Posts

Showing posts from March, 2011

Php - Delimiter must not be alphanumeric or backslash -

this question has answer here: delimiter must not alphanumeric or backslash , preg_match 5 answers this question has been asked don't know how fix problem in situation. getting following php errror: php message: php warning: preg_match(): delimiter must not alphanumeric or backslash in... on line 227 line 227 following: if (preg_match($match, $_server['http_user_agent'])) and function: $oslist = array ( 'windows 3.11' => 'win16', 'windows 95' => '(windows 95)|(win95)|(windows_95)', 'windows 98' => '(windows 98)|(win98)', 'windows 2000' => '(windows nt 5.0)|(windows 2000)', 'windows xp' => '(windows nt 5.1)|(windows xp)', 'windows server 2003' => '(windows nt 5.2)', 'windows vista' => '(windows nt 6.0)', 'w

autotools - How can I use gettext before install? -

to use gettext, need call bindtextdomain(), providing patch installed .mo files. instance: bindtextdomain("myappname", "/opt/gnome/share/locale"); of course, use defines there, set autotools build files. however, i'd use gettext before running "make install", because want use translations in "make check" tests. the path bindtextdomain() contain .mo files in structure this: de/lc_messages/myappname.mo fr/lc_messages/myappname.mo is there easy way create structure of generated files in local build, can pass local path bindtextdomain() during "make check"?

algorithm - Generate unique 12 letter alphanumeric string from two primary keys of table in php -

i have 2 tables: category(cat_id type int,cat_name) , books(book_id type int,cat_id) . when assign book user book code . want form book code containing 12 alphanumeric characters , must originated cat_id , book_id . should able decode code cat_id , book_id . idea?. ok here go... this can handle max signed integer types. , produces no more 12 characters. $firstid = "2147483646"; $secondid = "2147483646"; $firstbinary = str_pad(base_convert($firstid, 10, 2), 31, "0", str_pad_left); $secondbinary = str_pad(base_convert($secondid, 10, 2), 31, "0", str_pad_left); $finalbase36 = str_pad(base_convert($firstbinary.$secondbinary, 2, 36), 12, "0", str_pad_left); var_dump($finalbase36); update: sorry made mistake.. should trik updated code.

jquery - using a css3 animation to load a website -

i came across website other day , wondering how create same page load effect. jquery? or css3 animations using sprites? http://www.adhamdannaway.com/ after inspecting site found loading logo made of sprite image (black logo next grey logo). effect creates logo being "filled up" page loads (linear effect going up) have feeling overlaying black logo grey 1 , fading grey logo out in linear direction either using jquery , css3, or both. thanks in advance then need use ajax call content, , while content getting loaded, can show animation. when content loaded can make ajax animation in screen. the animations page site, might done jquery well. i did similar ajax myself. try out.

facebook - PHP $POST If statement -

okay, issue having have simple textarea should sent entered page, should 'thanks' when submitted, , should prompt entry if nothing entered, however, when enter nothing still says 'thanks' im sure simple enough. here code index.php <form method="post" action="translate.php"> <name="status" cols="50" rows="5"> what's on mind? </textarea><br> <input type="submit" value="translate status" /> and translate.php <?php $status = $_post['status']; if($status == ""){ echo "please enter status."; } else { echo "thanks"; } ?> i have tried using above code in index.php got error 'status' variable. while asking, how go having popup error on main page rather redirecting translate.php 1.you forgot write textarea . <textarea name="status" cols="50" rows="5"> what's

java - What is the purpose of the {} outside of any methods? -

this question has answer here: why java code in curly braces ({}) outside of method? 3 answers java empty block scope 3 answers i accidently made pair of {} outside of method , worked. public static void main(string[] args) { system.out.println("ddd"); } { system.out.println("ttt"); } of course if run code result "ddd" , writes "ttt" if create new instance of it. and if make static {system.out.println("ttt");} works designed , result "ttt" "ddd" is there practical use of this? why use contructor or without written constructor? my impressions are: seems working, smells bad , strange practice. right? is there practical use of this? there 1 "idiom" makes use of insta

ASP.NET UpdateProgress not disappearing after redirect to another page -

i have page updatapanel , updateprogress on it. in page redirect download page responsible downloading generated file. redirecting download page occurs in updatepanel via 1 of controls click event. problem after downloading file updateprogress not disappear. (i set contenttype of download page proper mime type) i found way download file in 1 of events in update panel. used frame this. onclick event add inline iframe page address of file. var script = @" var iframe = document.createelement(""iframe""); iframe.src = '{0}'; iframe.style.display = ""none""; document.body.appendchild(iframe);"; scriptmanager.registerstartupscript(string.format(script, url)); this solved problem.

java - converting blob to an image stream and assign it to jLabel -

i trying convert blob string in database byte array , after converting convert buffered image , assign label here's code package ims.project; import java.sql.*; import javax.swing.*; import java.awt.*; import java.awt.image.bufferedimage; import java.io.bytearrayinputstream; import javax.imageio.imageio; public class readingdata extends jframe { readingdata() { jpanel pane = new jpanel(); jlabel label1 = new jlabel("help"); jlabel label2 = new jlabel("33"); pane.add(label1); pane.add(label2); setvisible(true); add(pane); try { class.forname("com.mysql.jdbc.driver"); connection con = drivermanager.getconnection("jdbc:mysql://localhost:3306/ims1", "root", "root"); statement st = con.createstatement(); string ss = "select pic supplier supplier_id= '" + label2.gettext() + "'&qu

