Posts

Showing posts from January, 2015

c# - MS-Access Query Syntax -

Image
i have background of mysql. working on ms-access c#. tried following sql queries throws exception queries 1: string strsql = "select * employees orderby employeeid desc limit 1;"; oledbdataadapter adapter = new oledbdataadapter(strsql, conn); adapter.fill(dt); string strsql = "select * employees orderby employeeid asc limit 1;"; oledbdataadapter adapter = new oledbdataadapter(strsql, conn); adapter.fill(dt); common exception 1: additional information: syntax error in clause. queries 2: string strsql = "select * employees employeeid = (select min(employeeid) employees employeeid < '" + int64.parse(this.txtboxid.text) + "');"; oledbdataadapter adapter = new oledbdataadapter(strsql, conn); adapter.fill(dt); string strsql = "select * employees employeeid = (select min(employeeid) employees employeeid > '" + int64.parse(this.txtboxid.text) + "');"; oledbdataadapter adapter = new oledbdataadap

d - Writing functions conforming template defined function prototypes -

to sheer delight discovered d has made progress , runs on windows 64 bit. has visual studio integration seems work far can see after few hours of playing new toy. so, started play d language , bloody newbie in d. in code below goal define function prototypes in template , write functions sub-functions of main() conform prototypes. compiler complains , right cannot find out how right (probably simple syntax problem). the compiler errors are: main.d(90): error: function main.actor!(int, int).worker (duration timeout, bool function(int) timeouthandler, bool function(int, int) messagehandler, int context) not callable using argument types () main.d(90): error: function main.main.w1ontimeout (int context) not callable using argument types () main.d(90): error: function main.main.w1onmessage (int context, int message) not callable using argument types () building debug\consoleapp1.exe failed! import std.stdio; import core.time; import std.socket; import st

python - PyStruct - No matching signature find -

i'm trying use code here: https://github.com/pystruct/pystruct/blob/master/examples/multi_label.py i have x_train shape (2591, 256) , y_train shape (2591, 175) . when run this: tree = chow_liu_tree(y_train) tree_model = multilabelclf(edges=tree, inference_method="max-product") tree_ssvm = oneslackssvm(tree_model, inference_cache=50, c=.1, tol=0.01) print("fitting tree model...") tree_ssvm.fit(x_train, y_train) i got this: traceback (most recent call last): file "classifiers.py", line 173, in <module> tree_ssvm.fit(x_train, y_train) file "/usr/local/lib/python2.7/dist-packages/pystruct/learners/one_slack_ssvm.py", line 448, in fit x, y, joint_feature_gt, constraints) file "/usr/local/lib/python2.7/dist-packages/pystruct/learners/one_slack_ssvm.py", line 348, in _find_new_constraint x, y, self.w, relaxed=true) file "/usr/local/lib/python2.7/dist-packages/pystruct/models/base.py", line 9

Replace strings in php -

