Posts

Showing posts from June, 2012

xls - java.lang.IllegalArgumentException: Your InputStream was neither an OLE2 stream, nor an OOXML stream -

when i'm reading excel file(.xls format), keep getting exception : java.lang.illegalargumentexception: input stream neither ole 2 stream, nor ooxml stream. i go-ogled , found if input stream not supporting reset or mark, should wrap pushbackstream . input stream not mark\reset supported. so using pushbackstream option? how use it? , whats use of it? thanks your inputstream neither ole2 stream, nor ooxml stream java.lang.illegalargumentexception: inputstream neither ole2 stream, nor ooxml stream i guess using workbook factory or different format input file , different workbook type. error pops when not able not able read file type. apache poi not check file extension. if open in text editor, you'll see instead it'll in different format. or might initializing workbook type hssf or xssf, before using workbook factory. simpler solution open file using microsoft excel , save file(using file>save option microsoft excel > menu ). workbook factory

c# - Shell Context Menus -

i running windows 7 x64 machine . i have written following code add context menu on right click: registrykey rkey = registry.classesroot.opensubkey("directory\\background\\shell", true); string[] names = rkey.getsubkeynames(); foreach (string s in names) { system.windows.forms.messagebox.show(s); } registrykey newkey = rkey.createsubkey("your application"); registrykey newsubkey = newkey.createsubkey("command"); newsubkey.setvalue("", "c:\\windows\\system32\\notepad.exe"); newsubkey.close(); newkey.close(); rkey.close(); if repeat procedure directly on registry, works, not via this. i able access registry, have added snippet tells lists subkeys require, not add one. i have tested code , & good. looks dont have access rights open registry code. follow these simple steps: close visual studio. open again run administrator mode. 1 can right cl

matlab - How does "bwareaopen" work? -

i saw documentation of bwareaopen , confusing me number of pixels. when 8-neighbourhood , doesn't mean 9-pixels ? in function, specify number of pixels, , if see example provided in documentation, find mention 50-pixels , mean 10x5 window? so, if specify number of pixels, function do? mentions removing small pixels. mean? isn't each square in image matrix considered square? small pixel in case? thanks. you mixing 2 of variables. in documentation can see following: bw2 = bwareaopen(bw, p) bw2 = bwareaopen(bw, p, conn) where have p , conn variables. conn neighbourhood variable. chose values understand "neigbour". see example: conn=4; - x - x 0 x - x - conn=8 x x x x 0 x x x x higher numbers higher dimensions. p variable variable choose "small". the function bwareaopen delete white areas smaller p pixels. in example in documentation can see: bw = imread('text.png'); bw2 = bwareaopen(bw, 50); imshow

python - No POST responses from real time callbacks -

basic idea of i'm doing. want grab users' likes , print them in cli application (python script listens get/post messages using twisted framework). i have done oauth via inline canvas html: <a target='_top' href="https://www.facebook.com/dialog/oauth/?client_id=1111111111111&redirect_uri=https://apps.facebook.com/xxxxxxx/&scope=user_likes">grant permissions</a> right seems well? okay i've gone real time subscriptions section within facebook app section , added see image* : http://i.stack.imgur.com/l2i3t.png , when run test, python code returns result, see*: http://i.stack.imgur.com/9d2ek.png so i'm stuck though. because expect happen when like callback show in callback script. i'm printing given render_post , render_get , responses come out fine, example get {'hub.verify_token': ['test'], 'hub.challenge': ['73678294'], 'hub.mode': ['subscribe']} {'hub.verify_

How to delete superclass entity whose subclass entity has been removed in Hibernate? -

there 2 entity classes , b, , instances a, b (a , b have same id). b subclass of ( b extends a). removed entity "b" database. then, saw "a" has not been deleted. s want. @ point of code, want remove "a" too. when entitymanager.remove(a) throws exception saying, detached entity can t removed. seems removing subclass entity makes superclass entity detached although superclass entity remains in database. can me remove instance a. note: , b have same ids because when create b, automatically created same id ( rule of inheritance). you should use session.delete(b) . deletes both records database. after having deleted b record native sql delete statement, have delete record accordingly native delete statement.

Struts2: Is there a way that checkbox directly links to action class when checkbox is checked? -

for eg: <s:checkbox name="checkme" fieldvalue="true" label="check me testing" action="someactionclass"/> when checkbox selected, control not redirecting particular action class method. you must use javascript problem , toggle action of form according change event of checkbox. here's example using jquery: $('#checkboxid').change(function() { if(this.checked) { // when checked, change action. } else { // else } });

