Posts

Showing posts from January, 2013

c# - How to declare a const field of a generic value type provided as generic argument -

i'm trying define generic class accept argument value type (actually enum) , initialize const field it's default type. i want like: public abstract class genericclass<valuetype> valuetype: struct, iconvertible { public const valuetype val = default(valuetype); } unfortunately compiler complaints (i'm using mono think it's same on .net). error following: error cs1959: type parameter `valuetype' cannot declared const what's error? type parameter not allowed constant type. because struct cannot made const (from c# specification 10.4 constants ) the type specified in constant declaration must sbyte , byte , short , ushort , int , uint , long , ulong , char , float , double , decimal , bool , string , enum-type, or reference-type. a kind of workaround limitation declare static readonly . public static readonly valuetype val = default(valuetype);

Where does Android save your files? -

i'm using basic android developers code write file android system, i'm not sure app saving file. can check on phone make sure file being written , saved correctly. here's code: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); try { outputstream = openfileoutput(filename, context.mode_private); outputstream.write(string.getbytes()); outputstream.close(); } catch (exception e) { e.printstacktrace(); } } it creates file under /data/data/your.package.name/<name specify file> named test.txt /data/data/your.package.name/test.txt

Mysql - self join to check equality -

i have table structure below. id, firstname, lastname, address, phoneno i need select firstnames , lastnames repeated. example, 1 bob williams s-oak st 1234567890 2 rob williams n-oak st 1235432222 3 bob williams s-pec st 4332122111 i need make self join , result bob williams. no need self-join. select firstname, lastname, count(*) c table group firstname, lastname having c > 1

servlets - My service is not reached when using guice + gwt -

i trying setup guice+gwt far cannot invoke service . async request fails. here guice context listener: import ne.projl.client.service.projservice; import ne.projl.server.projserviceimpl; import com.google.inject.abstractmodule; import com.google.inject.guice; import com.google.inject.injector; import com.google.inject.persist.persistfilter; import com.google.inject.persist.jpa.jpapersistmodule; import com.google.inject.servlet.guiceservletcontextlistener; import com.google.inject.servlet.servletmodule; public class myguiceservletconfig extends guiceservletcontextlistener { @override protected injector getinjector() { return guice.createinjector(new servletmodule(){ @override protected void configureservlets() { // todo auto-generated method stub install(new jpapersistmodule("projpunit")); filter("/*").through(persistfilter.class); serve("springgwt...

apache - .htaccess rewrite but exclude password-protected directory results in 404 error -

i have pretty url setup .htaccess rewrites non-existent urls (not strictly 404 errors) php script serves either content or 404 message. have excluded existing files , directories rewriting css, images, etc, won't affected. however, there 1 directory password-protected .htpasswd should bypass rewrite rule not when .htpasswd enabled it. parent directory .htaccess: rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /callbacks.php [l] there's child directory following .htaccess: rewriteengine on options -indexes authname "backstage access" authtype basic authuserfile /path/to/.htpasswd authgroupfile /dev/null require valid-user if remove require valid-user line, parent directory's rewrite rule ignores child directory want, , can access browser. when turn on authorization, parent directory's .htaccess rewrites child directory /callbacks.php , resulting in custom 404 error. an...

html - is it technically possible to validate resizing through selenium? -

i'm trying automate test case covers resizing div element , making sure stays same in div (except size of of course). there way through selenium? i'm not sure want, here 3 things can verify: look @ html when resizing. if, element gains class "small", can element.getattribute("class").contains("small"); if css changes, can element.getcssvalue("someattribute").contains("something") finally, if want make sure none of html changes @ all, need source of webelement, requires work around (described here: get html source of webelement in selenium webdriver using python )

durandal - HotTowel SPA site launch with request paramters -

i have developed website using hottowel spa template. need users access spa website hyperlink on website parameters(query string/post). need access these paramters in shell.js header.html view need data. startmodule late access information if pass using :parm syntax in hash tag. can please advise best way around. thanks in advance vik you can access query string parameters in shell.js through window object. window.location.search there article on mdn showing this.

networking - Which network topology does Windows 'hostednetwork' use? Is it equivalent to Ad-Hoc's topology? -

i set access point using following command: netsh wlan set hostednetwork mode=allow ssid=dota key=pass keyusage=persistent i eager know topology (star, mesh etc.) use, may use optimally per needs. p.s.: did post question on superuser.com got no response. hoping lucky here. :) microsoft says the wireless hosted network new wlan feature supported on windows 7 , on windows server 2008 r2 wireless lan service installed. feature implements 2 major functions: the virtualization of physical wireless adapter more 1 virtual wireless adapter referred virtual wi-fi. software-based wireless access point (ap) referred softap uses designated virtual wireless adapter. and with feature, windows computer can use single physical wireless adapter connect client hardware access point (ap), while @ same time acting software ap allowing other wireless-capable devices connect it. as on ap mode (or managed mode) when want connect other wireless device connec...

oop - Referencing basic Java object in another class -

i'm beginner developing in java, , have run bit of problem referencing object (from different class) in class. this code used create object, file "neighborhoods.java". public class neighborhoods { // variables string name; int vertices; double[] latcoords; double[] longcoords; public neighborhoods() { neighborhoods fisherhill = new neighborhoods(); fisherhill.name = "fisher hill"; fisherhill.vertices = 4; fisherhill.latcoords = new double[] {42.331672, 42.326342, 42.334464, 42.335733}; fisherhill.longcoords = new double[] {-71.131277, -71.143036, -71.148615, -71.141062}; } } i tried use object created, "fisherhill" (from class neighborhoods) in main class when calling function different class (called "inpolygon"). inpolygon.check(neighborhoods.fisherhill.vertices); but reason, i'm getting error when try reference fisherhill object, says can't found. ...

c# - setting xml file path in web.config file -

my xml file resides in app_data folder of asp.net project. want set path of xml file in web.config file can accessed in class libraries. want because when move project our university computer makes problem. please me write code in web.config file , c# code through can accessed. also should mention have googled topic , searched on stack overflow nothing matched case add in configuration section : <appsettings> <add key="xmlpath" value="c:/users/jonesy" /> </appsettings> then in code : string path = configurationmanager.appsettings["xmlpath"]; you may need add reference system.configuration.

string - Delphi - Indy TIdHttp.Get with large URL length -

i'm trying use method indy 10 however, url's length bigger 255 chars. , method accepts "string" parameters. body := httpcom.get('..........wide string.........') delphi's compiler give me error: "string literals may have @ 255 elements" is there solution or different third-party component solve this? that no problem of string type ide, can write e.g. const c_url = 'a long text 255 characters ....to contionued ...' +'more content....to contionued ... ' +'more more content....to contionued ... ' +'enough content'; begin idhttp1.get(c_url); end; or idhttp1.get( 'a long text 255 characters ....to contionued ...' +'more content....to contionued ... ' +'more more content....to contionued ... ' +'enough content');

java - Is there any way to convert a Map to a JSON representation using Jackson without writing to a file? -

i'm trying use jackson convert hashmap json representation. however, ways i've seen involve writing file , reading back, seems inefficient. wondering if there anyway directly? here's example of instance i'd it public static party readoneparty(string partyname) { party localparty = new party(); if(connection==null) { connection = new dbconnection(); } try { string query = "select * pureservlet party_name=?"; ps = con.preparestatement(query); ps.setstring(1, partyname); resultset = ps.executequery(); meta = resultset.getmetadata(); string columnname, value; resultset.next(); for(int j=1;j<=meta.getcolumncount();j++) { // necessary start @ j=1 because of mysql index starting @ 1 columnname = meta.getcolumnlabel(j); value = resultset.getstring(columnname); localparty.getpartyinfo().put(columnname, value); // hashmap within party keeps track of individual values. column name = label, value val...

struts - logic:iterate comparing the next value -

i trying perform comparison current submission next. have following code: <logic:iterate id="anitem" name="datapage" property="filingslist" indexid="myind"> <bean:define id="currentsubmissionid" type="java.lang.string" name="anitem" property="denserank"/> i like: <logic:equal name="datapage" property="currentsubmissionid" value="nextsubmissionid???"> <img id="plus<%=rowcount%>" class="cursor" src="<icis2:icisres/>images/plus.gif" onclick="toggle('<%=rowcount%>', this, jquery('#minus<%=rowcount%>'))"/> <img id="minus<%=rowcount%>" class="cursor" src="<icis2:icisres/>images/minus.gif" onclick="toggle('<%=rowcount%>', this, jquery('#plus...

html - weird bug with jquery ui resizable -

i'm playing around jquery ui , noticed weird bug. when click button makes div resizable, div moves position below button. resizable.html: <html> <head> <link href="my.css" rel="stylesheet" type="text/css"/> <link href="jquery-ui.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery-ui.js"></script> <script> function makeresizable() { $("#divres").resizable(); } </script> <style> </style> </head> <body> <br><br><br><br><br><br><br><br><br><br> <button onclick="makeresizable();">make resizable</button> ...

jQuery event triggers -

i have select box onchange listener. functions 100% when human uses it. i've added modal dialog jqueryui create new option on said list. works 100% well. however, upon adding said new option list, trying 'fake' change event trigger user doesn't have it. never seems fire. can use trigger this? //##### addc ####// $( "#add" ).click(function(){ $( "#addform" ).dialog({ autoopen: true, height: 200, width: 350, modal: true, buttons: { "add": function() { var f = $('#folder').val(); var request = $.ajax({ url: "process.it" , type: "post" , data: { f : f } }); request.done(function(msg) { $("#version").append( $('<option></option>').val(msg).html(msg) ...

ruby on rails - Creating assoc record in HABTM through -

models: cities.rb: has_many :cities_users has_many :users, :through => :cities_users i have habtm (through) between cities , users . want view cities associated user. here's have , error is: users.rb has_many :cities_users has_many :cities, :through => :cities_users controller: @user = user.find(current_user.id) @users_cities = @user.cities i have written migration creates join table: create_table "cities_users", :id => false, :force => true |t| t.integer "user_id" t.integer "city_id" end this error (relating second line of controller code): uninitialized constant user::citiesuser i'm having similar problems creating city associated user too. many thanks. you should create new model if want use has_many :through association. please, consider using has_and_belongs_to_many direct many-to-many connection no intervening model. for details can read http://guides.rubyonrails.org/associati...

ruby - NameError: undefined local variable or method -

i have written simple ruby script , failing @ compiling. don't know problem. suggestions appreciated. class song def initialize (name, album, duration) @name = name @album = album @duration = duration end def duration=(new_duration) @duration=new _duration end def to_s "song: #@name #@album -- #@duration \n" end song = song.new("abc", "i don't lie...", 2.04) print song.to_s song.duration = 3.89 print song.to_s after compiling getting following error: ruby song.rb song: abc don't lie... -- 2.04 1. abc 2. don't lie... 3. 2.040000 nameerror: undefined local variable or method `_duration' #<song:0x3b500efd> duration= @ song.rb:21 song @ song.rb:37 (root) @ song.rb:1 you should remove method altogether , replace attr_writer . less error-prone , faster: class song attr_writer :duration def initialize (name, album, duration) @name = name @album = album @dur...