ios - Start playing an audio file when application goes in background -

it's "google maps" navigate in background. i have added "app plays audio" "required background modes" already, doesn't work. what's wrong it? here sample source code: -(void)applicationdidenterbackground:(uiapplication *)application { uidevice* device = [uidevice currentdevice]; bool backgroundsupported = no; if ([device respondstoselector:@selector(ismultitaskingsupported)]) { backgroundsupported = device.multitaskingsupported; } if (backgroundsupported && _bgtask==uibackgroundtaskinvalid ) { uiapplication* app = [uiapplication sharedapplication]; dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ while (app.applicationstate==uiapplicationstatebackground && _bgtask!=uibackgroundtaskinvalid) { [nsthread sleepfortimeinterval:3]; [self playaudio]; } [app endbackgroundtask:_bgtask]; _bgtask = uibackgroundtaski

jquery ui - Dynamically change the handle option in the stop event -

all,i knew how use handle in jquery ui draggable , sortable. , knew can modify dragged item html content , css style in stop event. don't know if there possibility dynamically add handle selector drag item in stop event? please review below code . thanks. $( ".selector" ).draggable({ connecttosortable : '.sortablediv', stop: function( event, ui ) { //do nothing } }); $(".sortablediv").sortable({ stop:function(event,ui){ $(ui.item).prependto( $('<div>drag handler</div>').addclass('draghandler'));//append elements //next want make div.draghandler drag handle . } }); i found way make it. add handle option no matter whether selector can retrieve elements it. if doesn't find element there no handle drag . otherwise works. please review code. thanks. $(".sortablediv").sortable({ stop:function(event,ui){ $(ui.item).prependto( $('<div>drag

sql - How to scope with "where", "having" and "or" -

i understand possible do scope :public_visible, where("(status = ?) or (end_date > ?)", :published, date.today) but want combining following 2 scopes or scope :succeeded, having("sum(orders.sum) >= goal") scope :ongoing, where("end_date >= ?", date.today) is possible? either in sql or activerecord ways. thanks everyone. not perfect solution ended doing scope :succeeded_or_ongoing, where("id in (?) or id in (?)", project.succeeded.map(&:id), project.ongoing.map(&:id))

javascript - Nicedit editor image upload -

i using "niceedit" editor in website anyhow working charm massage when trying "upload" image editor. "there error uploading image (sending image imageshack failed." i , found has change niceuplod file , must api key . so change way in calling editor following : bklib.ondomloaded(function() { niceditors.alltextareas(new niceditor({maxheight : 250}).panelinstance('contect')); }); $('form').submit(function(){ niceditors.findeditor('contect').savecontent(); //console.log(niceditors.findeditor('contect').getcontent()); }); 1 bklib.ondomloaded(function() { new niceditor({ buttonlist : ['bold','italic','underline','upload'], iconspath:'niceditoricons.gif', uploaduri : 'nicupload.php', }).panelinstance('contect'); }); got following error top.nicuploadbutton undefined , in console followin

cruisecontrol.net - CCNet AsseblyInfo update is not working. is there an issue with my config? -

below config using though force build doing check-in, version number of assemblies not updated. probably missing thing. note: new build servers , first. have lot of assemblyinfo.cs files, under different projects. do need use msbuildtaks around this? if can example. <cruisecontrol xmlns:cb="urn:ccnet.config.builder" xmlns="http://thoughtworks.org/ccnet/1/8"> <!-- preprocessor settings --> <cb:define artifactsdir="\artifacts" /> <cb:define productnamecompanysvnpath = "d:\companysvn\trunk\source\"/> <cb:define tortoisesvnexe = "c:\program files\tortoisesvn\bin\svn.exe"/> <cb:define svnpathtobuild = "http://dummy.mummy.com/svn/company/branches/branch-meau/" /> <cb:define nantexecutablepath = "c:\program files\nant\bin\nant.exe"/> <cb:define branchnameci="_br_meau_ci"/> <cb:define buildmode = "release"/> <cb:define platformc

java - ThreadPoolExecutor backed by PriorityBlockingQueue doesn't seem to work -

i have large number of pictures fetch server, , want fetch pictures higher priority others i've implemented own threadpoolexecutor returns futuretask implements comparable doesn't seem work. tasks more or less processed in order add them queue. i've debugged blockingqueue of threadpoolexecutor , found out when add runnable higher priority, not shifted way @ top of queue. here code public class prioritythreadpoolexecutor extends threadpoolexecutor { public prioritythreadpoolexecutor(int corepoolsize, int maximumpoolsize, long keepalivetime, timeunit unit, blockingqueue<runnable> workqueue) { super(corepoolsize, maximumpoolsize, keepalivetime, unit, workqueue); } protected <t> runnablefuture<t> newtaskforvalue(runnable runnable, t value) { return new comparablefuturetask<t>(runnable, value); } protected class comparablefuturetask<t> extends futuretask<t> implements comparab

.net - Can I make an exception in Task.Run crash the program? -

Image
i'm not big fan of quietly swallowed exceptions, following code that: task.run(() => { var obj = dosomethingcpuintensive(); // returns null, due bug obj.domorestuff(); console.writeline("after"); // never here; program continues running }); i've read throwunobservedtaskexceptions configuration value, doesn't help, since never task returned (edit: help, in release builds). is there way make unhandled exception crash program? using task.run in way i'm not supposed to? it appears using task.run is, indeed, mistake. think i'm supposed await it, else silly things above happen. when crash await , debugger rather unhelpful, looking this:                 i take mean i'm doing wrong thing task.run here. a simple fix use old threadpool.queueuserworkitem instead:                   that's better! didn't need async/await in code anyway; used task.run because it's less typing.

bash - return to position in array after exit -

apparently wasn't clear when last asked this, i'll try again. i have array full of values, lets call them primenumbers.txt i have bash script lets call primechecker the script take each , every value , in array , 1 @ time , run through. want able stop primechecker @ point in processing array; lets call x , restart script in way start position in array x+1. if there further clarification need please let me know. could store current index in file in /tmp , check file on startup: for in nums; echo $i > /tmp/marker ... done

azure - Cloud service for windows phone 7 apps -

in feb 2013 windows azure toolkit windows phone 7 apps has been suspended per link are there cloud services can use instead of azure on windows phone 7 apps ? it not suspended, superseded. means can use windows azure mobile services since designed work application windows phone 8 , windows store. as "big house" azure, can use ams through sdk: windows phone 8/windows store windows phone 7.5 (pre-release) or access through standard rest layer .

Licensing: Android, LGPL and the ZBar QR Code scanner -

i have integrated zbar code scanner in android-app in minutes (great library!), nevertheless thinking of replacing qr code reader now. reason is, there scepticism[1][2] on web whether lgpl compatible commercial android projects. can tell me why zbar uses lgpl nevertheless supporting android? (the have android section in support forum...) is there way make sure app meets license requirements? [1] http://source.android.com/source/licenses.html [2] http://www.gnu.org/licenses/lgpl-java.html android platform project has different licensing requirements 3rd party app developers. while possible replace , reverse engineer lgpl libraries in 3rd party apps, not lgpl libraries in read-only firmware. key parts of android zbar distributed in binary .so files. such, replaceable in distributed app in terms compliant lgpl. for java adapter code (zbar.jar), make sure you're not using proguard or other obfuscation on it. for reference, here's how droidtext project add

Execution python-paramiko -

i trying execute command remote machine through python ssh = paramiko.sshclient() ssh.set_missing_host_key_policy(paramiko.autoaddpolicy()) ssh.connect(server_ip, username='root', password='xxxxx') stdin, stdout, stderr = ssh.exec_command( "tar -c /home -xzf /home/tests.tar.gz;dos2unix /home/tests/run.py;chmod +x /home/tests/run.py;/home/tests/run.py>/home/tests/log.txt" ) it seems last command /home/tests/run.py>/home/tests/log.txt not working log.txt not having values, same works if /home/tests/run.py>/home/tests/log.txt on remote machine terminal. how resolve ? thanks in advance you not transporting client session : ssh = paramiko.sshclient() ssh.set_missing_host_key_policy(paramiko.autoaddpolicy()) ssh.connect(server_ip, username='root', password='xxxxx') #note next line missing ssh_session = ssh.get_transport().open_session() then (after declaration of ssh_session) may use ss

php - IIS7 rewrite regular expression does not identifying + sign -

i using php iis7. in web.config file have made rewrite rule. pattern matching ^product/([0-9a-za-z\+\-]+)$ now problem not work when there + sign in url example not work for http://mywebsite/product/abc+def+ghi i need work above. but work http://mywebsite/product/abc def ghi so guess identifying space not + any appreciated. thanks i found answer. sharing in case needs. just put <system.webserver> <security> <requestfiltering allowdoubleescaping="true"/> </security> in web.config file. and done

c# - Regex.Split create new line -

basically trying create new line in list box when data imported or added. example address need new line 2 example road example at moment showing item in 1 line rather 3 lines. private void txtphrase_selectedindexchanged(object sender, eventargs e) { foreach (string s in regex.split("", "\r\n")) txtphrase.items.add(s); } unsure on put string input? there different inputs. the listbox not support functionality split single list item on multiple lines. may want consider using seperate items or different control on form.

java - Strange behavior with Timezone -

i run following java code : timezone tz1 = timezone.gettimezone("etc/gmt-3"); system.out.println(tz1.getdisplayname()); the display gmt+03:00 ! it seems when use timezones ids such etc/gmtxx , sign reversed. why ? that etc style : http://en.wikipedia.org/wiki/zoneinfo the special area of "etc" used administrative zones, particularly "etc/utc" represents coordinated universal time. in order conform posix style, zone names beginning "etc/gmt" have sign reversed people expect. in style, zones west of gmt have positive sign , east have negative sign in name ( e.g "etc/gmt-14" 14 hours ahead/east of gmt. )

python script executed from php gives error -

on debian run xampp. want execute python script using php shell_exec. php code: shell_exec("/opt/lampp/htdocs/news/hello.py 2>1 &"); when run browser error: /usr/bin/python: /opt/lampp/lib/libz.so.1: no version information available (required /usr/bin/python) if run terminal window using this: php /opt/lampp/htdocs/page/index.php works without problems. ideas how can make work browser? thanks i'm guessing xampp comes it's own libraries instead of using system libraries, , means it's setting ld_library_path it's local library directory. this cause other programs started php use libraries, may not compatible with. to veryfy that, try system("env"); , sould show exported environment variables. if ld_library_path set, use: shell_exec("ld_library_path= /opt/lampp/htdocs/news/hello.py 2>1 &"); that unsets before running python script.

Load jQuery by javascript and run a function from another file -

i need load 3 jquery scripts in page. business reasons i've make minimum modifications possible i've decided create 1 javascript included in website. after that, script must load jquery , 3 more jquery scripts besides 3 css files. basically, until now, that's i've got: var jquery = document.createelement('script'); jquery.type = "text/javascript"; jquery.src = "common/com/jquery/jquery-1.9.1.js"; document.getelementsbytagname('head')[0].appendchild(jquery,document.getelementsbytagname('head')[0].firstchild); var prettyphoto = document.createelement('script'); prettyphoto.type = "text/javascript"; prettyphoto.src = "common/com/prettyphoto/jquery.prettyphoto.js"; document.getelementsbytagname('head')[0].appendchild(prettyphoto,document.getelementsbytagname('head')[0].firstchild); var jqueryui = document.createelement('script'); jqueryui.type = "text/javascript&

Python Boolean method naming readability -

which of these ways more readable boolean method in python? document.is_editable document.editable document.has_editable document.can_be_editable document.can_edit i choose first 1 (from point of view of java developer).

ios - Reachability.m - File not found - Odd behavior -

Image
i have 2 files of relevance: collectionviewcontroller.m , imagedetailviewcontroller.m for collectionviewcontroller.m, "#import "reachability.m" + functionality works fine. have added frameworks well. however, when trying import reachability.m file in imagedetailviewcontroller.m well, "reachability.m - file not found"-error. don't understand why happening. both files in same group, folder everything. has come across this? i'd appreciate solution, driving me crazy! you don't import reachability.m , required files imported having .h extensions called header files. problem importing .m files compiler might not able find .m file , complain. i recommend use forward declarations quite faster way of building code , indexing it, can add class in code collectionviewcontroller.h @class reachability; in collectionviewcontroller.h header file @property(strong,nonatomic)reachability *reachability; // here declaring property c

dependencies - Skipping dependency execution of a disabled task in Gradle? -

is somehow possible not execute dependencies of task when task skipped? in example below, i'd jar (and dependencies of jar ) not executed if server running when executing runservertests . server in case started process. apply plugin: 'java' task startserverifnotrunning(dependson: jar) { onlyif { isservernotrunning() } ... } task runservertests(dependson: startserverifnotrunning) { ... } i'd rather not add onlyif jar task, since other tasks should executed may depending on one. jar task has dependencies of own. to desired behavior, have exclude task task execution graph, rather skipping execution. can -x command line or programmatically gradle.startparameter.excludedtasknames << "..." or gradle.taskgraph.usefilter { task -> ... } .

Using a column entry as a "selector" for datasets in R -

my array looks this: slide index b c dosegroup 482 778 l 0 0 2 13gy_p_75_42wk 483 778 r 0 0 2 13gy_p_75_42wk 484 779 l 0 0 2 13gy_p_75_42wk 485 779 r 0 0 2 13gy_p_75_42wk 486 4700 l 2 2 2 14.25gy_c_50pl_42wk 487 4700 r 0 0 1 14.25gy_c_50pl_42wk 488 4701 l 0 0 1 14.25gy_c_50pl_42wk i use dosegroup column's entries able select respective entries in other columns. able tell r, e.g., "do wilcox.test between 13gy_p_75_42wk , 14.25gy_c_50pl_42wk datasets using column c ." how can r? there kind of way select columns having entry 14.25gy_c_50pl_42wk ? i modified data add third level in dosegroup make more realistic. txt &l

listbox - Wpf Close popup when ListboxItem is selected -

i have listbox inside popup. how close popup right after select item list box; here code: <popup x:name="colorpopup" allowstransparency="true" isopen="{binding elementname=colortoggle, path=ischecked}" placement="bottom" staysopen="false" placementtarget="{binding elementname=colortoggle}"> <border x:name="dropdownborder1" borderbrush="{dynamicresource {x:static systemcolors.windowframebrushkey}}" margin="0, 0,5,5" borderthickness="1" background="{dynamicresource {x:static systemcolors.windowbrushkey}}" effect="{dynamicresource windowshadoweffect}"> <listbox name="colorlist" verticalcontentalignment="stretch" margin="1, 3, 1, 3" isenabled="true" grid.column="0" background="transparent" horizontalcontentalignment="center" selecteditem="{binding fcolor}" se

javascript - Are these for loops different? -

here code example 1 for (var k = 0, l = value.length; k < l; k++, index++) { // ... } example 2 var l = value.length; (var k = 0; k < l; k++, index++) { // ... } in example 1, variable l defined inside of 'for' brackets, mean l being defined every time loop goes through? if example 2 more efficient right? they equal in speed. nothing different. but recommand use example 2 because better read.

ios - Copy NSArray to member variable -

i have setter in class: -(void)setnumbers:(nsarray *)anumbers{ nsarray *tarray = [[nsarray alloc]initwitharray:anumbers]; //throws bad access self.numbers = tarray; //also tried self.numbers = [tarray copy]; [tarray release]; } if invoke setter this: nsarray *numbers = [ticketmanager getrandomnumbersfor:@"lottonormal"]; [self.ticket setnumbers:numbers]; in 'getrandomnumbersfor:' method (the loop gets executed): +(nsarray *)getrandomnumbersfor:(nsstring *)atickettype{ nslog(@"getting randomnumbers for: %@",atickettype); nsmutablearray *tresult; if([atickettype isequaltostring:@"lottonormal"]){ tresult = [nsmutablearray arraywithcapacity:6]; for(int = 0;i<6;i++){ int tnumber = arc4random() % 48; tnumber++; nslog(@"number: %i",tnumber); [tresult addobject:[nsnumber numberwithint:tnumber]]; } } return tresult; } in viewcontroller i´m getting bad access in mar

What is wrong with this jquery each() select options? -

i have below function, function setdropdownvalue(dropdownid,selectedvalue){ $('#'+dropdownid+' option').each(function(){ if ($(this).val().tolowercase()==selectedvalue.tolowercase()){ //found option looking for, want $(this).val(selectedvalue); } }); } and passing dropdownid=$('#dp1") , selectedvalue='bat' , reason each() function not getting executed.. calling setdropdownvalue($("#dp1"),'bat'); am missing something?? dropdownid should string, why passing $('#dp1") jquery object? you should pass 'dp1' instead.

c++ - qt - Drag & Drop : Frame disappears -

i'm create drag , drop between 2 qgroubbox. each contains dragdropframes, subclass qframe, have problem when want release dragdropframe groupbox, disappear instantly dragdropframe: void mousepressevent(qmouseevent *ev) { if (ev->button() == qt::leftbutton) { offset = ev->pos(); if(!isreleasefromparentwidget) { releasefromparent(ev->pos()); } ismousedown = true; } }; void mousereleaseevent(qmouseevent *ev) { if (ev->button() == qt::leftbutton) { ismousedown = false; } } void mousemoveevent(qmouseevent *ev) { if (ismousedown) { this->move(maptoparent(ev->pos() - offset)); } } void releasefromparent(qpoint point) { oldparentwidget = parentwidget(); setparent(parentwidget()->parentwidget()); isreleasefromparentwidget = true; this->move(maptoparent(offset)); } when call releasefromparent in constructor dragdropframe , not somewhere

How to plot stacked point histograms in ggplot2 in R? -

Image
what's ggplot2 equivalent of "dotplot" histograms? stacked points instead of bars? similar solution in r: plot histogram points instead of bars is possible in ggplot2? ideally points shown stacks , faint line showing smoothed line "fit" these points (which make histogram shape.) as @joran pointed out, can use geom_dotplot require(ggplot2) ggplot(mtcars, aes(x = mpg)) + geom_dotplot()

How can you store a rsa key pair in a django model / sqlite db -

i using pycrypto within django (python 2.7, django 1.5m sqlite), create field store rsakey object. how can this? converting string , seems pretty error prone , since random bytes in there, not trust approach. able store random keys in charfield base-64 encoding (like this: random.new().read(16).encode('base64')). keypair? saw in current dev version of django, binary field incorporated, need stick 1.5. any appreciated. thanks gerd you need store private key, because can generate public key private one. >>> crypto.publickey import rsa >>> rsakey = rsa.generate(1024) the public key can exported with >>> rsakey.publickey().exportkey() to save private key might want convert text exportkey() method , store in django-textfield: >>> rsakey.exportkey() '-----begin rsa private key-----\nmi...-----end' converting text rsa key object easy too: >>> rsa.importkey('-----begin rsa private key--- ....')

c++ - Can't find the cause of an unhandled exception -

i writing parser .obj files, , unhandled exception being thrown somewhere within loop code block, , unable find it. visual studio error message saying it's @ ntdll.dll. code breaks in ostream file. when use breakpoints, program doesn't crash before quite few iterations. //intitialising index array part , returning start of vertex defining period //icount number of indices being read in //position saved position within .txt file has been reached data[k].indices = new triangle[icount]; data[k].noindices = icount; data[k].vertex = new point3d[icount]; int a,b,c,d,e,f; int check = 0; infile.seekg(position - 1); cout << "icount" << icount << endl; //getting index data for(int j = 0; j < icount; j++) { char buff[40]; infile.getline(buff, 40); int matched = sscanf(buff, "f %d/%d %d/%d %d/%d", &a, &b, &c, &d, &e, &f); //zero align indices , store data data[k].vertex[j].x = b - 1; data[

c# - Check if a remote port is UP(listening) on UDP? -

i've detect if remote host up, based on it's service(ip+port) running. can't use ping because need make works icmp port blocked. sometime service using tcp, udp(but when i've check, know if server has run on udp or tcp, it's depending of it's type). i've no issue checking tcp port(based on https://stackoverflow.com/a/7605428/397830 ). since udp not connection oriented protocol, how sure remote host listening on udp on port? thank you! excerpt nmap documentation: udp scan works sending udp packet every targeted port. common ports such 53 , 161, protocol-specific payload sent, ports packet empty. --data-length option can used send fixed-length random payload every port or (if specify value of 0) disable payloads. if icmp port unreachable error (type 3, code 3) returned, port closed. other icmp unreachable errors (type 3, codes 1, 2, 9, 10, or 13) mark port filtered. occasionally, service respond udp packet, proving open. if no response rece

javascript - proper way to fill js variables via ajax request -

at moment using follwing way fill global js variables data obtained json: var tranlationjson = $.ajax({ type: "get", url: "translation.xml", contenttype: "text/xml", datatype: "xml", success: function (datasource) { tranlationjson=tojasonparser(datasource); } }); is there more clever way? need variables filled because in scrips loaded later use content. you can make tranlationjson object instead of variable this: var tranlationjson = { init: function(){ $.ajax({ type: "get", url: "translation.xml", contenttype: "text/xml", datatype: "xml", success: function (datasource) { this.data = tojasonparser(datasource); } }); } then call init function this: tranlationjson.i

cloudbees - Authentication Issue with SendGrid -

i signed sendgrid via cloudbees. trying send email via sendgrid smtp api following attributes: port=587 host=smtp.sendgrid.net username=[username generated cloudbees, cloudbees_[myid] ] password=[the password login cloudbees grandcentral] and getting following exception. caused by: javax.mail.authenticationfailedexception: 535 authentication failed: bad username / password @ com.sun.mail.smtp.smtptransport$authenticator.authenticate(smtptransport.java:823) @ com.sun.mail.smtp.smtptransport.authenticate(smtptransport.java:756) @ com.sun.mail.smtp.smtptransport.protocolconnect(smtptransport.java:673) @ javax.mail.service.connect(service.java:295) @ org.springframework.mail.javamail.javamailsenderimpl.dosend(javamailsenderimpl.java:389) ... 38 more what should password be? username wrong? thanks in advance, al don't use cloudbees credentials connect sendgrid, runtime injected ones (read http://wiki.cloudbees.com/bin/view/run/sendgrid ). should use

actionscript 3 - AS3 enemy formations -

i have been developing shooter game in as3 using starling framework looking @ different tutorials. problem tutorials teach create random enemies move 1 side other. want know how can create different formations of enemies on screen. can suggest books, tutorials, or basic algorithm put me on track? here rather simple way spawn formation. create symbol in library called formation , use linkage/class name well. in symbol place 5 marker movieclips @ whatever locations want. marker clip recommend using circle centered. wherever place markers, represents enemies spawned. now, in code want spawn formation, can : var formationdata:movieclip = new formation; (var index:int = 0;index < formationdata.numchildren;index++) { var spawnmarker:movieclip = formationdata.getchildat(index) movieclip; var enemy:enemy = new enemy; enemy.x = spawnmarker.x; enemy.y = spawnmarker.y; addchild(enemy); } now, spawn formation based on set in formation symbol. you

java - MsAccess SQL Exception Too few parameters -

currently making java program grabs data off of msaccess database , of these errors extremely frustrating. keep getting sql.exception : few parameters. expected 1 error on last remaining bugs in program. little background on db: has 3 tables (a player table (11 columns), team table (3 columns), , opponent table (6 columns). these both of functions , problem lies in here somewhere conn = connect.connectdb(); string sql = "insert player ("+"playerlastname,"+"playerfirstname,"+"position)"+ "values("+txtid.gettext()+ ",'"+txtname.gettext()+"','"+txtaddress.gettext()+"')" ; try{ pst = conn.preparestatement(sql); pst.executequery(); pst.setstring(1, txtid.gettext()); pst.setstring(2, txtname.gettext()); pst.setstring(3, txtaddress.gettext()); joptionpane.showmessagedialog(null, txtid.gettext() + " saved"); updatejt

series 40 - Can Nokia Web Tools access device API? -

i'm using nokia web tools develop web app, need access device api such model name, exampl nokia asha 301, or e72, etc. possible? if not, possible device name through pure regular javascript api? the answer not, except location, again, location api in html 5, not really

javascript - Google maps API convert from V2 to V3 -

i jrying convert following 2 google m aps v2 api events v3 cannot life of me figure out how it, possible give me pointers on this? gevent.addlistener(map, "click", function(overlay, point){ if (point != null) { window.status = "click " + point.lat() + ", "+ point.lng(); } else if (overlay != null) { window.status = "overlay " + lastpoint.lat() + ", "+ lastpoint.lng(); } }); gevent.addlistener(map, "mousemove", function(point){ lastpoint = point; }); try this: google.maps.event.addlistener(map, 'click', function(event) { console.log(event.latlng); }); "no overlay argument exists in v3 event listeners. if register click event on v3 map callback occur when user clicks on base map. can register additional callbacks on clickable overlays if need react clicks. " - https://developers.google.com/maps/articles/v2tov3#events

Javascript - finding a particular form from a mouse change event -

i have webpage 4 separate pulldown option forms , have javascript function gets invoked when of forms gets changed via mouse. how establish specific forms changed event object , subsequently particular option change has been made? all examples have seem assume have dedicated javascript function each individual form. want able build forms 'on fly' need pass forms changes through single javascript function. in answer question - here's more info: i use jquery (but i'm novice) - javascript event setup code line is: document.onchange=this.audioselect and audioselect function has single line @ moment - alert proves gets invoked each form change: alert("audio select this: " + evtobj.type.tostring(). ). the forms defined similar 1 (with each subsequent form name being incremented: " <div id="videoslot" style="position: absolute; left:250px; top:450.0px; background- color:green;"> <

visual studio - Pdb's make my project always 'out of date' -

my project out of date because of pdb's. in vs output window see always: 'project out of date. input file foo.dll older output foo.pdb'. same. why happens? how should fix that? now founded reason... because usage of assembly produced project item in project file: if in foo project file define: <itemgroup> <thisassembly include="$(targetdir)\foo.dll" /> </itemgroup> than project out of date: input file foo.dll older output foo.pdb... vs 2012 sp2. sad.

objective c - Logging in to iOS app -

whenever have done apps require log in have placed login screen rootviewcontroller of uinavigationcontroller . i've been wondering whether or not best way approach it? is there standard pattern doing this? should maybe have modal screen on top of rootviewcontroller acts login screen? i have been using modal view controller 2 reasons: 1: because had implement auto login feature if user had been logged in , didn't want have add whole vc when navigating home screen when app auto logs in. makes loading , animation faster loose vc. 2: didn't want encryption code loaded entire duration of application incase wanted snapshot encryption , authentication process. not sure entirely necessary though, seemed bad have login code in memory duration of application. however in future applications im going neither, , create login view animates in , out when asking login details. in opinion looks best, modal view controllers dont have nicest of animations.

java - Jsoup select text after tag -

i want extract text after each tag using jsoup. there way select directly or have perform .substring on whole thing? <div> <a href="#"> don't want text </a> **i want retrieve text** </div> public static void main(string... args) throws ioexception { document document = jsoup.parse("<div>" + "<a href=\"#\"> don't want text </a>" + "**i want retrieve text**" + "</div>"); element = document.select("a").first(); node node = a.nextsibling(); system.out.println(node.tostring()); } output **i want retrieve text**

struts2 - How to suppress Jquery Validation submitHandler when cancel button is clicked? -

here have problem jquery validation plugin , struts2. i have 3 buttons below in form. <td><s:submit type="button" value="save" theme="simple" cssclass="valid" /></td> <td><s:submit type="button" value="cancel" theme="simple" action="cancel" cssclass="cancel"/></td> <td><s:submit type="button" value="submit" theme="simple" cssclass="valid"/></td> when form submitted, validations done using jquery validation. after form submitted, want user confirmation submit form ? so used submithandler of jquery validate function. when click cancel submithandler getting executed. dont want happened when cancel button clicked. here javascript part. $(document).ready(function() { $("#myform").validate({ //some validation rules submithandler: function(form) { //this runs when

html - Link does not work -

i try make menu @ website. menu html code following <div id="menu"> <ul class="navigation"> <li><a href="#home" class="selected">home<span class="ui_icon home"></span></a></li> <li><a href="#aboutus">about us<span class="ui_icon aboutus"></span></a></li> <li><a href="#gallery">gallery<span class="ui_icon gallery"></span></a></li> <li><a href="#contactus">contact us<span class="ui_icon contactus"></span></a></li> <li><a href="http://www.google.com">google</a><span class="ui_icon services"></span></li> &l

jquery - Scroll to top of element when near top of window -

i trying achieve following: i have div, when it's @ top of page want automatically scroll top of div. here script have far. can see (i hope). when #plus between 250 , 20 px top of page, want run animation positions #editions @ top of page. however, animation executed many times, , keeps on going. think it's being triggered every value in range between 250 , 20, 230 times. i'm not sure if i'm going right way. // scroll editions // function scrolleditions(){ $('html, body').animate({ scrolltop: $("#plus").offset().top }, 1200, 'easeoutquint').delay(200).animate({ scrolltop: $("#editions").offset(). }, 800, 'easeoutquint'); }; // scrolling check // function showhidetitles(){ // distance of elements frop top // var ptop2 = math.round($('#plus').offset().top - $(window).scrolltop()); // plus top // auto scrolling // if (ptop2 <= 240 && ptop2 >= 20){ sc

php - sqlsrv fetch array is only returning 1 result (most recent) and i know there is 5+ for a particular code -

here query, it's pulling added holdcode. armcode patient id , holdcode 2 digit code. $test = sql::query("select armcode, holdcode are.aas.me armcode = 'adsmanzs01'", $row['holdcode']); if($test){ $data = sqlsrv_fetch_array($test); echo $data['holdcode']; } do need foreach or loop through results have them echo or print_r? as usual, appreciated. use while loop iterate results while ($data = sqlsrv_fetch_array($test);) { //perform task }

Nutch 2.1 cassandra backend generate error -

i made choice on cassandra backend , started play nutch. small subset of dmoz urls (~50k), (inject, generate, fetch) runs fine. however, after injected whole dmoz url set (~3.5m) , tried generate fetchlist, got following error, reproducible on system: ~/software/nutch_dmoz/local$ ./bin/nutch generate -topn 1000 generatorjob: selecting best-scoring urls due fetch. generatorjob: starting generatorjob: filtering: true generatorjob: topn: 1000 generatorjob: java.lang.runtimeexception: job failed: name=generate: 1366905487-307733671, jobid=job_local_0001 @ org.apache.nutch.util.nutchjob.waitforcompletion(nutchjob.java:54) @ org.apache.nutch.crawl.generatorjob.run(generatorjob.java:191) @ org.apache.nutch.crawl.generatorjob.generate(generatorjob.java:213) @ org.apache.nutch.crawl.generatorjob.run(generatorjob.java:241) @ org.apache.hadoop.util.toolrunner.run(toolrunner.java:65) @ org.apache.nutch.crawl.generatorjob.main(generatorjob.java:249) logs/hadoop.l

Is there a concat function in GQL? -

is there concat function in google query language? given table x fname |lname --------|------ bob |smith larry |potts ask query: select concat(fname, lname) x i like: bobsmith larrypotts any ideas on how achive this? just concatenate them manually aftewards: query = gqlquery(...) result in query: fullname = result.fname+result.lname # fullname

xcode - Trying to understand Auto Layout -

Image
i'm trying understand how use auto layout haven't been able wrap head around how accomplish using it. have ipad viewcontroller 2 subview views. i'd layout work in representation i'm not clear on values set. particularly relationship between 2 subviews: the left view should pinned superview's top, left , bottom edges (with padding) it's right edge should pinned right view's left edge. the right view should pinned superview's top, right , bottom edges (with padding). should have width constraint constant value, set appropriate number on rotation. in ib, you'd create outlet width constraint. in code, assign property create it.

windows phone 7 - WP - Marketplace misssing required metadata -

i tried publish windows phone app on marketplace have error , cant figure out how can repair it: submission errors myappwinphone.xap czech missing required metadata: tile icon missing required metadata: screenshot wvga english (international) missing required metadata: tile icon missing required metadata: screenshot wvga app based on sdk 7.1 how can repear validation erorrs? app store need tile icon , @ least 1 screen shoot of application @ time of submit, without not submit , may show error. explore option , check error, there option show errors . sheck out.

xcode - Expected identifier image -

hi new here , noob xcode please help. trying make imagepickercontroller having trouble 1 error , don't know how solve it. viewcontroller.h @interface viewcontroller : uiviewcontroller<uiimagepickercontrollerdelegate> { iboutlet uibutton *button; iboutlet uiimageview *image; uiimagepickercontroller *imagepicker; } - (ibaction)change:(id)sender; @end viewcontroller.m @interface viewcontroller () @end @implementation viewcontroller -(void)touchesmoved:(nsset *)touches withevent:(uievent *)event { uitouch *mytouch = [[event alltouches] anyobject]; button.center = [mytouch locationinview:self.view]; } - (void)viewdidload { [super viewdidload]; imagepicker = [[uiimagepickercontroller alloc] init]; [imagepicker setsourcetype:uiimagepickercontrollersourcetypephotolibrary]; [imagepicker setallowsediting:yes]; } - (ibaction)change:(id)sender { [self presentviewcontroller:imagepicker animated:yes completion:no]; } - (void)image

Driving distance between two places - android -

i have 2 latitude-longitude pairs , want calculate driving distance between them. used location.distancebetween() method this. returns not driving distance. smaller value driving distance. can distance returns? can find actual driving distance using google maps android api v2? how?

php - Host 'hostname' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' -

my website working on localhost 'wamp' server. however, upload web host others use, following error: host 'stats.starfish.arvixe.com' blocked because of many connection errors; unblock 'mysqladmin flush-hosts' i cannot perform 'flush-hosts' command, since using shared host , lack privileges. i've searched extensively online, , can't find solid answer may causing connection errors. site works bit, multiple people start using it, mysql blocks web host because has many connection errors. is there sort of log can access or view may inform me causing connection error? https://dev.mysql.com/doc/refman/5.0/en/blocked-host.html your problem continually attempting connect , failing. shared server set protect behavior, , has cut off. turn off application while , resolve connection problem before turning on. the amount of time before able attempt again set on server, in place can not see. try every 15 minutes while until allowed at

java - How to limit number of checkboxes that can be checked? -

i have 4 checkboxes. want user select 2 of them. how set limit? you can have int variable stores how many checkboxes checked... time oncheckedchanged() called, check variable , if third checkbox checked, set unchecked again... let's start checkboxes unchecked. do: int numberofcheckboxeschecked = 0; then set oncheckchangedlistener : checkbox1.setoncheckedchangelistener(new oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { if (ischecked && numberofcheckboxeschecked >= 2) { checkbox1.setchecked(false); } else { // checkbox either got unchecked // or there less 2 other checkboxes checked // change counter accordingly if (ischecked) { numberofcheckboxeschecked++; } else { numberofcheckboxeschecked--; } // fine , can whatever //

asp.net - is reading web.config from a class insecure? -

i wanted way of getting settings without having them every time made simple class. ex: public class customconfigsettings { public customconfigsettings() { // default constructor. } public string mysetting { { return configurationmanager.appsettings["mysetting"]; } } } it works fine, feels might insecure (for reason can't put finger on). appreciate feedback on security issues, if any, , possible alternatives. (webforms; .net 3.5). this not insecure itself. security depends on access class , if class permits changes configurations, if access code, can change settings.

Extending a Java collection class like ArrayList for easier Generics management (warnings...etc)? -

extending java default collections not considered practice. wondering if, sake of cleaner code, 1 not extend, arraylist rid of generic. example public class doodlelist extends arraylist<doodle> { /** * */ private static final long serialversionuid = 1l; } so in one's code thing "someframework.getcontentas(doodlelist.class)" without having nasty warnings generics...etc note wrapping list might not option in case : class used in json mapping desired output : {doodles : [doodle1,doodle2,doodle3]} not {doodles : {innercollection : [doodle1,doodle2,doodle3]}} hiding nasty warnings playing around inheritance smells me. why not use annotation suppress warning. example: @suppresswarnings("unchecked") someframework.getcontentas(arraylist.class)"

sql server - sql deadlock in transaction scope -

i have transaction scope , to: using (var scope = new transactionscope()) { 1) insert row table1 2) select rows table1 (incuding inserted row in step 1) 3) insert row table1 4) select rows table1 (incuding inserted row in step 1 , 3) } is there chance sql deadlock in operations? i'm usig entity framework db work. i'm not sure this. thank you, have nice day. there should no problems this. the inserts may lock other users out, or lock other transactions made yourself, not lock doing in same sql transaction.