MSBuild says XML doc file (created from C# comments) does not exist, but it exists prior to build -

when set property <documentationfile> on msbuild project, corecompile task executed, when files present , up-to-date. msbuild says runs corecompile task because th file "c:\users\georges\documents\visual studio 2010\projects\test\test\bin\debug\test.xml" not exist, exists , up-to-date. details below. my msbuild file i created brand new console application project in visual studio 2010, , added following lines .csproj (just before import of $(msbuildtoolspath)\microsoft.csharp.targets near end of file): <propertygroup> <targetstriggeredbycompilation> $(targetstriggeredbycompilation);mytarget </targetstriggeredbycompilation> <usehostcompilerifavailable>false</usehostcompilerifavailable> <documentationfile>$(msbuildprojectdirectory)\$(outputpath)$(msbuildprojectname).xml</documentationfile> </propertygroup> <target name="mytarget"> <message text="myt

regex - How do I mod_rewrite this URL? -

i have url www.domain.com/catalog.php?category_title=widgets i want mod_rewrite www.domain.com/widgets/ i've tried rewriteengine on rewriterule /([^/.]+)/[?]*[^\/\.]*$ /catalog.php?category_title=$1 so i'm searching /([^/.]+)/ the [?]*[^\/\.]* part page can work google adwords appends query string flat url. this regex worked on a previous implementation using zeus's request rewrite module proprietary version of mod_rewrite. this first go @ apache mod_rewrite, , can't work. try using: rewriteengine on rewriterule ^([^/]*)/$ /catalog.php?category_title=$1 [l]

java - Ehcache with tomcat simple example -

i want include ehcache in java web application hosted in tomcat. want check cache key , if key exists retrieve it, if not add cache later retrieval (just memcached usage scenario). i searched documentation , couldn't find useful information on how implement simple example. found out need put ehcache-core.jar , slf4j*.jar in classpath along ehcache.xml. ? can see ehcache cache object in examples - should instantiate in order accessible servlets / jsps ? also, can recommend simple cache configuration put in ehcache.xml ? default <defaultcache maxentrieslocalheap="0" eternal="false" timetoidleseconds="1200" timetoliveseconds="1200"> </defaultcache> ok ? do like cachemanager.getinstance().addcache("xyz"); // creates cache called xyz. cache xyz = cachemanager.getinstance().getcache("xyz"); xyz.put(new element("key", new person()))

php - SPHINX enable_star not working -

i wish search substrings using results sphinx returned. is setting ok? do need restart searchd process? index dev_jobs { source = dev_jobs_src path = /home/sphinx/jobs/dev_jobs docinfo = extern charset_type = utf-8 enable_star = 1 min_infix_len = 3 } searchd { port = 9312 log = /var/log/sphinx/searchd.log query_log = /var/log/sphinx/query.log read_timeout = 5 max_children = 30 pid_file = /var/run/sphinx/searchd.pid max_matches = 100000 seamless_rotate = 1 preopen_indexes = 0 unlink_old = 1 } and php part of code: $sphinx_search = yii::app()->search; $sphinx_search->setselect('*'); $sphinx_search_final = ''; $sphinx_search_query = trim($this->q); if (strlen($sphinx_search_query) > 0) { $sphinx_search_query = str_replace('-', ' ', $sphinx_search_query); $keys = exp

c++ - QProcess - Unable to start program - No such file or directory -

i trying start program (tftp) qprocess. no matter how start it, won't run. have tried add absolute path, call inside cmd shell, system can't find it. on windows 8, using qt 4.8 qstring command("c:\\windows\\system32\\tftp.exe"); qprocess* downloadprocess = new qprocess(this); downloadprocess->setworkingdirectory("c:\\windows\\system32"); downloadprocess->setreadchannelmode(qprocess::mergedchannels); connect(downloadprocess, signal(finished(int,qprocess::exitstatus)), this, slot(ondownloadfinished(int,qprocess::exitstatus))); connect(downloadprocess, signal(error(qprocess::processerror)), this, slot(onprocesserror(qprocess::processerror))); connect(downloadprocess, signal(started()), this, slot(onprocessstart())); downloadprocess->start(command); result: "process failed start: no such file or directory could due execution privilege or else? (howeve tftp runs in shell)

initialization - Using Critical Sections/Semaphores in C++ -

i started using c++ instead of delphi. , there things seem quite different. example don't know how initialize variables semaphores , criticalsections. know 2 possible ways: 1. initializing critical section in constructor stupid since every instance using own critical section without synchronizing anything, right? 2. using global var , initializing when form created seems not perfect solution, well. can tell me how achieve this? just short explanation need critical section : i'd fill listbox different threads. semaphore : different threads moving mouse, shouldn't interrupted. thanks! contrary delphi, c++ has no concept of unit initialization/finalization (but found out that). what left little. need distinguish 2 things: where declare variable (global, static class member, class member, local function, static in function -- guess covers all) where initialize variable (since concerned c api have call initialization function yourself) fact is, in case

objective c - how to upload/download a file from/to dropbox using xcode -

i new ios. how upload/download file from/to dropbox? integrated dropbox applications in app, couldn't upload/download file. this upload code: - (nsstring *)getdocumentpath { nsmutabledata * pdfdata = [nsmutabledata data]; uigraphicsbeginpdfcontexttodata(pdfdata, self.view.bounds, nil); uigraphicsbeginpdfpage(); cgcontextref pdfcontext = uigraphicsgetcurrentcontext(); [self.view.layer renderincontext:pdfcontext]; uigraphicsendpdfcontext(); nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *path = [[paths objectatindex:0] stringbyappendingpathcomponent:@"vani.doc"]; [pdfdata writetofile:path atomically:yes]; return path; } - (ibaction)upload:(id)sender { nsstring *path = [self getdocumentpath]; nsstring * local = [path lastpathcomponent]; nsstring *destdir = @"/plist folder/vani.doc"; [restclient uploadfile:local topath:destdir wit

Generate unique string in sql server 2012 -

i have table create table #agency ( agencyid int primary key identity(1,1), agencyname varchar(100), agencycode varchar(50) ) i want generate unique agency code while inserting table...agency code should consists of alphabets ..no numbers or special characters thank you you can simple casting id varchar , replacing every digit letter (or combination). 1=a, 2=b, etc.. so, long ids unique, code be. snippet like: replace(replace(replace(replace(replace(replace(replace(replace(replace(replace( cast(agencyid varchar(50)) ,'1','a'),'2','b'),'3','c'),'4','d'),'5','e'),'6','f'),'7','g'),'8','h'),'9','i'),'0','j') if want during insert, can use ident_current('tablename') value inserts identity column. insert agency (agencyname, agencycode) select 'name001',

java - Display more than one div or table content of same id from onchange value -

i'd know if can display more 1 div or table content of same id onchange value. if select option drop down , displays content want display content elsewhere in page when same option selected. my code follows: <select name="debitordertype" id = "debitordertype" onchange="display(this,'bank','card','invoice');"> <option>please select...</option> <option value="bank" selected>debit order (monthly)</option> <option value="card">credit card (monthly)</option> <option value="invoice">invoice (yearly)</option> </select> then when selecting invoice dropdown displays following: <tbody id="invoice" style="display: none;"> <tr> <td class="field">thank selecting pay yearly in advance. doing receiving 1 month's free listing. </td></tr> </tbody> but want display followi

python - Read feedback from commands? -

i need use command lsmod check if mod loaded, don't know how read after running it. im using subprocess.popen() run it. point in right direction appreciated. :d suppose looking ath in lsmod , command be: lsmod | grep ath using subprocess : in [60]: c=subprocess.popen("lsmod",stdout=subprocess.pipe) in [61]: gr=subprocess.popen(["grep" ,"ath"],stdin=c.stdout,stdout=subprocess.pipe) in [62]: print gr.communicate()[0] ath5k 135206 0 ath 19188 1 ath5k mac80211 461261 1 ath5k cfg80211 175574 3 ath5k,ath,mac80211

sql server - datediff between multiple records in SQL -

i have 1 scenario want count if date difference between 2 dates <=14 days.that in first table have filter records 1 value of date1 values <=14 days of date2. for ex: q1="select date1 date1_table"; q2="select date2 date2_table"; simple query : select count(*) date1_table datediff(dd,date1,(select date2 date2_table))<=14 but have multiple records in both tables,but want choose record having difference count >0.so,it throwing error subquery returned more 1 record.i want solutions this.i using sql server 2008 note:i can't use join here.because wanted results 2 different queries. in advance. you can use top 1 clause in query.. select top 1 * date1_table datediff(dd,date1,(select date2 date2_table))<=14

unicode - How to get symbols from a particular font as array using jquery -

i need display symbols selected font done in microsoft word's insert symbol. if can symbols font in array, then, can show them in table anchors insert them web page's targeted text area when user clicks. new web development. or if can r compute unicode symbols can use them. have rigorously searched unicode of various symbols getting tedious there many symbols , not able code all. any appreciated.

ios6 - loading cached webpage in UIWebView in ios -

i've task increasing speed of webpage loading in uiwebview. i'm moving cache concept. here i'm using asiwebpagerequest cache content of webpage. doing well.but when load cached webpage, hyperlinks not working(not linking live url)? and one. if webpage cached means,its loads cache otherwise loads live url. how can fix it? here code: - (void)fetchurl:(nsurl *)url { [self setrequestsinprogress:[nsmutablearray array]]; [request setdelegate:nil]; [request cancel]; [self setrequest:[asiwebpagerequest requestwithurl:url]]; [request setdidfailselector:@selector(webpagefetchfailed:)]; [request setdidfinishselector:@selector(webpagefetchsucceeded:)]; [request setdelegate:self]; [request setdownloadprogressdelegate:self]; [request seturlreplacementmode:asireplaceexternalresourceswithdata]; [request setdownloadcache:[asidownloadcache sharedcache]]; [request setcachepolicy:asionlyloadifnotcachedcachepolicy]; // efficient w

Render HTML on Node.js Express (Include HTML code in another HTML file) -

i'm using node.js server express-framework installed , have problem combining 2 different html-files. i have basic template.html file <div id="content"> in it. want include content.html within div before sending data client. how can done? i use ejs because it's straight-forward templating language, same idea applies jade or whatever might use. enable in express after running npm install ejs : app.engine('.ejs', require('ejs').__express); when send response, run: res.render('content.html.ejs'); spit template.html views/header.html.ejs , views/footer.html.ejs , , include them in views/content.html.ejs this: <% include header.ejs %> content here <% include footer.ejs %>

java - Search 2d Array -

so im writing java program should find shortest way entrance "2" 1 of numbers "3" . can walk on " " positions. "1" walls. 11111121 131 1 1 1 1111 1 1 13 1 1 1 11 1 1 1 1 1 1 11111111 my starting idea find entrance in 2d array. done this: point entrance = new point(0,0); (int = 0; < n; i++) { (int j = 0; j < n; j++){ if(map[i][j] == 2){ entrance.x =i; entrance.y =j; } } i find 2 "3" , save them in points. but im not sure how return rute closest "3" . considering joystick, save direction go, (up, down, left, right). return full list of moves entrance closests 3. got suggestion or ideas how implement ? what have here non-cannonical representation of graph. have each cell being vertex in graph , have edge between 2 neighboring cells if , if both of them free. now @ problem in way, find entrance , breadth first search find exit

probability - Monty Hall Program Simulation (C#) -

i trying simulate monty hall problem (because read book think statistics guy in particular convinced after seeing computer simulation) in c#, programming language familiar me. scenario such position of prize random (in each run), choice random, , game host's choice of opening door random (it can't random if picked non-prize). surprisingly though, program achieves result of 50:50 chance of winning no matter whether switch or not. here's code (pardon me lengthiness): class program { static void main(string[] args) { random rand = new random(); int noswitchwins = rungames(rand, false, 10000); int switchwins = rungames(rand, true, 10000); console.writeline(string.format("if don't switch, win {0} out of 1000 games.", noswitchwins)); console.writeline(string.format("if switch, win {0} out of 1000 games.", switchwins)); console.readline(); } static int rungames(random rand, bool d

c - Using the return value of "scanf()" to check for end of file -

i searching net on how use return value of scanf check end of file! found following code.but having difficulty in understanding? how method working? what '~' operator signify? while(~scanf("%d",&n)) { /* solution */ } this horrible way check if value different -1. ~x returns bitwise negation of x . having in mind complimentary code used negative numbers(on most compilers way approach not portable) -1 represented sequence of 1-s , ~(-1) produce zero. please don't use approach. write scanf("%d", &n) != eof way easier understand.

windows - How to use svn+ssh with Tortoise SVN from the command line -

i'm having trouble trying checkout repo using following syntax on windows 7 workstation tortoisesvn: svn co svn+ssh://user@ip/repo . what i've done test issue: modified network settings of tortoisesvn point ..\tortoiseplink.exe successfully established ssh connection target machine no issues successfully checked out repos workstations running ubuntu openssh when try above syntax command line on windows 7 workstation error: svn: e720087: unable connect repository @ url 'svn+ssh:///user@ip/repo' svn: e720087: can't create tunnel:the parameter incorrect. interestingly, if use tortoise gui browse repo can open , check out repo. need command line scripting purposes. any suggestions? for svn+ssh work tortoise, make sure %svn_ssh% set ssh client (probably plink.exe tortoise or putty) , path must written either forward slashes / or escaped backslashes \\ . try set %svn_ssh% absolute path of plink while escaping backslashes, c:\\program f

solr - Get possible facet fields with search results -

i'm working on improving search powered solr e-commerce project. search queries performed solr , results returned solr. this working fine. need offer facet on search results. first category easy implement category common product , in query make enable facet , pass category facet field. however, different nature of products there different products , have few facets defined them. i'm clueless how know them in advance , pass in solr search query? solr return facet field queries along search results? if yes, how? if no, correct way proceed further. pass unique facet field name on want make facet filtering, , records have facet field.

c++ - pointers to object with external linkage to Nontype template parameters -

i tried following code. template <int val> void printval() { for(int i=0;i<val; i++){ cout << " value "<<i<<endl; } } instantiation: printval<100>() when use ( std::string s ) non type template parameter, compiler shouted @ me following error "class std::basic_str<char>' not valid type template non-type parameter. what know should use constant integral values only. not double. question: 1) why should not use std::string, bothers ? 2) meaning of 'pointers objects external linkage can used'. can sample code it? according 14.1/4, a non-type template-parameter shall have 1 of following (optionally cv-qualified) types: integral or enumeration type, pointer object or pointer function, lvalue reference object or lvalue reference function, pointer member, std::nullptr_t . your std::string none of those.

How do I get my highcharts to reduce in size when the window is resized down -

i'm having trouble getting highchart reduce in size when window resized down. i have created example of code in jsfiddle http://jsfiddle.net/britboy/uvfaq/ <table border='1' width='100%'><tr><td width='100%'> <div id="container" width='100%'></div> </td></tr></table> its simple highchart chart displayed in table - if make window bigger chart expands, if make window smaller chart doesn't want reduce instead table gets scroll bars. i've tried setting resize event , adjusting chart size chart.setsize( ) problem div containing chart never reduces further in size, setsize() not triggered. since chart resizes automatically when chart container gets bigger have though same should work when chart gets smaller. think problem chart's size preventing container shrinking. how code chart in table reduce in size when table reduced? thanks there n number of ways accompli

Android - imageview.setBackgroundResource issues -

i have image view have set 400dp(width) , 300dp(height). image view used in list view loading images url. during loading of images, show progess bar animation set this: imageview.setbackgroundresource(r.drawable.progress); final animationdrawable startanimation = (animationdrawable) imageview .getbackground(); startanimation.start(); once image finished loading , ll remove animation , set loaded image shown below: imageview.setbackgroundresource(0); imageview.setimagebitmap(bitmap); but probelm is, animation taking specified width , height, ie 400dp , 300dp respectively, how can reduce size of animation drawable alone ? my animation file: progress.xml <?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/anim_black" android:oneshot="false" > <item androi

taxonomy - SQL overload - weird query -

my hoster claims following sql query overloading server , causing perform , threatens disable account. can't seem find bottleneck - can me detect comes from? executed 1 min ago 8 sec on database --> mydb_name. select * tsk_posts left join tsk_term_relationships on (tsk_posts.id = tsk_term_relationships.object_id) left join tsk_term_taxonomy on (tsk_term_relationships.term_taxonomy_id = tsk_term_taxonomy.term_taxonomy_id) tsk_posts.post_status = 'publish' , tsk_posts.post_type = 'post' , tsk_term_taxonomy.taxonomy = 'category' , ( tsk_term_taxonomy.term_id = 4 or tsk_term_taxonomy.term_id = 103 or tsk_term_taxonomy.term_id = 19 or tsk_term_taxonomy.term_id = 20 or tsk_term_taxonomy.term_id = 5 or tsk_term_taxonomy.term_id = 2 or tsk_term_taxonomy.term_id = 14 ) order rand() limit 1 thank much. "order rand"

draw - Drawing lines at angle vb.net -

i can find plenty of examples of how draw line in vb.net online. i cannot find examples of how draw lines @ specific angle. could tell me how this? you'll need bit of math using sin/cos. x1,y1 = starting position of line angleinradian = angle on line converted radian x2 = linelength * math.cos(angleinradian) + x1 y2 = linelength * math.sin(angleinradian) + y1 then can draw line (x1, y1) (x2, y2)

javascript - sencha touch hide and show a component on tab of a button -

Image
i have created app views , there list button on top left corner display , hide list on tap event. how able hide on tab don't know how display again. default should hidden on tap of button should hide , show self depending on current property. iconcls: 'list', iconmask: true, ui: 'plain', handler: function() { ext.getcmp('ext-listnavigation-1').hide(); } and list view code ext.define('ov_app.store.navigationitems', { extend: 'ext.data.store', config:{ model: 'ov_app.model.items', data:[ { items:"services"}, { items:"solutions"}, { items:"about us"}, { items:"why singapore"}, { items:"contact us"} ] } }); the user inter phase looks as can see hide , show (services,solution, etc.. ) on tap of list button above list. var list = ext.getcmp('ext-listnavigation-1'); if (list.ishidden(

java - How to use JSR 303 @Valid annotation to validate primitive types? -

jsr 303 @valid annotation can used validate input objects controller method, demonstrated on mkyong.com is possible use @valid annotation validate primitive types int , long[]? if so, how? here example spring mvc method signature needs validated parameters above 0: @requestmapping(value = { "/delete" }, method = requestmethod.post) modelandview deletebulk(@requestparam("userid") int userid, @requestparam("ids") long[] ids) { no, can't done. it's bean validation, described here .

php - PEAR SMTP Behaviour in Windows -

i have strange problem. i using pear smtp on ubuntu. when send message: --==alternative_boundary_x{da5ccf044317613d9f8e371455f292a6}x content-type: text/plain; charset="utf-8" content-transfer-encoding: 7bit hello world - plain text test --==alternative_boundary_x{da5ccf044317613d9f8e371455f292a6}x content-type: text/html; charset="utf-8" content-transfer-encoding: 7bit <i>hello world - html test</i> --==alternative_boundary_x{da5ccf044317613d9f8e371455f292a6}x-- --==mixed_boundary_x{e46253d4aad6aff75d74ef5eb064a626}x content-type: application/rtf; name="attachment.rtf" content-disposition: attachment; filename="attachment.rtf" content-transfer-encoding: base64 e1xydgyxxgfuc2lczgvmzjb7xgzvbnr0ymx7xgywxgztb2rlcm5cznbyctfczmnoyxjzzxqwienv dxjpzxigtmv3o317xgyxxgzuawxczmnoyxjzzxqwienvdxjpzxigtmv3o319dqp7xgnvbg9ydgjs idtccmvkmfxncmvlbjbcymx1zta7fq0ke1wqxgdlbmvyyxrvcibnc2z0zwrpdca1ljqxlje1lje1 mtu7fvx2awv3a2luzdrcdwmxxhbhcmrcy2y

CSS responsive max-height not working in safari/laptop? -

i have css: @media screen , (max-height: 500px) { body{ display: none; } } this hides page when gets 500px (just test it), works fine in browsers on windows pc, when try on macbook pro in safari doesn't seem detect it, how can work properly? cant find on on google i tested it , it's working fine on safari(mac) well. div{ background: #ddd; width: 300px; height: 300px; } @media screen , (max-height: 500px) { div{ display: none; } } here's screenshot . though there's bug safari(ipad/iphone). might love read this .

Adding textbox values to an SQL database in c# -

i'm trying add values textbox datagridview, have asked question before i'm getting different error saying there more columns in insert statement values specified in values clause. number of values in values clause must match number of columns specified in insert statement. this code causing error private void savebtn_click(object sender, eventargs e) { sqlconnection sc = new sqlconnection(); sqlcommand com = new sqlcommand(); sc.connectionstring = ("data source=localhost;initial catalog=loginscreen;integrated security=true"); sc.open(); com.connection = sc; com.commandtext = ("insert stock (prod_id, prod_name, prod_cat, supplier, cost, price_1, price_2, price_3) values ('"+prodid.text+"''"+prodname.text+"'+'"+prodcat.text+"'+'"+prodsup.text+"'+'"+prodcost.text+"'+'"+prodprice1.text+"'+'"+prodprice2.text+"

rotation - Rotating body around a point Box2D Cocos2d -

i have problem when rotating triangular image radar detecting enemies. b2body *body; ccsprite *actor; if (b->gettype() == b2_kinematicbody && myactor == [loader spritewithuniquename:@"radar."]){ radar = b; radarsprite = myactor; } it kinematic body made levelhelper, , want rotate it. need rotate around static point, , repeat movement backwards. since body , not sprite, don't know how make rotate around top point . i have idea, i'm not sure. if rotate ccsprite , move body sprite.position? possible? thank much here's how update position , rotation of box2d bodies acording theirs sprites: // box2d updates. // set position of b2bodies according sprites. _world->step(delta, 10, 10); for(b2body *b = _world->getbodylist(); b; b=b->getnext()) { if (b->getuserdata() != null) { gameobject *sprite = (gameobject *)b->getuserdata(); b2vec2 b2position = b2vec2(sprite.position.x/ptm

node.js - Assign variable value to a block in jade -

is possible assign value of variable block? either not possible or i'm doing wrong. example: - var $foo = "bar" block #{$foo} div.a_class content this not possible because blocks compile-time, not runtime.

single page application - Durandal Caching Issue / Versioning Strategy -

what's strategy versioning durandal js , html files? i noticed that, during development, browser cache must disabled in order receive date files on each refresh. must during development. however, concern when go production continuous deployment strategy (deploying multiple times per day), users' browsers caching older versions of app might lead unpredictable behaviour. the approach springs mind version js , html urls somehow there version number embedded every request. unsure how make work internally within durandal framework. ok, here direction heading in. there built requirejs handle this. at top of main.js, in call requirejs.config can set urlargs property appended every call requirejs makes module. requirejs.config({ paths: { 'text': 'durandal/amd/text' }, urlargs: 'v=1.0.0.0' }); when want force production users new version of requirejs modules can increment version number invalidate browsers cache. (in

sql server - Copy Stored Proc Execution Plan to Another Database -

setup: using sql server 2008 r2. we've got stored procedure has been intermittently running long. i'd test theory parameter sniffing causing query engine choose bad plan. question: how can copy query's execution plans 1 database (test) database? note: i'm aware may not parameter sniffing issues. however, i'd go through motions of creating test plan , using it, if @ possible. therefore please not ask me post code and/or table schema, since irrelevant @ time. plans not portable, bind object ids. can use planguides , strictly tied database. have test on restored backup of same database. on restored backup can use planguide. relevance physical characteristics of machines should similar (cpus, ram, disks). normally though 1 not need resort such shenanigans copy plans. looking @ actual execution plans answers right there .

asp.net - WIF SAML 2.0 CTP Identity Provider Initiated SSO -

i developing single sign on asp.net application, , trying decide whether make use of wif saml 2.0 ctp or instead use adfs 2.0. have read several places wif saml 2.0 ctp enables identity provider initiated sso, can't find examples or tutorials anywhere. know resource becoming familiar methods of doing using wif ctp? so want sso asp.net application saml idp? it sounds you've figured out can either go direct saml idp adding saml stack application or going ws-fed adfs , saml idp. as mentioned saml ctp has been in ctp ages , there little documentation. have @ opensso fedlet . however, find adfs option both quicker , easier.

ios - Handling multiple gestures simultaneously -

i have 2 subviews view1 , view2. have added longpress , pan gesture parentview. when longpress on view1, present draggableview popup animation below fingure , continue dragging dragview view2. in process pangesture selector not called longpress gesture selector called. after remove fingure dragview , start dragging again pangesture selector called. what need is, once dragview created, disable(not permanently until pan gesture state ended called) longpress gesture , pan gesture selector should called you have delegate method called: - (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldrecognizesimultaneouslywithgesturerecognizer:(uigesturerecognizer *)othergesturerecognizer take @ it, need return yes.

asp.net mvc 3 - Determining if a date field presents a calendar popup via JavaScript -

for mvc app working on, have date fields on page. my initial reaction use jquery ui's datepicker, hit small snag - we're expecting application run on ipads. so, asked using html5 <input type="date" /> tag, fall datepicker if browser dosen't support it. one additional small problem: ie evil. apparently, ie does 'support' <input type="date" /> ; dosen't show calendar when clicked. a abbreviated, sanitized markup: @* in html body... *@ @html.inputfor(m => m.somedate, new { id="a", type="date" }) @html.inputfor(m => m.someotherdate, new { id="b", type="date" }) <script> var $a = $('#a'), $b = $('#b'); $(document).ready(function () { fallbacktodatepicker($a); fallbacktodatepicker($b); @* ...snip: other operations here... *@ }); function fallbacktodatepicker($field) { if($field.type() != "date") { console.log($field.selecto

JavaScript - how to add support for document.all for other browsers? -

i have got bunch of old javascript code, document.all used. now, need find way replace document.all document.getelementbyid . there encapsulate document.all , call second function instead? or need edit files? if (!document.all) { document.constructor.prototype.__definegetter__('all', function() { return document.getelementsbytagname('*'); }); }

python - Using .pyd library in Jython -

actually i'm start project, in company using java main technology in owr web app server (ibm webspher), need integrate existing technology new product purchased , developed in c/cpython , ofer sdk in c , implementation in cpython (.pyd file), want know if kind of libraries supported in jython actyally i'm working jython 2.7b1? or there way use these kind of libraries? thanks , regards, serch from jython faq ... jython programs cannot use cpython extension modules written in c. these modules have files extension .pyc, .pyd or .dll. if want use such module, should equivalent written in pure python or java. the workaround use jni embed cpython in java, although defeat purpose of using jython.

Change CSS property on each page using jQuery -

i'm trying make navigation menu website. hover event (jquery) changes <div> background position user can see pointing. final effect want achieve looks this: http://jsfiddle.net/wacku/ the problem solution when click on <li> (page changes) loose variable (background position resets) wonder if there workaround, maybe adding css class element click on (similar wordpress themes)? i'd avoid persisting value cookies. check current page in window.location.href, , set background image depending on it var currentpage = window.location.href.split("/").pop(); switch(currentpage){ case "page1.php": $(".topmenu").css('background-position', position1);break; case "page2.php": $(".topmenu").css('background-position', position2);break; ... }

c++ - Boost vs. .Net random number generators -

i developed same algorithm (baum-welch estimating parameters of hidden markov model) both in f# (.net) , c++. in both cases developed same test generates random test data known distribution , uses algorithm estimate parameters, , makes sure converges known right answer. the problem test works fine in f# case, fails converge in c++ implementation. compared both algorithms on real-world data , give same results, guess generation of test data broken in c++ case. hence question: random number generator comes .net 4 (i think default version vs2010)? in f# using: let random = new random() let randomnormal () = //for standard normal random variable let u1 = random.nextdouble() let u2 = random.nextdouble() let r = sqrt (-2. * (log u1)) let theta = 2. * system.math.pi * u2 r * (sin theta) //random.nextdouble() uniform random variable on [0-1] in c++ use standard boost classes: class hmmgenerator { public: hmmgenerator() : rng(37), //the seed change

model view controller - How to notify parent class from child? -

i'm trying resolves 1 architectural issue, want find best suitable approach. i have game scene gamelayer.h view in case. have gameengine class i'm trying controller. have custom egg class derived ccnode , timer logic implemented via schedule in egg class. have many egg object on game scene added via addchild method. gameengine.m imports gamelayer.h, , gamelayer.m imports egg.h after timer in each egg runs out, want notified, i.e run actions, increase score etc. question best way implement such situation. want obey mvc rule quick solutions comes in mind are include gamelayer.h in egg class , call update method in it. update view (self) , notify gameengine save new score. include gamelayer.h in egg class , call update method in it. in update method call update method in gameengine.h , gameengine save score, , update gamelayer (the view) implement kvo. problem never done before, don't know observer should gamelayer or gameengine please help, examples appreciate

Can gradle extensions handle lazy evaluation of a property? -

i'm writing custom gradle plugin handle vaguely complicated work , have run frustrating problem while using properties configure of tasks plugin applies. apply plugin: myplugin //provide properties applied plugin mypluginprops { message = "hello" } //define task uses custom task directly task thistaskworksfine(type: mytask) { input = mypluginprops.message } //define plugin apply task of custom type class myplugin implements plugin<project> { void apply(project project) { project.extensions.create('mypluginprops', mypluginextension) project.task(type: mytask, 'thistaskworksincorrectly') { input = project.mypluginprops.message } } } //the extension used custom plugin input class mypluginextension { def string message } //the task used both standard build section , plugin class mytask extends defaulttask { def string input @taskaction def action() { println "yo

jQuery AJAX .post pulling multiple variables from one php -

i trying find best way pull multiple variables php ajax post. right now, using .substr split echoed variable php itself. here's ajax post (with jquery) $.post("scripts/enter/register.php", {username : username, email : email, password : password}, function(data) { var callback = data.substr(0,1); var user_session = data.substr(1); if(callback === "1"){ //do registration script } else { //give error } }); and php if (strlen($hash) >= 20) { if($user_name){ //perform sql queries echo "1"; echo $cookie; } else { echo "0"; } } else { echo "0"; } as see, in php, echo 2 variables when goes well. when there's error, echo 1 variable. script works fine, find clunky , apparently unsecure. on side note, have come understand echo not secure, though no 1 has told me instead. i have script handles login (this last script register), use

ios - Subclassing UIToolbar and overriding drawRect: - UIBarButtonItems NOT displaying -

context i'm using 'initwithnavigationbarclass' method initialize uinavigationcontroller custom toolbar, here line alloc init uinavigationcontroller navigationcontroller = [[uinavigationcontroller alloc] initwithnavigationbarclass:nil toolbarclass:[questiontoolbar class]]; is class, "questiontoolbar", subclass uitoolbar , override drawrect, here drawrect method: - (void)drawrect:(cgrect)rect { [super drawrect:rect]; uiimage *backgroundimage = [uiimage imagenamed:@"44px_background_red.png"]; [backgroundimage drawinrect:cgrectmake(0, 0, self.frame.size.width, self.frame.size.height)]; } here pertinent code in viewcontroller attempt add uibarbuttonitems uibarbuttonitem *spacer = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil]; uibarbuttonitem *beginitem = [[uibarbuttonitem alloc] initwithtitle:@"begin quiz" style:uibarbuttonitemstyleplain t

java - action bar sherlock in preference menu -

i have preference menu , want consistent app, there must action bar in top in rest of activities. i tried this public class preferencemenu extends preferenceactivity implements onsharedpreferencechangelistener { ....... class menuinflater extends baseactivity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); actionbar = getsupportactionbar(); inflater = getsupportmenuinflater(); } } public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); dbhelper = new databasehelper(getapplicationcontext()); context ctx = getapplicationcontext(); trainapplication ta = (trainapplication) getapplication(); actionbar.setdisplayhomeasupenabled(true); actionbar.sethomebuttonenabled(true); menuinflater menu = new menuinflater(); ..... but ofcourse doesn't work. any ideas? you need extend sherlockpreferenceactivity .

r - using the arrows function to add confidence limits stored in a dataframe to a barplot -

Image
i'm sure simple problem of :) have looked around r pages , on here , know function need (arrows think) don't understand how use it. question is: i have dataframe (data) results of experiment have simplified this: treatment y lower_limit_ci upper_limit_ci 1 0.13284413 0.1224 0.1438 2 0.263072558 0.2458 0.2809 3 0.234218546 0.217 0.2521 4 0.394980185 0.3702 0.4201 5 0.474533107 0.4457 0.5035 6 0.583333333 0.5526 0.6136 i have drawn barplot of data so: plot <- barplot(data$y) and know need function arrows (yes?) add confidence limits stored in dataframe plot. can please show me how use arrows correct info. dataframe? have tried on advice of someone: arrows(plot, data$y - data$lower_limit_ci, plot, data$y + data$upper_limit_ci, code=3, angle=90, length =0.1) which gives giant bars incorrect. can help? thanks! i suggest instead of barplot , arrows functions, use more flexible , powerful ggplot2 package. here's h

how to read an Access database when it's open by another person -

i'm working on website application reads data access db. works fine until opens database work on (e.g., write new record...). when happens, connection interrupted , message "database in use" appears. i understand access has security file extension .ldb created automatically when .mdb open, i'm looking way able open database multiple users. way, can check data application and, @ same time, record new data. is there way that? the website application not maintain continuous connection database, symptoms describe caused 1 of following: when "someone opens database work on it" open in exclusive mode, prevents other users/processes opening @ same time. when "someone opens database work on it" not have "create file" permission on folder in .mdb file resides. prevents them creating .ldb lock file , can cause other users forced read-only mode or prevent them accessing database entirely. (for more details on file/folder pe

regex - ANTLR3 String Literals and Disallowing Nested Comments -

i've been tasked writing antlr3 grammar fictional language. else seems fine, i've couple of minor issues with: 1) comments between '/*' , '*/' , , may not nested. know how implement comments ( '/*' .* '*/' ), how go disallowing nesting? 2) string literals defined sequence of characters (except double quotes , new lines) in between pair of double quotes. can used in output statement. attempted define thus: output : output (stringlit | ident) ; stringlit : '"' ~('\r' | '\n' | '"')* '"' ; for reason, however, parser accepts output "hello, world!" and tokenises "hello, \nworld . exclamation mark or closing " went have no idea. whitespace maybe? whitespace : ( '\t' | ' ' | '\n' | '\r' | '\f' )+ { $channel = hidden; } ; any advice appreciated - time! :) the form wrote disallows nested comments. token stop @