android - Getting Google Map Fragment in onCreateView using ActionBar tabs -

i'm trying retrieve google map fragment while using tabs in actionbar. when load tabbed page map loads fine, want map object can center it, add markers etc. is there way , if there is, kind show me how? here's code tabbed page... the specific method i'm working public static class map extends fragment public class page3activity extends fragmentactivity implements actionbar.tablistener { final context context = this; static googlemap map; static mapview mmapview; databasehandler db = new databasehandler(context); appsectionspageradapter mappsectionspageradapter; viewpager mviewpager; @suppresslint("newapi") public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.page3); // create adapter return fragment each of 3 primary sections // of app. mappsectionspageradapter = new appsectionspageradapter(getsupportfragmentmanage...

r - How to flatten exactly two dimensions of the nested list? -

suppose have list a built follows: a1<-list(1,2,list("x",10)) a2<-list("a",list("b"),"c") a3<-list(list("d",list("e")),3.14) a<-list(a1,a2,a3) how can transform a this: list(1,2,list("x",10),"a",list("b"),"c",list("d",list("e")),3.14) i want solution works arbitrary number of a1, a2, a3... an , not a1, a2 , a3 in example above. in mathematica use flatten[a,1] , how 1 in r? use unlist recursive=false : dput(unlist(a,recursive=false)) list(1, 2, list("x", 10), "a", list("b"), "c", list("d", list( "e")), 3.14)

