Posts

Showing posts from February, 2010

html - unable to see the image in the frontend, joomla website -

Image
my website running on joomla 3.0 , have created customhtml module type on page of website www.earthandwaterpictures.com . problem updating text of particular module getting reflected on frontend, when i'm trying insert image, left aligned text, image getting displayed properly. in short, i'm able make changes text, not the image. here link page http://earthandwaterpictures.com/index.php/about-us . have tried clearing cache of browser , joomla system menu. if right click , inspect element on browser itself, you'll see tag without syntax error or anything. your picture has display: none . you should rid of fav-breadcrumbs id on container element:

c++ - QT can't find openCV's libs -

i've installed opencv via this instruction. i use opencv when , build code via cmake - , it's ok. i'm trying use opencv qt, , errors this: error: undefined reference `cvcreatecameracapture' the same errors functions opencv. i tried add in .pro code: includepath += /usr/local/include/opencv2 libs += -l/usr/local/lib libs += -lopencv_core libs += -lopencv_imgproc libs += -lopencv_highgui libs += -lopencv_ml libs += -lopencv_video libs += -lopencv_features2d libs += -lopencv_calib3d libs += -lopencv_objdetect libs += -lopencv_contrib libs += -lopencv_legacy libs += -lopencv_flann but isn't work. dir /usr/local/include/opencv2 exist , not empty. so, what's wrong? add .pro file: libs += "pkg-config --libs opencv"

About checking fields around in 2 dimensional array [C++] -

i know might sound stupid, got ask. it's easy thing. you have 2 dimensional array, elements inside or empty, location(x , y) , have draw 1 field free fields around. i know how it, doesn't seems ... elegant or nice. way doing checking if i'm on max left, max right, top, bottom, etc. if there in fields around, , rand(). it's long , seems unpleasent. don't know if there's shorter way? thanks. and sorry english, doing best. there might performance issues. critic situation when have point [x, y] in corner, rand() can possibly select invalid elements multiple times, have rand() , check again. the way i'd it, check available neighbours , push each valid neighbour std::vector . after that, there's 1 random number generation chooses 1 element within vector: std::vector<coordinate> validneighbours; // coordinate struct x , y integers, can use std::pair<int, int> or pointers elements if(/* has neighbour left*/) validne

Quaternion to Euler angle conversion -

i using imu (mpu9150/9250) measuring relative joint angle. if in 2 different conditions where, x , z towards user z , x towards user how can convert quaternion euler angle in zyx sequence out having singularity? best regards, akhil

php - variable the loop doesn't increase -