i have string consists of tags <p> </p> , want replace them <br /> , whenever try using str_replace() not so. is there solution it? other possible way it? $string="<p> 1 para </p> <p> second </p>"; using: str_replace("</p> <p>","<br />",$string> nothing gets replaced. are looking this? <?php $string = "<p> 1 para </p> <p> second </p>"; $searcharray = array( '<p>' , '</p>' ); $replacearray = array( '' , '<br />' ); var_dump( str_replace($searcharray, $replacearray, $string) ); ?> output string(47) " 1 para <br /> second <br />"

c++ - Boost Build: Use a feature or a variable -

i have db integration test i'm running using boost build. test needs commandline args (db username, password). what's best way set via boost build in way that's configurable user (via environment variables, bjam commandline, user-config.jam)? i know can variables: import os ; local db_pass = [ os.environ db_pass ] ; run dbtest : test.cpp : --dbpass $(db_pass) ; this can set via commandline ( bjam -s db_pass=pass ) or via environment variable. on other hand, boost build tends of configuration via feature mechanism. define new feature , configuration data right place way. what's pros , cons of each approach? 1 should take? if features: how that? nb: actual test within jamfile that's used jamroot, not directly in root file. i use suggestion of variables. provide great deal of flexibility. don't see how "feature" in case things.

How to create a layout like Twitter profile page in Android -

Image
i developping app has page there must header followed multiple recycler views within viewpager. however, not know how "hide" header when scrolling down. the following layout not work : - recyclerview - header - slidingtablayout - viewpager - recyclerview because verticaly scrollable view cannot put inside verticaly scollable view. possible create type of layout in way because twitter did : so how 1 achieve create type of layout? theorical solution suggestion if had layout : - linearlayout - header - slidingtablayout - viewpager - recyclerview and when recyclerview scrolled, move manually every element upwards header progressively "hidden" , viewpager higher, work? because verticaly scrollable view cannot put inside verticaly scollable view that not true, can put scrollable view scrollable view. hard manage scrolling events , of times not necesseary. should not nest scrollable views. howe

python - How to make two classes sharing a same attribute? -

i have defined class posseses attribute score matrix. let's var instance of class. i have class needs access 1 particular cell of matrix var.score . : class myclass: def __init__(self, r, c): self.cell = var.score[r][c] ... # make operations on self.cell except if self.cell modified, modification should reflect on var.score[r][c] . goal of creating self.cell , not using var.score[r][c] clarity , avoiding dragging r , c along following definition of class. i've seen solutions using wrapper mutable objects list didn't satisfied me. best solution implement ? you use property: class foo(object): def __init__(self, r, c): self.r = r self.c = c @property def cell(self): return var[self.r][self.c] @cell.setter def cell(self, val): var[self.r][self.c] = val then: >>> var = [[1, 2], [3, 4]] >>> x = foo(0, 1) >>> x.cell 2 >>> x.cell = 8 >&

php - Need information about file safety -

hello stackoverflow community! i've got question website security! i'm new in creating tvs want ask include file stuff. let's say, i've got index.php file has: include_once 'style/header.php'; , file header.php contains: <html> <head> <title>some title!</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <link href="css/style.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" /> </head> <body> so if 1 try directly access header.php see html tags. how can block access included file or encrypt them? o

sqlite - UPDATE Query not Working with Android App -

i writing android app needs execute update query on sqlite database, reason, query not having effect when run it. here's function supposed execute query. public void query() { try { cursor = this.db.rawquery("update data set saved=1 number=1", null); } catch(sqliteexception e) { system.out.println("database query failed: " + e.getcause().getmessage()); } } although query not work, not output catch clause, , adding additional catch check exception not output either. what's problem? how can update queries work? have not tried executing insert query, need later on. have similar issues queries write database? use execsql() , not rawquery() run sql. rawquery() compiles sql not run it. execsql() both compiles , runs sql.

mysql - php pagination, something is wrong -

i found tutorial according pagination. http://papermashup.com/easy-php-pagination/ i tried code , work. every time first index reload(first result in pagination). i got message. notice: undefined index: page in c:\xampp\htdocs\sim\registrar\index.php on line 207 how can remove message? here's code.. $targetpage = "index.php"; $limit = 3; $query = "select count(*) num advisoryclass"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_get['page']);//this part if($page){ $start = ($page - 1) * $limit; }else{ $start = 0; } thanks you're assuming page set when that's not going case; hence error. change this: $page = mysql_escape_string($_get['page']);//this part to: $page = ( isset( $_get['page'] ) ) ? mysql_escape_string( $_get['page'] ) : 1; in code above we're checking page $_

meteor - Does FeathersJS use the Mongo Oplog for "live data" (when Mongodb is the database) -

Image
the documentation not clear mechanism used. can find references pub/sub using special collection in mongo. if case possible issue in more mixed environments when example data collected other services using php or like. feathers real-time functionality added @ service level. database independent , real-time mechanism works backend real-time updates has go through feathers rest or websocket api. long e.g. php backend talks feathers rest api clients real-time updates. if put directly in database won't. a example graphic made illustrate how make existing api real-time. feathers services proxies requests clients connected via websockets real-time updates:

javascript - AngularJS ui view autoscroll not working -

i'm using angular's ui-router having problem when click on new view, page doesn't start @ top was. set autoscroll true in ui-view others suggested still isn't working. i'm not sure reason not working. <ui-view autoscroll="true" /> the default option true, maybe there's preventing autoscroll firing, need more code. can make custom code that'll work. this $scope.$on('$routechangesuccess', function () { window.scrollto(0, 0); });

r - how to Create Histogram for one variable, using another to determine its frequency? -

Image
i'm new r, , using histograms first time. need construct histogram chart show frequency of income 50 united states + district of columbia. this data given me: > data x.income. x.no.states. 1 -22.024 5 2 -25.027 13 3 -28.030 16 4 -31.033 9 5 -34.036 4 6 -37.039 2 7 -40.042 2 > hist(data$x.income, col="red") but produces histogram of number of frequency each income amount appears in graph, not number of states have level of income. how account number of states have each level of income in chart? use bar plot instead of histogram, histogram expects calculate frequencies you: library(ggplot2) # make data exercise income = c(-22.024, -25.027, -28.030, -31.033, -34.036, -37.039,-40.042) freq = c(5,13,16,9,4,2,2) df <- data.frame(income, freq) df <- names(c("income","freq")) # graph object p <- ggplot(data=df) + aes(x=income, y

PHP PDO mySQL query returns column name instead of value -

this question has answer here: can use pdo prepared statement bind identifier (a table or field name) or syntax keyword? 1 answer i'm setting web application has multiple user roles determine view specific user gets when visiting specific sections (or whether sections available them). have table ("users") includes columns "username" , "role". have second table ("roles") has columns "role" column each section, each having multiple possible values drive user experience each role. column i'm concerned here call "useradminview", have same issue other columns. i have no problem obtaining given user's role when login. when attempt useradmin view associated role, query returns column name rather expected value. i've found several posts on stackoverflow , other sites same symptom, queries setup d

c++ - Error when calling an Integral template member function with g++ and clang++ -

this question has answer here: where , why have put “template” , “typename” keywords? 5 answers i'm stuck on compilation error, can't identify... here's minimal working example: #include <iostream> template <typename t, int r> class a_type { public: template <int n> double segment() { return 42; } }; template <int m> double func() { a_type<double, m> a; return a.segment<1>(); } int main(int argc, char *argv[]) { std::cout << func<10>() << std::endl; return 0; } the error message gcc reads: g++ main.cpp -o main main.cpp: in function 'double func()': main.cpp:18:26: error: expected primary-expression before ')' token return a.segment<1>(); ^ main.cpp: in instantiation of 'double func(

javascript - how do i call vast tag in every 10 minutes? -

i trying implement vast tag video player on client web site..i need call vast tag every 10 minutes...can 1 know,which codes need implement/put current codes... my code follows: <script src="http://jwpsrv.com/library/ddkxavrleek6qxixoucpzg.js"></script> <div id="container">&nbsp;</div> <script> var playerinstance = jwplayer("container"); playerinstance.setup({ image: "http://demo.jwplayer.com.s3.amazonaws.com/advertising/assets/adpod.jpg", file: "http://content.jwplatform.com/videos/s8bpzde0-knspjqnj.mp4", advertising: { client:"vast", schedule:{ adbreak1: { offset:'pre', tag: 'http://demo.jwplayer.com/advertising/assets/vast3_jw_ads.xml' } } } }); </script> thank you

winapi - How to edit pixels in a wndproc window c++? -

i have window in c++ made wndproc function. how edit pixels of screen in case wm_paint: { hdc hdc; paintstruct ps; hdc = beginpaint( hwnd, &ps ); // ????? endpaint( hwnd, &ps ); } when wm_paint message pixels gone, and/or calling beginpaint causes pixels erased. painting code needs paint whole window. if merely changing few pixels can use in-memory bitmap, change few pixels within (setpixel 1 way), bitblt screen repaint whole window.

php - How to do a SUM subquery within a left join query? -

so have data: table 'group_info': identifier name 123 group 124 group b table: 'group_participants': id group_id privilege 1 123 admin 2 123 user 3 124 admin i want number of people 'user' or 'admin' , number of people 'admin', along group identifier , name, groups user id 1 member of. e.g. in case above return 123, 'group a', 2 users , 1 admin. i'm trying in single query can't quite final part. have far: select group_info.identifier, group_info.name `group_info` left join group_participants on group_participants.group_id = group_info.identifier group_participants.user_id = 1 i'm aware can done in 2 queries, i'd rather @ once. ideas how format subquery achieve this? your question not clear on "user or above" means. answer question use conditional aggregation al

ios - Disable iOS8 Quicktype Keyboard programmatically on UITextView -

Image
i'm trying update app ios8, has chat interface, new quicktype keyboard hides text view, turn off programmatically or in interface builder. is possible somehow or users can turn off in device settings? i know there question/answer solves problem uitextfield , need uitextview . you may disable keyboard suggestions / autocomplete / quicktype uitextview can block text on smaller screens 4s shown in example with following line: mytextview.autocorrectiontype = uitextautocorrectiontypeno; and further if youd on specific screen such targeting 4s if([[uidevice currentdevice]userinterfaceidiom] == uiuserinterfaceidiomphone) { cgfloat screenheight = [uiscreen mainscreen].bounds.size.height; if (screenheight == 568) { // iphone 5 screen } else if (screenheight < 568) { // smaller iphone 5 screen 4s } }

java - Null Pointer Exception for Default Shared Preference Manager -

sometimes when call edit on default shared preferences, nullpointerexception. know why is? below code , error. sharedpreferences sharedpreferencesfinish = preferencemanager.getdefaultsharedpreferences(getactivity()); sharedpreferences.editor spef = sharedpreferencesfinish.edit(); java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.string android.content.context.getpackagename()' on null object reference

Fresh ELK Install on Ubuntu 14.04, Kibana returns Connection Refused -

new server running ubuntu 14.04 server. fresh install of elk stack today. check elastic search spyder on home ubuntu machine. result (using python's requests package): res = requests.get('http://' + falcon618 + ':' + port) print(res.content) { "status" : 200, "name" : "six of nine", "cluster_name" : "{my cluster name}", "version" : { "number" : "1.4.4", "build_hash" : "c88f77ffc81301dfa9dfd81ca2232f09588bd512", "build_timestamp" : "2015-02-19t13:05:36z", "build_snapshot" : false, "lucene_version" : "4.10.3" }, "tagline" : "you know, search" } however, when go server_ip:5601 via chrome connection refused. when ask ubuntu kibana's status says running. when @ netstat -lnp there entry (listening) port 9200 (elaticsearch) no entry port 5601. i have searched

java - I add two numbers with the same way but get different values -

the following code , extremely confused results get. byte[] bytes = new byte[2]; bytes[0] = (byte)0xe6; bytes[1] = (byte)0x1b; int high = (bytes[1] & 0xff)*256; int low = bytes[0] & 0xff; double j = high + low; double = (bytes[1] & 0xff)*256 + bytes[0] & 0xff; system.out.println(bytes[1] & 0xff); system.out.println(bytes[0] & 0xff); system.out.println((bytes[1] & 0xff)*256); system.out.println(i); system.out.println(j); logically, i , j same result quite amazing. results: 27 230 6912 230.0 7142.0 i , j should same isn't. don't know reason. there explanation this? they aren't equivalent; in java, the bitwise & operator has lower precedence + operator . i being defined ((bytes[1] & 0xff)*256 + bytes[0])& 0xff , evaluates 230, instead of intended 7142. replacing line i = (bytes[1] & 0xff)*256 + (bytes[0] & 0xff); need do.

ios - exc_arithmetic error with simulator only, assigning UICollectionView flowlayout -

im trying assign uicollectionviewflowlayout uicollectionview , runs fine on physical device simulators break, signal: exc_arithmetic(code=exc_i386_div, subcode=0x0) this happens on simulator, understanding division 0 error, dont see how thats possible implementation code: let flowlayout: uicollectionviewflowlayout = uicollectionviewflowlayout() flowlayout.itemsize = cgsizemake(self.view.bounds.width * 0.67, self.collectionview!.frame.height - 10) flowlayout.scrolldirection = uicollectionviewscrolldirection.horizontal self.collectionview!.collectionviewlayout = flowlayout furthermore, signal @ line: self.collectionview!.collectionviewlayout = flowlayout and view bounds : width: 277.38 height: 75.0 any help, or alternatives appreciated! i got exact same issue on old code working on , appears calling code wrong method. moved in more appropriate place, viewdidload or init , works.

python - Unique slugs to user -

using python library awesome-slugify creating slugs so: unique_slug = uniqueslugify() text = 'this text' slug = unique_slug(text) # prints 'this-is-some-text' the value of slug gets added database after it's created. if want create slug same value this-is-some-text-1 . as application lets users create slugs, if 1 user create slug value some text some-text . if user create slug same value some-text-1 . if many users have same value number increase , increase. i slugs unique user: user creates slug unique_slug('hello world') # 'hello-world' user b creates slug unique_slug('hello world') # 'hello-world' user b creates slug unique_slug('hello world') # 'hello-world-1' user c creates slug unique_slug('hello world') # 'hello-world' as see slug unique user. doesn't matter if different users share same slug user cannot have same ones. how go preferably using awesome-slugify or slug

java - Change font of a part of a JLabel? -

Image
i want change only first 2 words of jlabel different font rest of jlabel. have found make jpanel, , have 2 jlabels different fonts in it. cannot use way, because can have 1 jlabel (this since have mouse listener changes text of jlabel based on entrance or exit of different other jlabels, in seperate jpanel). there way? have tried (adding jlabel side side jlabel): jlabel giraffesays = new jlabel("giraffe says:"); giraffesays.setfont(new font("timesroman", font.bold, 60)); status.settext(giraffesays +"hi!"); //status jlabel but didn't work. tried making string: string giraffesays = "giraffe says: giraffesays.setfont(new font("timesroman", font.bold, 60)); status.settext(giraffesays +"hi!"); //status jlabel but cannot change font of string... try using html string jlabel : import javax.swing.swingutilities; import javax.swing.jframe; import javax.swing.jlabel; public clas

Load url web view android - Java -

i have webview in app , got working this webview = (webview) findviewbyid(r.id.mainwebview); webview.loadurl("https://www.google.com"); but if try load non mobile version of https://uniondining.sodexomyway.com/images/mar2015dutchcalendar_000_tcm1792-59025.pdf exits out of app. how can load mobile version of site in app? thanks unfortunately, android not support viewing pdfs out of box in webview. luckily, google has nifty little tool allows perform task quite using google docs. embed our pdf in google doc page on-the-fly , load that. you can use google docs viewer read pdf online: here's code: webview webview = (webview) findviewbyid(r.id.webview); webview.getsettings().setjavascriptenabled(true); string pdf = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf"; webview.loadurl("http://docs.google.com/gview?embedded=true&url=" + pdf); if use view url user not propted login there google account.

c++ - Visual Studio 2013 cannot open 'glfw3.lib' -

i'm having few issues getting glfw3 set up. i've downloaded 64-bit binaries official site, added glfw3.dll, glfw3.lib , glfw3.h respective places, specified proper include, , added appropriate linker input project. however, when test library glfwinit() , vs spits out: error lnk1104: cannot open file 'glfw3.lib' path/to/project my guess vs didn't know directory library in, seeing it's in ide's own lib folder, don't think it. have suggestions? sorry if has been solved, got in deep read steps of compilation before gave searching. edit: changed solution platform x64, since using 64-bit glfw binaries. following andon m. coleman's advice, moved headers , library folders new directory outside of visual studio's built-in ones (d:\opengl-wrappers\lib & d:\opengl-wrappers\include, example). after including libraries in project settings (c/c++->general-> additional include directories , linker->general->additional libr

c# - Make my counter score save highest score even after app closes -

so making rocket app, still development. wrote code counts score when collide objects. how make saves highest score , can display it? leave scene sets score 0 :( please thank you! using unityengine; using unityengine.ui; using system.collections; public class points1 : monobehaviour { public text counttext; public text wintext; private rigidbody rb; private int count; void start() { rb = getcomponent<rigidbody>(); count = 0; setcounttext(); wintext.text = ""; } void ontriggerenter(collider other) { if (other.gameobject.comparetag("pickup")) { other.gameobject.setactive(false); count = count + 100; setcounttext(); } if (other.gameobject.comparetag("minus300")) { other.gameobject.setactive(false); count = count -300; setcounttext(); } } void setcounttext() { counttext.text = "score: " + count.tostring(); if (count >= 5000)

javascript - Image Slider that opens images from different folders on different button click -

i have image slider opens different images same folder(named images 1.jpg,2.jpg in folder img1 ). possible if can have buttons below image slider gives me sliding images different folders(1.jpg,2.jpg folder img2 ; 1.jpg,2.jpg folder img3 ) <div id="slider"> <img src="img/1.jpg" alt="slide 1" /> <img data-src="img/2.jpg" alt="slide 2" /> <img data-src="img/3.jpg" alt="slide 3" /> <img data-src="img/4.jpg" alt="slide 4" /> </div><button>images new folder</button> i'm guessing using library/code displays image in data-src . can change 'data-src' (or images' src ) attribute dynamically , change path using. it depends on implementation since lib might cache data-src on initialization , ignore changes it.. anyway, how can (i'm using src in example can change data-src well): var gallery =

ios - Is it okay to solicit bug reports? -

i've noticed instagram , other apps allow users report problems don't let people report "bugs". since guess premise of apple review process catch bugs , there no bugs in ios apps, makes sense not use word. however, apple reject app if use word "bugs"? coming web background okay launch beta, honest users rather politically correct if possible. the reason want let them report bugs not catch them hope launch bug-free if has problem let them report rather write bad review. would appreciate guidance. thank you. apple review guideline ; 2. functionality 2.2 apps exhibit bugs rejected i don't think means have filter on word 'bug'. may find bug tracking apps available on app store used word doesn't make sense of rejection because of report bugs section in app. but @ time of apple review, if find bug, reject app may fix it. need sharp @ app should not have permanent bug or issue. for confirmation may contact a

perl - How to modify content of a file using single file handle -

i'm trying modify content of file using perl. the following script works fine. #!/usr/bin/perl use strict; use warnings; open(fh,"test.txt") || die "not able open test.txt $!"; open(fh2,">","test_new.txt")|| die "not able opne test_new.txt $!"; while(my $line = <fh>) { $line =~ s/perl/python/i; print fh2 $line; } close(fh); close(fh2); the content of test.txt : im learning perl im in file handlers chapter the output in test_new.txt : im learning python im in file handlers chapter if try use same file handle modifying content of file, i'm not getting expected output. following script attempts this: #!/usr/bin/perl use strict; use warnings; open(fh,"+<","test.txt") || die "not able open test.txt $!"; while(my $line = <fh>) { $line =~ s/perl/python/i; print fh $line; } close(fh); incorrect output in test.txt : im learning p

parse.com - Parse setting explicit type using REST -

i know can set date field explicitly so: "date_brewed":{ "__type":"date", "iso":"2009-10-15t00:00:00.000z" } but there anyway explicitly set column type of 'number' using rest? instance, i'd set column 'batch_size' number instead of string when post'ing via rest keeps getting created string type column. meh, more of perl issue parse issue. what had tell perl treat number actual number add 0 value. :/

Loading data to vector rather than cell in MATlab -

i load data text files matlab function using code: data = cell(h.numdirs, numdatafilesinfirstdir); d = 1:h.numdirs % code set filenames, idir t = 1:size(filenames,1) fid = fopen([idir, '/', filenames{t}]); % drop first 2 lines (column headers) skip = 1:2 fgets(fid); end u_temp = fscanf(fid, '%f %f', [2, inf]); u_temp = u_temp'; % ' transpose (syntax highlighting on so) data(d, t) = {u_temp(:,2)}; fclose(fid); end end the files should each have same length (at least varying t , varying d or else have problems later) should (/ how can i) simplify code here avoid (unnecessary?) cells? i scan first data set, use data = zeros(h.numdirs, numdatafilesinfirstdir, lengthoffirstfile) but don't know if better. 'better' solution/method? i use dlmread instead of fscanf . data type hard since dimensions vary. wouldn't pad arrays... benefit not usi

javascript - Jquery: setTimeout Timer and Corresponding High Score List Do Not Match -

this seems simple problem, can't seem find posts similar issue. i've written basic timer in jquery , starts , stops click of 2 buttons, , time @ stops passed high score list appears after. appears on high score list 0.01 seconds lower number on timer. there settimeout method cause this, or missing something? fiddle here: https://jsfiddle.net/nbsteuv/j9otp5ya/ here's code i'm using timer: function timer(){ if(starttimer=="true"){ settimeout(function(){ i=i+0.01; $(".timer").html("<h1><center>"+ i.tofixed(2) + "</center></h1>"); timer(); },10); }; }; and here's code updates high score list: $(".stopbutton").click(function(){ if(starttimer== "true"){ starttimer= "false"; updatescores(i); darken(".space"); }; });

vb.net - How to insert data into SQL Server database and retrieve it and put into datagridview? -

what want is, after insert data sql server database, datagridview retrieve added data database , add in row. i'm new vb.net code in dialog add form. name dlgadd imports system.windows.forms imports system.data.sqlclient public class dlgadd dim constr string = "data source=server008;initial catalog=collectiondb;persist security info=true;user id=sa;password=p@ssw0rd1234" dim sql string dim sqlcon new sqlconnection dim sqlcmd new sqlcommand private sub ok_button_click(byval sender system.object, byval e system.eventargs) handles ok_button.click sql = "insert datacollection(customername,or_no,sor_no,balance,cash_amount,check_amount) values('" & txtname.text & "','" & txtor.text & "','" & txtsor.text & "','" & txtbalance.text & "','" & txtcash.text & "','" & txtcheck.text & "'

javascript - swapping pairs in arrays recursively -

trying swap pairs in array recursively, managed iteratively. how implement swap part recursively? think have of correct! if there odd number, last 1 stays same. don't want have helper swap function if possible. pairswap = function(arr) { var newarray = [] (var = 0; < arr.length; += 2) { var current = arr[i]; var next = arr[i + 1] if (next !== undefined) { newarray.push(next) } if (current !== undefined) { newarray.push(current) }; }; return newarray; } console.log(pairswap([1, 2, 3, 4, 5])) pairswaprecursive = function(arr) { if (arr.length < 2) { return arr; } else { //swap first , second: return (swap ? ) + pairswaprecursive(arr.slice(2)) } } console.log(pairswaprecursive([1, 2, 3, 4, 5])) //should return [2, 1, 4, 3, 5] //something similar in java: // public string swappairs(string s) { // if (

javascript - jquery scroll to element then lock to that element regardless of changes on window size -

i'm trying use jquery scroll specific element inside of wrapping element. works intended work, long screen width isn't resized. screen width changes, scroll doesn't stick. here current code: javascript function pageinit(pageid) { $('.page-wrapper').animate({ scrollleft: $('#' + pageid).offset().left }, 500); $('#' + pageid).css('postion', 'fixed'); console.debug('page #' + pageid + ' initiated.'); } pageinit('about'); html <div class="page-wrapper"> <div class="page main-page" id="root" data-pos="0"> <div class="group-container"> <div class="book"></div> <div class="promo"> <div class="button"> <a href="/about"> <div class="button-logo cover-button-logo"></div>

r - How to plot multiple variogram plots with different title using loop/lapply function? -

i have csv file contains hourly pm10 concentration of 1 march 7 march. please, download here. have plotted variogram (total 161) in loop automap package. library(sp) library(gstat) library(rgdal) library(automap) library(latticeextra) seoul1to7<-read.csv("seoul1to7.csv") seoul1to7[seoul1to7==0] <-na seoul1to7 <- na.omit(seoul1to7) seoul1to7_split<-split(seoul1to7,seoul1to7$time) seq(seoul1to7_split) vars<-lapply(seq(seoul1to7_split), function(i) { dat<-seoul1to7_split[[i]] coordinates(dat)<-~lon+lat proj4string(dat) <- "+proj=longlat +datum=wgs84" dat <- sptransform(dat, crs("+proj=utm +north +zone=52 +datum=wgs84")) variogram<-autofitvariogram(log(pm10)~1,dat, model="sph") plot<- plot(variogram,plotit=false, asp=1) return(plot) }) vars[[1]] vars[[2]] here, can individual plot vars[[1]],vars[[2]]... etc variogram has same title. now, want plot variogram image different title in loop

how to show text in lower case in android? -

i try implement tabs in android .i able implement tab in android android text display in capital .i don’t want show tab text in capital letter . can show text in same format given in code here manifest file <resources> <!-- base application theme. --> <style name="apptheme" parent="android:theme.holo"> <!-- customize theme here. --> <item name="android:textappearance">?android:attr/textappearancesmall</item> <item name="android:textallcaps">false</item> </style> </resources> manifest file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.naveen.tabsfavourite" > <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label=&quo

apache spark - Why does reading csv file with empty values lead to IndexOutOfBoundException? -

i have csv file foll struct name | val1 | val2 | val3 | val4 | val5 john 1 2 joe 1 2 david 1 2 10 11 i able load rdd fine. tried create schema , dataframe , indexoutofbound error. code ... val rowrdd = filerdd.map(p => row(p(0), p(1), p(2), p(3), p(4), p(5), p(6) ) when tried perform action on rowrdd , gives error. any appreciated. this not answer question. may solve problem. from question see trying create dataframe csv. creating dataframe using csv can done using spark-csv package with spark-csv below scala code can used read csv val df = sqlcontext.read.format("com.databricks.spark.csv").option("header", "true").load(csvfilepath) for sample data got following result +-----+----+----+----+----+----+ | name|val1|val2|val3|val4|val5| +-----+----+----+----+----+----+ | john| 1| 2| | | | | joe| 1| 2| | | | |david| 1| 2| | 10| 11| +-----+----

Converting list of lists to numpy array with multiple data types -

i have list of lists i've read file. each of inner lists 6 elements in length, , has 3 strings , 5 floats. how convert list of lists numpy array? thanks! you want structured array, 1 has compound dtype : a sample list of lists: in [4]: ll = [['one','two',1,1.23],['four','five',4,34.3],['six','seven',4,34.3]] trying make regular array, produces array of strings: in [5]: np.array(ll) out[5]: array([['one', 'two', '1', '1.23'], ['four', 'five', '4', '34.3'], ['six', 'seven', '4', '34.3']], dtype='|s5') but if specify dtype contains 2 strings, , int , float, 1d structured array: in [8]: np.array([tuple(x) x in ll],dtype='s5,s5,i,f') out[8]: array([('one', 'two', 1, 1.2300000190734863), ('four', 'five', 4, 34.29999923706055), ('s

javascript - Why is the IP address different between mobile devices and desktop/laptop? -

i'm having 2 different ip address connecting on same wifi connection. laptop/desktop: 58.110.xxx.xxx ipad/android phone: 66.249.xx.xxx this difference causes country detection rendered incorrectly between laptop , mobile devices. use geo php (maxmind) that's based on ip address. any appreciated. thanks. i might have figured out issue. using chrome in ipad , android phone "reduce data usage" feature enabled. in case, traffics tunneling through google servers reduce data size. therefore, other web servers detecting usa (google servers) instead of direct connection australia. if disable "reduce data usage", should direct connection australia anywhere instead. please use http://ipaddress.my test ip address , isp confirmation.

iframe - Run wordpress plugin on Joomla based website -

i have question related wordpress<>joomla compatibility. purchased sophisticated plugin runs on wordpress only. website content , design based on joomla. i'm trying figure out means how use wordpress plugin on joomla website. said before it's kind of advanced plugin many options, guess difficult adapt code fit joomla requirements. i'm thinking 2 possible solutions: i create wordpress website same design joomla website has. solution requires change joomla template files, or build wordpress theme scratch. know tutorial explains how migrate template joomla wordpress? don't need move content, design. menu links , other stuff redirect parent joomla site. the second solution think install wordpress plugin on server , create copy of joomla site on sub-domain. maybe can use iframe on joomla site show wordpress plugin running. kind of scenario possible? kind of solution suggest? said before, keep joomla site anyway, because running tons of data. need functionality

sql server 2008 - Refresh Front-End on Data Change in Database by Other User in C# -

i using c# front end multiple users, connected sql server 2008. question is: if 1 user changes data using update operation, how can other user see impact of update statement without using select * command or sda.fill ? i have thousands of records in table takes time on refill. here code using update data. myglobalvariables.bsinc.endedit(); myglobalvariables.con.open(); myglobalvariables.cmdstring = "update increment set incamount=" + convert.toint32(txtinc.text) + ", editedby='"+myglobalvariables.myuname+"', editedon=sysdatetime() incyear=" + convert.toint16(cmbincyear.text) + " , empcode='" + myglobalvariables.myempcode + "'"; myglobalvariables.cmd = new sqlcommand(myglobalvariables.cmdstring, myglobalvariables.con); myglobalvariables.cmd.executenonquery(); myglobalvariables.con.close(); myglobalvariables.ds.tables["increment"].rows[myglobalvariables.bsinc.position].acceptchanges(); myglobalvariable

Is it possible to get the last google search query made by the user through chrome extension? -

i trying build functionality based on user's google search query. not interested in particular link visited user after search, query used user. there way can retrieve it? there suggestions find last google search url in history add contentscript google search page record search keyword. use webrequest listen search request, record keyword. visit https://history.google.com/history don't know if there api this.

javascript - Promise middleware in node js callback functions how to use multiple then? -

am newby in node js, using promise middleware in node js. didn't find documentation useful me , unable understand how use 2 callbacks in 1 request or how should use multiple then. please me thanks. here code //get application types var p1 = new promise(function(resolve, reject) { console.log("in p1"); var url = turl+'applicationtype/getall' var args = { headers:{"authkey": req.session.name} }; client.get(url, args, function(data,response) { console.log(data, "in app type req"); if(data.status == "success"){ return resolve(data); } else{ reject ("unamble data!") } }); }); p1.then(function(data) { console.log(data.response.applicationtype, "in p1 then", data) //load page after data res.render('app', { message: req.session.name, uname: "the mechanic", applist: data.response.applicationtype }); },function(reas

android - Data of ListView keeps changing on scroll -

data of listview keeps changing on scrolling listview , down. seems wrong adapter. below code have used adapter. have 2 buttons in listview item, accept , reject request.if request either accepted or rejected 1 button appear.if request pending i.e p, both buttons displayed public view getview(int position, view convertview_, viewgroup parent) { // todo auto-generated method stub viewholder view ; system.out.println("getview " + position + " " + convertview_); if (convertview_ == null) { convertview_ = inflator.inflate(r.layout.received_list_row, null); view = new viewholder(); view.imageviewpage = (imageview) convertview_ .findviewbyid(r.id.received_postimage); view.postimagebg = (imageview) convertview_ .findviewbyid(r.id.received_postimagebg); view.txt_post_title = (ctextview) convertview_ .findviewbyid(r.id.received_txt_post_title); view.txt

integration testing - how to write RestTemplate.put() in groovy using Spock -

i writing integration test cases using spock in groovy. using resttemplate call operation example when: string url="http://localhost:$port/user/password" responseentity<responsewrapper<user>> entity=resttemplate.postforentity(url,changepassworddto,responsewrapper.class) then: entity.statuscode == httpstatus.ok entity!=null i have written integration test post , get, when writing put, getting null pointer exception on entity object i have written put, know put operation null, not getting other way this, can please me string url="http://localhost:$port/applicant/{id}/status?blacklistingflag&reason" map.put("id", "23") map.put("blacklistingflag","0") map.put("reason","no reason") resttemplate.exchange(url, httpmethod.put, null, null, map) responseentity<responsewrapper<user>> entity=resttemplate.put(url,responsewrapper.class , map) then

selenium - Python - find element if the previous contains specific type value in xpath -

i struggling find way match element if there previous element contains specific name. let's take example following html: <div> <input type="text" name="name"> </div> <div> <input type="text" name="email"> </div> <div> <input class="bla"> </div> <!-- there might more divs between email / name , button want press--> <div> <button class="something" type="submit"></button> </div> i want click on element of type="submit" (instead of button tag there can anything) if after element contains name="email" or name="name" . to match name , email , complete them values have this: # variables , booleans defined here # (...) driver = webdriver.firefox() lista = [ 'https://rapidevolution.clickfunnels.com/jv-page-2', 'http://listhubpro.com/jv', 'ht