android - SQLite group by/count hours, days, weeks, year -

assume have simple android application has 1 button. click on button record date , time of click (in sqlite). wondering best format records keep long or string of date-time. purpose make reports show: 1. sum of clicks made chosen day grouped hours. 2. sum of clicks made chosen week grouped days. 3. sum of clicks made chosen month grouped weeks. 4. sum of clicks made chosen year grouped month. how create such database , how do such queries? i'd vote using unix timestamps (number of seconds since "epoch"), given they're convenient range calculation , understood robust date-time libraries. sqlite provides few helper functions working unix timestamps. useful 1 here going strftime . you can insert current unix timestamp using strftime('%s', 'now') in insert. later, if know particular time range you're interested in, can calculate minimum , maximum timestamps range , select rows between them: select * data timestamp >=...

How to get expect to set a bash variable -

i following expect script set variable in main bash script. in other words set $ssh_success pass/fail string. have tried using $expect_out , $::env(ssh_success) have been unsuccessful. how set bash variable expect? expect << eof log_user 0 log_file $test_log set timeout 5 spawn ssh root@$radio_ip ..... ....expect script, echoing return of ssh command... send "echo\$?\n" expect { "0" { send_user "ssh test: passed\r" ssh_success="passed" } "1" { send_user "ssh test: failed\r" ssh_success="failed" } sleep 1 send_user "\n" exit eof echo $ssh_success i don't know expect, think it's this ssh_success=$(expect <<eof ... expect { "0" { puts "passed" } "1" { puts "failed" } ... eof ) echo $ssh_success

Resizing GXT Window When Browser Window Resizes -

developing using gxt 2.2.5 on gwt 2.3.0. the application i'm working on displays resizable window auto scrollbars. want make sure window size not exceed size of browser window gets displayed in. effect, added following code: addwindowlistener(new windowlistener() { public void windowactivate(windowevent we) { super.windowactivate(); window window = we.getwindow(); window.layout(true); int width = window.getwidth(); int height = window.getheight(); int maxwidth = xdom.getviewportwidth(); int maxheight = xdom.getviewportheight(); window.setsize(math.min(width, maxwidth), math.min(height, maxheight)); window.center(); } }; this manages sizing window fit in browser when gets opened quite nicely. my problem if user resizes browser window, open window not adjust , ends being clipped. is there way me either force window stay within boundaries of browser, or capture resize event can tell window resize accordingly? thanks. y...

Is Selenium suitable for use as an automation tool - as you would use cURL -

for several reasons cant use curl preform automated tasks on 3rd party site, we've tried using selenium instead , via php integration can work , preform tasks need. is there downside using selenium purpose - after reading see primary use seems automated testing tool, see reason not use part of webapp. the obvious 1 comes mind if change pages html, leave in similar position if using curl , changed post / data needed received server.. selenium not change html. however, if going try use post/gets selenium, require work around, if possible. you able navigate webpages, go urls, @ html, , execute javascript, if looking selenium.

loadrunner - How do I save off a variable per thread in vuser_init for repeated use in Action block? -

in loadrunner program, have initialization block in vuser_init modifies value of handle. static int handle =0; init(&handle); in case pointer handle modified init function. modified handle used other functions parameters within action block. problem static value of handle works first thread not others since read same static value. need static value of handle per thread action block called during each iteration thread can own handle. there way save handles list or map or structure in c recognized loadrunner? just build whatever c structure want , use it. loadrunner ansi c lcc compiler. you make linked list add , delete functions global , manage handles way. it's c. shoot moon , implement it. i not sure mean value of handle per thread? mean per virtual user? ask because web virtual user can have more 1 thread. if looking capture of distinct dynamic session information per virtual user common , standard loadrunner functions can used capture informatio...

css3 - background-size: cover bug in webkit -

Image
it looks me there bug in webkit, rounding issue, that's causing background-size property fail cover entire of element when set cover . jsfiddle: http://jsfiddle.net/um4cq/ (try resizing result area if don't see red background showing through on either left or top). i've seen references bug around net, some dating 2011 , i've yet hear developers. more importantly time being, if there's css workaround (without using javascript). has found viable workaround this? i added vendor prefix , fixed images, grouped background: shorthand rule color , no-repeat. fixed of images, not all, notice it's related image dimensions have, used same image (that working) images , worked. so aspect ratio of images has here , think it's because background-size: cover; trying not distort image messing aspect ratio. here's fiddle working ... rework images have aspect ratio fit it's container properly.

c - How to cleanly interrupt a thread blocking on a recv call? -

i have multithreaded server written in c, each client thread looking this: ssize_t n; struct request request; // main loop: receive requests client , send responses. while(running && (n = recv(sockfd, &request, sizeof(request), 0)) == sizeof(request)) { // process request , send response. } if(n == -1) perror("error receiving request client"); else if(n != sizeof(act)) fprintf(stderr, "error receiving request client: incomplete data\n"); // clean-up code. at point, client meets criteria must disconnected. if client regularly sending requests, fine because can informed of disconnection in responses; clients take long time send request, client threads end blocking in recv call, , client not disconnected until next request/response. is there clean way disconnect client thread while client thread blocking in recv call? tried close(sockfd) causes error error receiving request client: bad file descriptor occur, isn't accurate. ...

python - How to do this mysql query where I want to query columns side by side? -

i've table structure this: col1 col2 col3 1 1 1 1 2 1 1 3 1 2 10 1 now have information in tuples in python (1,2) column 1 , (1,1) column 3. i want query table such in select clause want correspond column 1 value column 3. by mean there 2 queries: select * table col1 = 1 , col3 = 1; select * table col1 = 2 , col3 = 1; i want combine these , many entries have in tuples. can lots of ands , union not solution beyond 10 values. your simplest method, that's not result in performance problems, going iterating across tuples , generating , condition each, enclosed in parentheses , joined or conditions, produce query thus: select * table (col1 = 1 , col3 = 1) or (col1 = 2 , col3 = 1) or (...) you're right, though, in that won't scale particularly well. might instead first analyze tuples values you're using in clause, in order generate more compact condition which, each unique acceptable col1 value, or'...

Full page jscrollpane keyboard arrow keys focus -

i have 2 problems demonstrated in jscrollpane website . first problem in order focus page need click on actual page before can use keyboard arrow keys scroll. second problem, main problem, if adjust page size width scroll bar appears on page, need click mouse on bottom right scroll bar square before can use keyboard arrow keys scroll through page. example clicking on page not focus scroll bars. you can use this: $("#container_element").hover(function () { $("#scrollable_element").focus(); //makes gain focus }); to make element cain focus when hover on (no need clicking). and in case want lose focus when stop hovering, use this: $("#container_element").mouseleave(function () { $("#scrollable_element").blur(); //makes lose focus });

c# - How do I detect a BitmapImage failing to load? -

i have following code load image url. if url doesn't exist, placeholder should loaded instead. public bitmapimage image { { if (m_image == null) { try { bitmapimage image = new bitmapimage(); image.begininit(); image.urisource = new uri(m_photopath); image.decodepixelheight = s_imagepixelheight; image.endinit(); m_image = image; } catch (filenotfoundexception) { bitmapimage image = new bitmapimage(); image.begininit(); image.urisource = new uri(c_placeholderimagepath); image.decodepixelheight = s_imagepixelheight; image.decodepixelwidth = s_imagepixelwidth; image.endinit(); m_image = image; } } return m_image; } } i'm getting weirdest error - when m_p...

html - how to vertically align table data -

i have following table alignment goes wrong because of values have brackets in them. build data in c# although table rendered using html. have jquery available. there way correct alignment in either of these languages please? | value | | 40% | | 20% | | (30%) | | 10% | notice how 30% not aligned correct because of brackets. thanks, james as building data on server-side (c#), (and being numbers better off right-aligned) append space before sending data down client. (1) convert data string. if brackets because of being negative append space positive numbers while converting string. if brackets there after conversion string (result of format), append space string values not ending ")". for example: while formatting numbers: string myformat = "#0% ;(#0%)"; myvalue.tostring(myformat); notice space after positive part (first part) of format. for example: if data string: if (! stringvalue.substring(stringvalue.length - 1) == ...

ruby - Rake task to update a column value -

i writing rake task update value in specific column in table. when run task, error: uninitialized constant firstlooksubscription here rake task code: namespace :first_look_db desc "adds 1 month subscription" firstsubscription.where(subscription_state: 'active').each |t| t.update_attribute :next_billing_check, '2013-9-10' end end i new rake tasks, , don't want migration. advice great! also note: when run in rails console, executes without problem, biggest issue turning rake task our lead dev can run it you need task name. namespace gives namespace of task, declare task name , import environment can find activerecords: namespace :first_look_db desc "adds 1 month subscription" task :add_month_to_look_sub => :environment firstsubscription.where(subscription_state: 'active').each |t| t.update_attribute :next_billing_check, '2013-9-10' end end end this go file called li...

Joomla CSS not rendering on IE or Firefox -

just had frustrating couple of hours , figured i'd haul out big guns , ask intertubes. i have joomla site 3rd party template doesn't seem rendering css in ie8, ie9 or firefox, opera, chrome , safari reading boss. site is: http://www.quizzically.co.uk theme is: http://joomlathemes.co/free-orange-template-for-joomla-2.5/ the internet abuzz questions upwards of 4 years ago issue, i'm not finding recent. old issues personal sites happened on no love on answers did find. my gut feeling directs css not being picked or being ignored firefox , ie. don't know or how begin looking can offered ecstatically accepted. thanks. line 39 of styles.css has incorrectly coded background style: #header-w {position:relative; background:"fff } the " should # color. ie , firefox using stricter standards others, break once there's error. once that's corrected, rest of styles load.

How to get latest index of GROUP BY in mysql query? -

i got confused algorithm , way latest index of group by. have query this. select hasil_kmbg result, extract(month tgl_check) month, extract(year tgl_check) year perkembangan no_pasien=11 group month, id_kmbg desc and here result of query |result|month|year| ------------------- |3 |1 |2013| |1 |1 |2013| |5 |1 |2013| |1 |2 |2013| |1 |3 |2013| , on the question is, how result result 3 in month 1? didn't want show other result int month 1 except 3 (the latest, order desc). you getting multiple rows per month because have included id_kmbg in group by clause. think want max() function: select max(hasil_kmbg) result, extract(month tgl_check) month, extract(year tgl_check) year perkembangan no_pasien=11 group month, year;

google app engine - GAE NDB Datastore: does a single put affect the whole entity? -

when using google app engine ndb datastore altering , putting 1 property of entity affect whole thing? for example have video entity: class video(ndb.model): title = ndb.stringproperty(required = true) category = ndb.stringproperty(required = true) original_video_ref = ndb.blobkeyproperty() webm_video_ref = ndb.blobkeyproperty() mp4_video_ref = ndb.blobkeyproperty() and let user edit title , category whenever want , put out process on task queue take original video , return me in webm , mp4 formats. process takes variable amount of time can occur right when user editing it, , will, wondering if can have two, simultaneous, puts on different properties of entity without interfering each other or needing use transactions. no. a put entire entity. there no partial update.

php - Unable to get the image from mysql DB -

i'm new php. have sample mysql db in have table named testdb columns id(int) , image(blob). have uploaded image testdb. uploaded successfully. following php code. variable $conn contains connection details. have html page redirects php page on submitting. <?php $name = $_files["sample"]["name"]; echo $name . "<br/>"; $tmp_name = $_files["sample"]["tmp_name"]; echo $tmp_name . "<br/>"; $size = $_files["sample"]["size"]; echo $size . "<br/>"; $contents = file_get_contents($tmp_name); $htmlen = htmlentities($contents); $cont = mysql_real_escape_string($contents); $query = "insert testdb(image) values ('$cont')"; $dbquery = mysql_query($query, $conn); if($dbquery){ echo "successfully inserted"; } else{ echo "could not inserted" . mysql_error(); } ?> i trying image following code. showing string characte...

How can I fix a PDF document that was scanned backwards? -

i received email containing pdf document scanned backwards. tried rotating pdf complete version 4.0.65 didn't correct problem. user emailed doesn't have original document re-scan correctly. how can fix it? this should work pdf's install pdf printer bullzip pdf printer http://www.bullzip.com/products/pdf/info.php open pdf in eg. adobe reader , select print, select pdf printer printer in "pages print area" select more options , select reverse pages. this create pdf pages in reverse order

php - Authenticate single user in Google Calendar api -

i'm working on system allows schedule events using google's calendar api. however, going small company's internal use , need use single google account (ie 1 entire company) can have access exact same events. i've implemented calendar api , scheduling functionality (in php btw), when authenticating user able login google account, including personal ones. should able authenticate company account events don't scheduled personal accounts. what thought doing checking authenticated account's email address see if matches company one, , if doesn't error displayed telling them on wrong account. this work, seems inefficient , ugly solution (especially considering i'd need use google+ api email address). what recommended way of doing this? (also, calendar api documentation sucks. what's that!) if authenticating using google's oauth2 mechanism, must register app in google api console ( https://code.google.com/apis/console ), , provide ...

asp.net mvc 4 - View to Controller Data Conversion -

working on mvc4 + jquery software. on jquery front-end/ui, configured "go" button to: put related form data data object call var datatosend = json.stringify(data) send ajax post request datatosend for server-side controller, i've noticed there methods (whose names match controller routes' actions) contain argument inputs, such int or string . how client-side json gets converted int or string server-side controller? need convert json data in way? no, don't have special. mvc model binder work it's magic , it's best map post data action parameters (it attempt map them name). don't typically have worry doing type conversion; model binder you. here's excellent primer on how mvc model binder works ootb: http://dotnetslackers.com/articles/aspnet/understanding-asp-net-mvc-model-binding.aspx

asp.net mvc 3 - Validation for textbox in MVC3 -

i need help. working mvc3-razor application. need validate textbox on view (.cshtml file) in such way that, starting 2 characters must "pr" , 4th character must "2". requirement. how achieve functionality? suggestions, great help. precious time. model public class registermodel { public int id { get; set; } [regularexpression(@"^pr[a-za-z0-9]2([a-za-z0-9]*)$", errormessage = "please enter valid name.")] [required(errormessage = "name required.")] public string name { get; set; } } view @using (html.beginform("dymaniccontrollerpage", "test", formmethod.post, new { id = "frmindex" })) { <div> @html.labelfor(m => m.name) @html.textboxfor(m => m.name) @html.validationmessagefor(m => m.name) </div> }

java - Fairness setting in semaphore class -

i trying understand usefulness of fairness property in semaphore class. specifically quote javadoc mentions that: generally, semaphores used control resource access should initialized fair, ensure no thread starved out accessing resource. when using semaphores other kinds of synchronization control, throughput advantages of non-fair ordering outweigh fairness considerations. could provide example barging might desired here. cannot think past resource access use case. also, why default non-fair behavior? lastly, there performance implications in using fairness behavior? java's built-in concurrency constructs ( synchronized , wait() , notify() ,...) not specify thread should freed when lock released. jvm implementation decide algorithm use. fairness gives more control: when lock released, thread longest wait time given lock (fifo processing). without fairness (and bad algorithm) might have situation thread waiting lock because there continuous stream of ot...

opengl - Custom real-time drawing in Qt5 and Qt Quick 2 -

i have been looking far , wide find out how, if it’s possible, can fill particular area in qml screen opengl context , custom opengl in context. i’ve seen plenty of demos qml components buttons, etc lay on top or below screen-wide opengl context (as typically required games), i’d able situate several distinct opengl contexts within qml , have qml file define how large are, positioned, etc. now, since qt 5 opengl under hood, makes me wonder if using canvas element custom drawing via javascript result in similar rendering performance custom opengl? meaningful alternative it’s not clear me how javascript drawing handled via runtime compared custom opengl drawing. what want draw? qquickpainteditem may simplest way go it. when you're using qopenglframebufferobject target, painter use opengl paint texture. might easier writing own opengl code if you're doing 2d.

android - My existing Keystore does not exists -

Image
i updating code next version. after clicked "export signed application package", got error stating keystore not exists. didn't delete sure. unable update app since existing keystore vanished. check whether have deleted file, tried recovery software. unable find. tried similar questions , there no suitable result. please me recover the old keystore. (sorry bad english) first check out ,where key store exits ? @ default location or have stored @ else. default path other location if storing key store @ other location check out rebuild time idea. and if there okay issue password. so,it if create new key store , use it

list - Excel - VBA : Simplify this If statement comparing cell to words -

easy question here. using in program : if lcase(inp_rng.offset(1, 0).value) = "street" or lcase(inp_rng.offset(1, 0)) = "ave." score = score - 50 end if it not clean can find way put in 1 sentence only. programming way of writing this: if lcase(inp_rng.offset(1,0).value = ("street", "ave.", "road", "...", etc.) 'do end if thanks in advance! you can use select case statement instead: i = lcase(inp_rng.offset(1,0).value select case case "street", "ave.", "road" 'do case else 'do end select alternatively can populate possible answers in array , search array match.

jquery - code for ajax on text field using database -

i making web portal institute intern. currently making module on telephone directory. mentor has asked me apply ajax on text field entering employee name. using dreamweaver cs4 , mysql database through phpmyadmin. my problem is: how apply ajax on text field such whole list of employee names appears list on entering single character. same google does, gives suggestions. have searched lot , got no code this. dreamweaver has limited features , it's getting tough work it. i guess these 2 links might u achieve want. http://beski.wordpress.com/2009/11/20/jquery-php-mysql-ajax-autocomplete/ . http://jqueryui.com/autocomplete/

html - Keep relative positioned images at the bottom when size of one changes -

i have images in div, grow bigger when move mose on them. problem is, if 1 of them gets bigger, other images stay @ top of div , move up. i tried setting bottom property of images 0, doesnt work because positioned relative. if set position absolute , bring them right position, overlap when grow bigger. i tried set vertical-align of parent div bottom doesn't work either. my html: <div id="picmen"> <img src="/images/b1.png" /> <img src="/images/b2.png" /> <img src="/images/b3.png" /> <img src="/images/b4.png" /> <img src="/images/b5.png" /> <img src="/images/b6.png" /> <img src="/images/b7.png" /> </div> my css: #picmen { position: absolute; right: 0px; bottom: 0px; vertical-align: bottom; } #picmen img { float: right; margin: 3px 1px 3px 1px; height: 50px; width: 50px; tr...

c# - Is there a way to pass an argument to the is operator? -

i trying find alternative following can take advantage of is operator. public bool isoftype(type type) { return this._item.gettype() == type; } something similar following, not compile. public bool isoftype(type type) { return this._item type; } i think you're looking type.isassignablefrom : public bool isoftype(type type) { return _item != null && type.isassignablefrom(_item.gettype()); } or if can make method generic, that's simpler can use is type parameter: public bool isoftype<t>() { return _item t; } edit: noted in wim's answer, there's type.isinstanceof makes non-generic method simpler: public bool isoftype(type type) { return type.instanceof(_item); }

c# - Form Builder On the fly With asp.net mvc site -

is there open source form builder can add mvc project , create form on fly it. want users can create series of form , mvc program render them. i saw http://www.wufoo.com , http://www.jotform.com , these ideal form of user story. naked objects .net framework takes domain object model, written pocos following few simple conventions, , dynamically creates 1 or more complete interfaces it, using reflection (not 'code generation' or 'scaffolding'). naked objects mvc builds upon core framework create complete web-based user interface, using asp.net mvc 4. https://github.com/nakedobjectsgroup/nakedobjectsframework

c++ - When does std::unique_ptr<A> need a special deleter if A has a destructor? -

if class a in unique_ptr<a> it's own destructor, necessary declare deleter ensure unique pointer uses destructor? example thinking of a has member mx of type user_matrix (a name made up) needs call function free(...) release memory, 1 define ~a(){ user_matrix::free(mx); /*etc*/} since default_deleter<> call delete , understanding that should use ~a() . however, example opening , closing of directories in section 5.2, under "deleters associated resources", of book of josuttis (the c++ standard library: tutorial , reference) suggests 1 may need declare special deleter this, confused.... because, in given example, class dir doesn't have destructor uses closedir(...) ? the default deleter of std::unique_ptr<t> call delete , default deleter of std::unique_ptr<t[]> call delete[] , call destructors of objects appropriately. what may happen operation need scheduled right before destruction, either because destructor incom...

The 'this' keyword in Unity3D scripts (c# script, JavaScript) -

i'm confused that: code (cs01.cs) the script attached simple cube object. using unityengine; using system.collections; public class cs01 : monobehaviour { // use initialization void start () { debug.log (this); //--> cube(cs01) debug.log (this.gettype()); //--> cs01 debug.log (this.gettype() == typeof(unityengine.gameobject)); //--> false debug.log (this == gameobject); //--> false debug.log (this.name); //--> cube debug.log (gameobject.name); //--> cube this.name = "hello"; // --> gameobject's name changed 'hello' debug.log (gameobject.name); //--> hello } // update called once per frame void update () { } } 1> cs01 script object right? doc : scripting inside unity consists of attaching custom script objects called behaviours game objects. 2> in component object, variables transform, renderer, rigidbody referenced c...

perl - Can not send data to IO::Socket::INET in conditional statement -

i have issue communicating external system via io::socket::inet. try login , send multiple commands system unfortunately does'n work if command print in line 58 under conditional statement. conditional statements in case required handle response data. package net::cli::cisco; use 5.006; use strict; use warnings fatal => qw(all); use io::socket::inet; use carp; use data::dumper; $| = 1; sub new { $class = shift; %args = @_; $self = bless { _host => $args{host} || carp('no hostname defined'), _username => $args{username} || carp('no username defined'), _password => $args{password} || carp('no password defined'), _logged_in => 0, }, $class; return $self; } sub connect { $self = shift; $host = $self->{_host}; $port = 23; $handle = io::socket::inet->new( proto => "tcp", peeraddr => $host, peerport => $port, ...

php - Retrieving module parameter settings in a template joomla 2.5 -

i'm trying settings saved within specific module in specific template position in joomla 2.5 site use in module chrome i'm making website template. i'm not sure how information can retrieved. how done module: newsflash, position: banner would insert code here function modchrome_strhtml($module,&$params,&$attribs) { //content manipulated here } clarification i using newsflash module display specific news articles on homepage. i manipulate article content displayed in module match structure i'm using in site using module chrome article content , arrange dont know how access parameters sent newsflash module (the specified category) , other parameters can use in module chrome. looking for. i hope clarifies question. you want use jmodulehelper. it's hard more without knowing doing.

php - How to override classes in lib/Varien directory? -

i want override \lib\varien\data\collection\db.php . know how override creating same file path in local code pool. want know possible override class same way overriding models, blocks inside our modules? appreciated. no, can not rewrite varien_data_collection_db dynamic way models, etc. the reason simple: appropriate magento models use varien_data_collection_db base class , literally extend it: abstract class mage_core_model_resource_db_collection_abstract extends varien_data_collection_db {} abstract class mage_eav_model_entity_collection_abstract extends varien_data_collection_db {} class mage_sales_model_resource_sale_collection extends varien_data_collection_db {} copying class local or community code pool way go.

Check color of the rows of the datagridview c# -

i want check if row contains white color should not replaced in datagridview otherwise if contains other color text in row can replaced don't know how check condition in scenario. this code. private void button9_click_1(object sender, eventargs e) { var original = ((datatable)datagridview1.datasource); var clone = original.clone(); var ordinal = original.columns["stringtext"].ordinal; (int = 0; < original.rows.count; i++) { var values = original.rows[i].itemarray; values[ordinal] = ((values[ordinal].tostring()).tolower()) .replace(textbox6.text.tolower(), textbox7.text); clone.rows.add(values); } datagridview1.datasource = clone; string filterby; filterby = "stringtext '%" + textbox7.text + "%'"; ((datatable)datagridview1.datasource).defaultview.rowfilter = filterby; } any ideas? to loop through cells in datagridview , check backgroun...