need count updated data in table, $up stays 0. data received imported csv file. $up=0; { //loop through csv file if ($data[0]) { $res = mysql_query("select ..."); $check=false; for($i = 0; $array[$i] = mysql_fetch_assoc($res); $i++){ while ((condition)){ $check = true; $i++; }; }; if ($check) { $up++;//this not work mysql_query("update ..."); } else { mysql_query("insert ..."); } } } while ($data = fgetcsv($handle,1000,",","'")); there's code below do-while loop choose file , messege $up <html> ... <?php if (!empty($_get[success])) {echo $up; } ?> <form action="" method="post" enctype="

How can i detect that user has pressed enter key (in java) And what, if i want to use enter key in the condition of a loop? -

please me! m new java. want specific line of code must executed after enter button has been pressed. like: int x= in.nextint(); value stored in x after pressing enter. now want use such mechanism in loop.means; perform statement if enter button has pressed else statement. if(!enter key pressed) { } else if(space has been pressed) { } tell me kind of code should write in java? i don't want use listeners. so suggest me should do? simply read line of input. if you're reading user input: bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); string input = null; try { input = br.readline(); //this code executed after user pressed enter } catch (ioexception e) { //handle exception } likewise, if you're reading file, change system.in file (opened file object): file file = new file(path); bufferedreader br = new bufferedreader(new inputstreamreader(new filereader(file))); if want distinguish between i

mysql - Column value of first table needs to be update automatically whenever the second table row is updated or added -

column value of first table needs update automatically whenever second table row updated or added. i have 2 table ccncsr , csrtimereporting mysql> select * ccncsr; select * csrtimereporting; +-----------+-----------------------------------------+----------+-------------+-----------+-------------+------------+------------+------------+-------------------+--------+ | csrnumber | slogan | severity | customer | status | createddate | ccnqdate | tts | iadate | totaltimereported | remark | +-----------+-----------------------------------------+----------+-------------+-----------+-------------+------------+------------+------------+-------------------+--------+ | 2718122 | diameter link flicks between ggsn-ccn38 | high | ideaindia | null | 2105-03-04 | 2105-03-03 | 2015-03-28 | 2105-03-13 | null | na | | 2718133 | auto zr | high | airtelindia | analysin

c# - direct reference to app.ico icon - NO EXTRACT -

i have c# project. choose .ico file in property automatically added .ico list "solution explorer". i using "notifyicon", , want change icon programmatically. example notifyicon red when program busy , green when free. know have add new embed resource second ico. how access existing 1 application ico? i "something like" notifyicon1.icon = appname.greenico.ico; //default app ico notifyicon1.icon = appname.redico.ico; //ico ill add embed resource guess is possible? saw strange extractico thingy... sure possible reference straight embed ain't it? found really easy solution. first: change "build" properties of 2 icons in "solution explorer" "embedded ressource". now in code set 2 icons variables: public icon greenico = new icon(typeof(mainformname), "greenico.ico"); public icon redico = new icon(typeof(mainformname), "redico.ico"); then use them, easy so: notifyicon1.icon = gre

ruby - Bundle install failed getting error occurred while installing unf_ext (0.0.6) -

i have tried running bundle install on mac keep getting following message: an error occurred while installing unf_ext (0.0.6), , bundler cannot continue. make sure gem install unf_ext -v '0.0.6' succeeds before bundling. but when install unf_ext(0.0.6) error message: error: error installing unf_ext: error: failed build gem native extension. make install failed, exit code 2. any appreciated, thank you. i found solution: brew install coreutils installed missing gmkdir

Rotating and changing the size of image in Android Camera -

i'm new android development , recently, i've made simple camera app android have problems cannot solve. first, i've rotated preview screen 90 degree surfaceview in portrait mode. 've used code below . public void surfacechanged(surfaceholder holder, int format, int w, int h) { if(mcamera != null) { camera.parameters parameters = mcamera.getparameters(); parameters.setpreviewsize(mpreviewsize.width, mpreviewsize.height); requestlayout(); mcamera.setdisplayorientation(90); mcamera.setparameters(parameters); mcamera.startpreview(); } but problem isn't solved. after take shot , check image in folder jpg image took app saved horizontally bad resolution. i'm not sure how explain want alter image size , save in portrait mode. code save image sample below, i'm not how , can change size , rotation before saving. sorry bad english. great if can have clear tips noobs. private class saveimagetask exten

java - How to get SD card size programmatically in _EMULATOR_ in Android Studio -

this works on real gadget connected via usb cord while in debugging mode: statfs stat = new statfs(environment.getexternalstoragedirectory().getpath()); long bytestotal = (long) stat.getblocksize() * (long) stat.getblockcount(); long bytesavail = (long) stat.getblocksize() * (long) stat.getavailableblocks(); if, however, try run avd, 0 bytes. tools | android | avd manager | virtual devices | view details gave me this: name: nexus_5_api_21_x86 cpu/abi: google apis intel atom (x86) path: c:\users\owner.android\avd\nexus_5_api_21_x86.avd target: google apis (api level 21) skin: nexus_5 sd card: 200m snapshot: no hw.dpad: no runtime.network.speed: full hw.accelerometer: yes hw.device.name: nexus 5 vm.heapsize: 64 skin.dynamic: no hw.device.manufacturer: google hw.gps: yes hw.audioinput: yes tag.id: google_apis hw.camera.back: emulated hw.mainkeys: no avdid: nexus_5_api_21_x86 hw.camera.front: emulated hw.lcd.density: 480 runtime.scalefactor: au

compiler construction - the positioning mechanism in bisonc++ YYLTYPE is always returning 0 -

while parsing source file using grammar bisonc++, want line number of token. i've enabled %lsp-needed . when i'm accessing line number using @1.first_line , @1.last_line , both printing 0 though tokens not 0th line.

jquery ui - Comiseo daterange picker options -

Image
i using date range picker http://tamble.github.io/jquery-ui-daterangepicker/ all want drop down select month & year. know there options available jquery ui render drop down instead of text month , year. however when used applies on first datepicker only. want drop down on both calender. below capture form demo on working. i found reference here var $datepicker = $("#txtstrtdate,#txtexpdte"); $datepicker.datepicker({ changemonth: true, changeyear: true, inline: true, altfield: "#datep", }).change(function(e){ settimeout(function(){ console.log(e, e.currenttarget, $datepicker.find('.ui-datepicker-current-day:visible')[0]); $datepicker .find('.ui-datepicker-current-day') .next('td') .children('.ui-state-default') .addclass('ui-state-active'); }); }); fiddle

android - Error while using Parse SDK for tesiting PUSH Notifications-Multiple dex files define Lcom/parse/FacebookAuthenticationProvider$1 -

{dex loader} unable execute dex: multiple dex files define lcom/parse/facebookauthenticationprovider$1 ; i keep getting error while exporting project in eclipse . have tried solutions mentioned in similar questions yet it's not working.. tried link . just delete facebook jar parsefacebookutils v3 it makes conflict parsefacebookutilsv4-1.9.1.jar and run

java ee 6 - What's difference between `javax.servlet.AsyncContext.startAsync()` and `new Thread(Runnable).start()`? -

i have read article 17.12 asynchronous processing what difference between: public void doget(httpservletrequest req, httpservletresponse resp) { asynccontext acontext = req.startasync(); ... } and public void doget(httpservletrequest req, httpservletresponse resp) { runnable runnable = ... new thread(runnable).start(); ... } the difference lies in 'who' controlling thread. when asynccontext request, use start method , pass instance of runnable, container manages thread in executes logic passed in runnable instance. not case when fire thread using new thread(runnable).start()

android - How to retrieve JSONOBJECT which is inside JSONArray -

this java code retrieve data json res = out.tostring(); jsonarray arrjsonarray=new jsonarray(res); (int = 0; < arrjsonarray.length(); i++) { jsonobject object = arrjsonarray.getjsonobject(i); data data=new data(); data.setname(object.getstring("slug")); data.setmsg(object.getstring("modified")); data.setlocation(object.getstring("type")); // want show data inside offer_shop_details. //like afflshop_address, afflshop_email, please me. jsonobject authore = object.getjsonobject("offer_shop_details"); string authore1 = authore.getstring("afflshop_address"); data.setlocation(object.getstring(authore1)); itemlist.add(data); } this jsonarray without object name have retrieved data insi

c - adapting xbox controller to simple ncurses game -

libusb_device_handle *h; int transferred , r; r = libusb_init(null); libusb_set_debug(null, 3); //open device h = libusb_open_device_with_vid_pid(null, 0x045e, 0x028e); if (h == null) { fprintf(stderr, "failed open device\n"); return (1); } r = libusb_kernel_driver_active(h,0); if(r>0) r = libusb_detach_kernel_driver(h,0); r = libusb_claim_interface(h,0); if(r!=0) { fprintf(stderr, "interface failed: %d\n",r); return (1); } this part of handling device , after in moving section have these piece of codes. unsigned char buffer[20]; libusb_interrupt_transfer(h, 0x81, buffer, sizeof (buffer), &transferred, 0); char direction = 'l'; if (((buffer[3] >> 6)&0x01)) { if (direction != 'r') direction = 'l'; }

c - include <signal.h> error, library is missing -

i trying compile code uses these libraries on ubuntu #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <unistd.h> but compiler returned error sig.c:3:9: error: #include expects "filename" or <filename> #include <signal.h> ^ also unistd.h is there way fix without reinstalling ubuntu? the compiler reporting syntax error, not missing header. code in question looks correct, there must strange characters you're not seeing, perhaps looks < character or space isn't. try typing head foo.c | cat -a at shell prompt; show what's in source file. (substitute actual file name foo.c , of course.)

authentication - ASP.NET Identity cookie and subdomains -

i'm trying share asp.net identity cookie across subdomains. locally. sub1.domain.local sub2.domain.local i have same machine key on both sites, cookie created on sub1 not validate on sub2 , vice versa. resulting cookie domain ".domain.local" (which should correct??) this setup in startup class: app.usecookieauthentication(new cookieauthenticationoptions { authenticationtype = defaultauthenticationtypes.applicationcookie, loginpath = new pathstring("/login"), cookiedomain = ".domain.local", }); i've tried on localhost:siteport each site, same result (cookie domain blank, resolving "localhost") i can't life of me figure out i'm doing wrong. maybe can point me in right direction? thanks update okay, i've figured out cookie in fact shared between subdomains, it's considered valid on subdomain created cookie. need find way know why authentication fails

python - I have an array of strings; is there a way to see which one an argument string is closest to? -

i'm working in python, , i've decided break down , make huge array of phrases result of speech recognition module compare to. far i've got: phrases = [ "what time it", "what's weather", "what's date", "hello", "hi", "what's up", "how you" ] (i've started few minutes ago, haven't got yet... outline) anyway, i'd function kind of this... def match(phrase): #match_greatest start @ 0 continuously update if string #being compared has higher percentage match match_greatest = 0 #match store actual string closest match = "" in phrases: #this part need with... match_current = #somehow percentage argument phrase matches phrase it's comparing #if current phrase closer match before, update if match_current > match_greatest: match_greatest = match_current matc

php - How can i insert data from an XML into a database -

this question has answer here: import xml content specified attributes mysql table? 1 answer i want insert following xml file mysql database using php <?xml version="1.0" encoding="utf-8"?> <printletterbarcodedata uid="725733706873" name="ravinder kumar" gender="m" yob="1996" co="s/o kaka ram" house="460a" street="ward no. 6" lm="na" loc="na" vtc="nanyola (292)" po="naneola" dist="ambala" state="haryana" pc="134003" /> how extract data xml file insert them database ? for php approach, find following useful: <?php $string = <<<xml <printletterbarcodedata uid="725733706873" name=&

QT QML signal does not get to a Canvas when defined in style: ButtonStyle -

i quite new qml , trying make qml button change it's background when event happens. button uses style: buttonstyle , canvas generate graphics (via javascript). using qml state s control button state. i figured out canvas not refresh automatically tried call requestpaint() inside onstatechanged handler, signal somehow not canvas when defined in style property. here code: button { id: small_rounded_button state: "off" states: [ state { name: "on" propertychanges { target: small_rounded_button backgroundcolor: "#18243c" } }, state { name: "off" propertychanges { target: small_rounded_button backgroundcolor: "#aaa" } } ] mousearea { anchors.fill: parent onclicked: { if (small_rounded_button.enabled == tr

java - JFXtra agenda to only show between certain times? -

for example if want show ranges 9am 9pm? displayedcalendar property doesn't seem change anything, changed displayed date. is possible? right there week , day skin, showing both 24 hours. answer is: not @ moment.

java - DesiredCapabilities object not getting its properties -

i trying use desiredcapabilities in selenium 1 of project. have created new project , imported selenium standalone jars along libs (tried 2.44 , 2.45 versions). have written below code, import org.openqa.selenium.remote.desiredcapabilities; public class desiredcapatest { desiredcapabilities capabilities = new desiredcapabilities(); capabilities. } when write 'capabilities.' expect see different options set etc. seeing message 'unavailable-bsh.capabilities'. same code working fine in office machine. my home machine windows 8.1 , office machine windows 7, not sure whether matter. awaiting feedback. the function list not displayed when not have jar file: selenium-java-2.43.0.jar added build path of project. please make sure have jar files added build path. right click on project->build path->configure build path goto libraries->add external jar files add jar files made available selenium (please check bsh-1.3.0.jar well)

python - How to unit test Django rest framework requests? -

i have django-rest-framework api, want unit test. more specifically, want unit test data validation methods separately. these data validation methods request parameter, so: def validate(request) in order test separately, need way create requests. in django-rest-framework, there apirequestfactory , can used in creating requests. main problem is, apirequestfactory not create same request django-rest-framework uses. instead, create regular django requests stated site: note: when using apirequestfactory, object returned django's standard httprequest, , not rest framework's request object, generated once view called. but because validation methods use django-rest-frameworks request, cannot unit test using apirequestfactory. there way unit test separately those, or should use apiclient, , try test whole apiview? wouldn't want that, because not pure unit test. , apiclient, can responses, not requests. why there not apirequestfactory django-rest-framework requests?

PHP Array printing in a different format -

i'm having troubles printing array in following format: "key, value" my current array following format: array(51) { ["t"]=> int(3) ["i"]=> int(3) ["co"]=> int(3) ["http"]=> int(3) ["it"]=> int(2) ["new"]=> int(1) ["project"]=> int(1) } any idea on can format array shows need? do this: <?php foreach($array $key => $value) { echo '"'.$key.', '.$value.'"'; echo '<br/>'; } where $array initial array.

Stocking user visited pages in a serialized array Mysql php : strangely disapearing -

i stock page user has visit in serialized array in database. when visitor has visited few page (~60 or more) array disapear , restarts 0. how fix ? thank ! my code if($utilisateur[0]!=null) { $table=unserialize($_session['vue']); if($table[$_get["serie"]][$_get["version"].round($_get["numero"]/64)]!=null) { } else { $table[$_get["serie"]][$_get["version"].round($_get["numero"]/64)]=0; } if($table[$_get["serie"]][$_get["version"].round($_get["numero"]/64)]&pow(2,($_get["numero"]%64))) { } else { $table[$_get["serie"]][$_get["version"].round($_get["numero"]/64)]=$table[$_get["serie"]][$_get["version"].round($_get["numero"]/64)]|pow(2,($_get["numero"]%64)) ; $_session['vue']=serialize($table); $req2 = $loginbase->prepare('update `user` set v

python 3.x - 'IndentationError: unindent does not match any outer indentation level', when indent is completly correct -

i don't know if bug, or editor error, @ specific line, throw 'indentationerror: unindent ...' code is: def toktype(token): if type(token) str: if ":" in token: out = "" c in token: if c == ":": break out += c return out else: return none elif type(token) list: i, t in enumerate(token): if != 0 , toktype(t) != toktype(token[i-1]): return "multi" return toktype(token[0]) else: raise typeerror("unsupported type {0}, expecting list or string!".format(type(token))) why getting error?? it editor fault. started write tabs instead of spaces. found-replaced tabs spaces , checked settings.

c# - How to create a tree representing namespaces from their string representations -

Image
how can create tree-like data structure namespaces. for example, these namespaces: enums.newenums.new1 enums.newenums.new2 enums.newenums.new3 enums.oldenums enums.test.sub enums.test.sub.ok and load treeview shown below: i tried split namespaces, life of me can't think of logic generate correctly. also tried generate way generate directory structure, can't head around since namespaces need splitting. 1. parsing namespace here class represents namespace. represents namespace dictionary of directly nested namespaces. generate namespace s strings provides static methods use recursive calls , linq : public class namespace : idictionary<string, namespace> { #region static public static ienumerable<namespace> fromstrings(ienumerable<string> namespacestrings) { // split strings var splitsubnamespaces = namespacestrings .select(fullnamespace => fullnamespace.split('.'));

email - php not running script -

i want send mails using php. have take mails id database fetching data tables , using mail functions when going server , run shows nothing blank page appears site pligg cms base site <html> <head> <title>sending html email using php</title> </head> <body> <?php $mysql_host = "localhost"; $mysql_database = "db"; $mysql_user = "r"; $mysql_password = "s#1#"; $con=mysql_connect($mysql_host,$mysql_user,$mysql_password); if(!$con) { echo "can't connect"; die("failed connect".mysql_error()); } $db_select=mysql_select_db($mysql_database); if(!$db_select) { echo "db not connected"; die(" failed user".mysql_error()); } $query1 = "select * pligg_users" $subject = "exclusive facebook cover offer."; $message = "hello"; $messa

sqlite - Escaping SQL queries in C# -

i have program runs queries on sqlite db , want replace ' character in query ''. the code using: val.value.replace(',' '\'\ ') but vs doesnt accept that, there different method? the code below uses quotes (") encapsulate 2 parameters of replace statement. in case, first parameter single quote (') , second 2 single quotes (''). result in code below. val.replace("'","''")

python - Close TopLevel window after command -

i'm doing simple compressor in python school assignment, problem here when enter name of file, little window has appear button execute tar command, want window close after command dont know why, here's code def crea_arxiu(): global aux if v.get() 1 or v.get() 2 or v.get() 3 or v.get() 4: f = open('fitxers.txt','w') in range(llista2.size()): f.write(llista2.get(i)+'\n') f.close() print 'arxius comprimir:',llista2.size() obre_finestra() if aux 1: print 'aux true' subprocess.call(['rm','fitxers.txt']) else: print 'escolleix una opcio' #aquest mètode crea mostra la pantalla per guardar el nom #i la finestra amb la comanda que executara def obre_finestra(): global aux ruta_text = stringvar() finestra2=toplevel(finestra) finestra2.minsize(0,0) finestra2.title('comanda executar:')

c# - The remote procedure call failed -

this first post, please easy on me :) i doing a tutorial facebook sdk , , trying login facebook service windows phone xaml application. works fine when follow steps of tutorial, , hit login button log in, when trying automate this, error. the code uses webauthenticationbroker, calling webauthenticationbroker.authenticateandcontinue(loginurl); when try put code inside loaded event private void page_loaded(object sender, routedeventargs e) { if (this.fbhelper.accesstoken == null) { webauthenticationbroker.authenticateandcontinue(loginurl); //throws error } else { getuserinfo(); } } i following error: the remote procedure call failed. (exception hresult: 0x800706be) i think problem page not ready yet perform logic, don't know should put code? it seems broker can called once window activated. i've tried should work when done this: public mainpage() { this.initializecomponent(); window.current.activa

Regex grouping matches with C++ 11 regex library -

i'm trying use regex group matching. want extract 2 strings 1 big string. the input string looks this: tХb:username!username@username.tcc.domain.com connected tХb:username!username@username.tcc.domain.com webmsg #username :this message tХb:username!username@username.tcc.domain.com status: visible the username can anything. same goes end part this message . what want extract username comes after pound sign # . not other place in string, since can vary aswell. want message string comes after semicolon : . i tried following regex. never outputs results. regex rgx("webmsg #([a-za-z0-9]) :(.*?)"); smatch matches; for(size_t i=0; i<matches.size(); ++i) { cout << "match: " << matches[i] << endl; } i'm not getting matches. wrong regex? your regular expression incorrect because neither capture group want. first looking match single character set [a-za-z0-9] followed <space>: , works single character usern

Similar to C#'s Process.Close event in Java? -

if start process using processbuilder in java, there way listen if process has been closed? start process, insert record mysql table, , when process killed or user exited, execute delete statement in mysql table. i've done in c#, users requested application able run on linux , mac too, , stuck @ part. try friend. public class yourclass { public static void main(string[] args) throws ioexception { processbuilder yourprocess = new processbuilder(); process process = yourprocess.start();//creates new object containing process //your insert sql stuff... try { process.waitfor();//waits until process finish //your delete sql stuff... } catch (interruptedexception ex) { system.out.println("the process finished unexpectly");; } } }

How to calculate standard deviation of a table in R? -

i have table of data looks this: category : solution 1 : solution 2 : diff 1: 5 : 6 : -1 2: 7 : 6 : 1 3: 4 : 4 : 0 4: 8 : 9 : -1 how calculate standard deviation within r? sd(d$diff) should give standard deviation of column to standard deviation of columns apply(d,2,sd) where d data frame.

python - Is it possible to get color gradients under curve in matplotlib? -

Image
i happened see beautiful graphs on page shown below: is possible such color gradients in matplotlib? there have been handful of previous answers similar questions (e.g. https://stackoverflow.com/a/22081678/325565 ), recommend sub-optimal approach. most of previous answers recommend plotting white polygon on pcolormesh fill. less ideal 2 reasons: the background of axes can't transparent, there's filled polygon overlying it pcolormesh slow draw , isn't smoothly interpolated. it's touch more work, there's method draws faster , gives better visual result: set clip path of image plotted imshow . as example: import numpy np import matplotlib.pyplot plt import matplotlib.colors mcolors matplotlib.patches import polygon np.random.seed(1977) def main(): _ in range(5): gradient_fill(*generate_data(100)) plt.show() def generate_data(num): x = np.linspace(0, 100, num) y = np.random.normal(0, 1, num).cumsum() retur

plugins - Advanced indent settings in Visual Studio -

i'm using vs2013 , i'd change indentation. however, visual's settings aren't enough me. i'd auto indent this: int function() { int a=1; while (a) { if(a>0) { a=0; return; } } } are there plugins, or me indentation?

c# - How to create a true 'Random' with Timer control? -

i have timer clicks button, , no matter speed timer at, due random having kind of association clock, outcome predictable no matter speed. i have been reading , learned when new random initialized, done system time, explains why i'm getting problem. here's have: int win = 0; int lose = 0; private void button1_click(object sender, eventargs e) { random rn = new random(); int rnu = rn.next(2); if (rnu == 0) win++; if (rnu == 1) lose++; string winmsg = "wins: " + win.tostring(); string losemsg = "losses: " + lose.tostring(); winlbl.text = winmsg; loselbl.text = losemsg; timer1.start(); } and timer: private void timer1_tick(object sender, eventargs e) { button1.performclick(); //interval 500, predictable. } my goal try create more 'random' outcome- 1 wouldn't predictable timer control. howev

php - Adding session in while (mysql) -

if(isset($_session['username'])) { $con = mysql_connect('localhost','root',''); mysql_select_db('chatbox',$con); $result = mysql_query("select id users"); mysql_query("update users set `online` = 0 `username` = ".$username.""); } can make username session (that logged in) equal to mysql_query("update users set `online` = 0 `username` = "to_put_it_here"); simple , cute trick $username = $_session['username']; if(isset($username)) { $con = mysql_connect('localhost','root',''); mysql_select_db('chatbox',$con); $result = mysql_query("select id users"); mysql_query("update users set `online` = 0 `username` = '$username' "); }

opencv - Canny Edge vs Thresholding for contour estimation in Open CV -

i using open cv image processing application involves contour estimation in images. know whether thresholding image (like how have done here ) or using canny edge algorithm ( here ) yields better result. involve algorithmic analysis or missing something? canny edge detection obviously. whole bunch of things ensure strong edges come out of result. thresholding takes @ intensities , sees whether or not each value smaller or larger , "edge" points respectively. however , depending on complexity of scene, thresholding , edge detection yield same thing. example, if had clean image multiple crisp objects have clear intensity difference between foreground , background, either edge detection or thresholding work. if had more complex image contrast different in different areas, or if had multiple objects different intensities, thresholding not give results because inevitably including in pixels don't belong proper objects. why edge detection better, it's lo

css - How do I lean a xul element to the right side of a variably sized centered element? -

Image
<edit>i decided clean question little bit, easier reading.</edit> i have centered <menulist> , of variable width ( maxwidth="200" ), next want lean couple of <toolbarbuttons> in <hbox> . these elements part of xul <page> element. the following image shows current result , actual goal is: the vertical red line merely drawn indicate center of window. the current result achieved following css , xul: css: page { -moz-appearance: none; background-color: #fff; text-align: center; } toolbarbutton { list-style-image: url( 'chrome://codifiertest/skin/icons.png' ); } toolbarbutton .toolbarbutton-icon { width: 16px; height: 16px; } toolbarbutton.add { -moz-image-region: rect( 0px, 16px, 16px, 0px ); } toolbarbutton.edit { -moz-image-region: rect( 0px, 32px, 16px, 16px ); } toolbarbutton.delete { -moz-image-region: rect( 0px, 48px, 16px, 32px ); } toolbarbutton.config { -moz-image-region: rect( 0px,

Basic Java Income Tax -

the question: write program prompts user enter his/her taxable income , calculates income tax due using 2014 tax table below. express tax 2 decimal places. income tax brackets single-filers $9075 10% $9076 - $36900 15% $36901 - $89350 25% $89351 - $186350 28% $186351 - $405100 33% this have far. i'm new java keep in mind. specific question come after code. import java.util.scanner; public class incometax { public static void main(string[] args) { scanner input = new scanner(system.in); // prompt user enter taxable income system.out.print("enter amount of taxable income year 2014: "); double income = input.nextdouble(); // compute tax double tax = 0; if (income <= 9075) tax = income * 0.10; else if (income <= 9076) tax = 9075 * 0.10 + (income - 36900) * 0.15; else if (income <= 36901) tax = 9075 * 0.10 + (9076 -

javascript - existing function is undefined -

i working hammer.js library: http://hammerjs.github.io/ , using jquery plugin. there few ivents 'panright panleft press' on occurrence of able call function. trying call cardswipe(..) function, consol error saying cardswipe undefined. can't figure out causing this. /* initiate hammerjs on elements */ inithammer : function() { /* create hammer object swipable game cards */ game.$gamecard = $('.game-card-mobile'); game.$gamecardtouch = game.$gamecard.hammer(); game.$gamecardtouch.on("panleft panright press", cardswipe(ev, $(this), data)); }, cardswipe : function(ev, element, data) { console.log(ev.type); console.log(element); console.log(data); } edit: adding game.cardswipe resolved that, error of: ev undefined, ev hammer.js event , should recognized (it if swap function function(ev) {..} ) that's because

ssh - Git: Insufficient permission for adding object, chown doesn't resolve -

distinct this question because question addresses shared git remote, whereas issue privately held one. i'm not regular user, answer seems work people plain mystifying me. when attempt execute git push foo master i following result: counting objects: 18, done. compressing objects: 100% (18/18), done. writing objects: 100% (18/18) 14.71 kib, done. total 18 (delta 5), reused 0 (delta 0) remote: error: insufficient permission adding object repository database ./objects remote: fatal: failed write object error: unpack failed: unpack-objects abnormal exit i followed these instructions , achieved nothing. don't understand what's being said in the checked answer here . i've never had issue before today. made sure git repository i'm remoting created normal server user rather root, , user has super-user permissions; it's evident me of what's being suggested beyond limited knowledge, , don't want ruin trying don't understand, answer explains in de

sql server - Encrypted Password corruption - some saved as encrypted, some not encrypted, some not saved -

i'm programming legacy coldfusion application uses 2008 sql server database. know little how sql server database set up, i'm hoping if share of symptoms, might have suggestions check. the database uses symmetric key secure users passwords. have users table username, password, etc. fields. password encrypted. most legacy users in database work correctly. users can login using website, change passwords, etc. without issues. records used testing, i've changed passwords sql in sql server, not through website: "update users set password = "fluffy" userid in (6543, 7654, 8765)" etc. when i've done that, few things happen: i can never log website first time using userid 6543 , password "fluffy" -- works second time. when run stored procedure exec get_user_unencrypt_by_id 6543 , results return "null" password. when run query select * users see expected symbols/gibberish in of password fields, users 6543, 7654, , 8765, s

string - How do I use a phrase with php in a mongo text search? -

i've got simple mongo query returns result want - db.properties.findone({$text:{$search:'\"eiffel petit louvre\"'}}) however can't seem transpose same query php - $searchstring = '\"eiffel petit louvre\"'; $hotel = $db->properties->findone( array('$text' => array('$search' => $searchstring)) ); this doesn't give me results back. doing wrong? i'm guessing it's string. i've tried escaping backslashes (i don't think should need since string uses single quotes), didn't work. hi had exact same problem. after long trial , error figured out following works: array('$text'=>array('$search'=>"\"$searchstring\""))

javascript - Firefox Add-on SDK: communicating objects between a sidebar and the main script -

i hacking away @ first addon, problem running has either obvious solution or general approach flawed. i using add-on sdk . lib/main.js contains object foo . data directory has files sidebar.html , sidebar.js . want pass foo sidebar-script , change sidebar depending on state of foo . in minmal example try display object. minimal example: main.js : var foo = {"a": "b", "c": "d"}; var bar = require("sdk/ui/sidebar").sidebar({ id: "sb", title: "foobar", url: "./sidebar.html" }); bar.show(); sidebar.html : <!doctype html> <html> <body> <div id="foo-here"> <!-- modified sidebar.js --> </div> </body> <script type="text/javascript" src="sidebar.js"></script> </html> sidebar.js : var foodiv = document.getelementbyid("foo-here"); var st

python - How can i speed up this django orm generated query? -

i have movie table , genre table , moviegenre table genres movie has. the django orm came query when i'm trying movies have @ least of genres target movie has in common. select "movies_movie"."id", "movies_movie"."imdb_id", ..etc.. "movies_movie"."last_ingested_on", count("movies_movie"."id") "count", count("movies_moviegenre"."genre_id") "genres_count" "movies_movie" left outer join "movies_moviegenre" on ( "movies_movie"."id" = "movies_moviegenre"."movie_id" ) inner join "movies_moviegenre" t4 on ( "movies_movie"."id" = t4."movie_id" ) inner join "movies_moviegenre" t6 on ( "movies_movie"."id" = t6."movie_id" ) ("movies_movie"."last_ingested_on" not null , not ("movies_movie".&q

winapi - IsClipboardFormatAvailable returns true but GetClipboardData returns NULL even when text on clipboard -

this problem see in vim hoping can provide advice on (with google code shutdown, cannot submit bug reports vim). on x64 windows 8.1 (it works fine on x64 windows 7) vim/gvim works fine windows clipboard until launch web browser (chrome, firefox, opera, ie). when browser running, vim can place text on clipboard cannot text clipboard. when web browser closed, clipboard starts working again. i have tracked problem down isclipboardformatavailable(cf_unicodetext) returning non-null getclipboarddata(cf_unicodetext) returning null under these conditions. seems specific how vim using win32 api (probably different calls these) because simple test apps write doing work fine. i have tried running different compatibility settings , running administrator nothing makes difference. behavior same both 32-bit , 64-bit builds created using visual studio 2013 community , 2010 professional. what puzzling official 32-bit build (very old @ point) works fine own build off of exact same tag (o

php - Android - Check if SELECT Statement Return Value in MySQL -

i explain want before getting in codes, have android project, connected mysql database, , have password recovery activity in app, in activity user type email in order log in information, when user click send app check if email exists in database or not, if yes send email , if no notify user. now, in php side every thing works will, wrote query , returns correct values. public function getuname($uemail) { if ($uemail != null) { $data = array(); $sql = "select uname `user` `email`= '" . $uemail . "'"; $result = $this->db->query($sql); while ($row = $result->fetch_array(mysqli_assoc)) { $data[] = $row; } return $this->_jsonencode( $data ); } } i know in php if want check if select statement return value or not write like: if (mysql_num_rows($result) > 0) but in android side? have function: private boolean getuserinfo(string uemail) { string getinfo_url