Posts

Showing posts from July, 2010

c++ - Converting QString to std::string -

i've seen several other posts converting qstring std::string, , should simple. somehow i'm getting error. my code compiled vs project using cmake (i'm using vs express), there's no issue qt libraries, , gui wrote works besides part. i have qcombobox cb holds names objects, , qlineedit lineedit allows me specify name of object looking for. should run function tested , working when press go button, input qcombobox , lineedit arguments. here's code when go button clicked: void gui::on_go_clicked(){ std::string str(cb->currenttext().tostdstring()); //std::cout << str << "\n"; //qstring qstr = lineedit->text(); //std::cout<<lineedit->text().tostdstring(); updatedb(str, lineedit->text().tostdstring()); } the first line, creating str , works fine. i.e. there's no problem library functions or tostdstring() . when executes function, program breaks, , it's not becuase of function, it's b

php - Using Regex (or anything) to do an advanced find and replace -

i'm trying find things inside double quotes , replace link using it. have on 500 lines of questions, don't want hand. original php doc snippet: $q2 = array ("what mars earth?", "what mars's position relative earth?"); $q3 = array ("what mars's surface like?", "show me view of surface of mars.", "show me picture of surface of mars."); formatting want: $q2 = array ("<a href="answer.php?query=what+does+mars+look+like+from+earth%3f">what mars earth?</a>", <a href="answer.php?query=what+is+mars's+position+relative+to+earth%3f">"what mars's position relative earth?"); i tried using regex, without previous experience it, unsuccessful. using regexr ( my example ) came find of: "[a-za-z0-9\s.\?']*" , replace of: < href=answer.php?query=$&>$&" this gave results like $q2 = array (<a href=answer.php?query="wh

c# - RavenDB Changes API Time out -

i handling changes in ravendb database code: _documentstore.changes( "databasename" ).foralldocuments() .subscribe( change => { using ( var session = _documentstore.opensession( "databasename" ) ) { var obj = session.load<object>( change.id ); //deal changed object } } ); but reason after period of inactivity (i have not been able measure how long precisely, 15-20 minutes), stops sending updates. don't receive exception, after restarting application, runs fine. there sort of time out need set? or there else might cause this? it bug in ravendb fixed while ago. build running?

c# - How to capture return value for Event handler? -

environment: ms sql server, ef, wcf-ria-service, sliverlight try define event async call complete event like: public event eventhandler<int> mysavecomplete; the event call sp in db , return id value(int). but got error message when try compile code: the type 'int' cannot used type parameter 'teventargs' in generic type or method 'system.eventhandler'. there no boxing conversion 'int' 'system.eventargs' how resolve problem? eventhandler<t> requires generic argument of type eventargs (i.e. 1 inherited it). so, should create own class: public class mysavecompleteeventargs : eventargs { public mysavecompleteeventargs(int id) { id = id; } public int id { get; private set; } } and use eventhandler<t> argument: public event eventhandler<mysavecompleteeventargs> mysavecomplete; event raising: protected void onmysavecomplete(int id) { if (mysavecomplete == n

javascript - showing alert when drag and drop matching is correct with html css js -

i followed tutorial on internet on drag , drop, using js function: function draguser(user, event) { event.datatransfer.setdata('user', user.id); } function dropuser(target, event) { var user = event.datatransfer.getdata('user'); target.appendchild(document.getelementbyid(user)); } and div/id/elements modified this: <div id="unassigned" ondrop="dropuser(this, event)" ondragenter="return false" ondragover="return false"> names: <a draggable="true" class="user" id="banana" ondragstart="draguser(this, event)">banana</a> <a draggable="true" class="user" id="newyork" ondragstart="draguser(this, event)">new york</a> <a draggable="true" class="user" id="london" ondragstart="draguser(this, event)">london</a> <a draggable="true&q

asp.net - How to pass concatenated value of drop down to stored proc as parameter -

i have drop down in values concatenated 2 columns of table, use value of drop down parameter stored procedure, possible? how that? this code create procedure [dbo].[reassign] @recordumber int @employeename begin update qr set qr.qamemberid = @qamemberid roster qr inner join teammaster s tm on qr.qamemberid = tm.qamemberid qr.recordnumber = @recordumber , qr.firstname, qr.lastname = @employeename end and qr.firstname , qr.lastname = @employeename know last piece of code wrong... how can right way? thank you... do not concatenate values in code, rather use parameter firstname , parameter lastname , this: create procedure [dbo].[reassign] @recordumber int, @firstname, @lastname begin update qr set qr.qamemberid = @qamemberid roster qr inner join teammaster s tm on qr.qamemberid = tm.qamemberid qr.recordnumber = @recordumber , qr.firstname = @firstname, qr.lastname = @lastname en

mysql - Get a result by comparing two tables with an identical column -

mysql> select * on_connected; +----+-----------+-------------+---------------------------+---------------------+ | id | extension | destination | call_id | created_at | +----+-----------+-------------+---------------------------+---------------------+ | 11 | 1111111 | 01155555551 | 521243ad953e-965inwuz1gku | 2013-08-19 17:11:53 | +----+-----------+-------------+---------------------------+---------------------+ mysql> select * on_disconnected; +----+-----------+-------------+---------------------------+---------------------+ | id | extension | destination | call_id | created_at | +----+-----------+-------------+---------------------------+---------------------+ | 1 | 1111111 | 01155555551 | 521243ad953e-965inwuz1gku | 2013-08-19 17:11:57 | +----+-----------+-------------+---------------------------+---------------------+ 1 row in set (0.00 sec) there time difference of 4sec between two. calculate difference using

swing - Java Tic Tac Toe GUI -

the code works fine problem want 3 columns , 3 rows.. output shows 6 columns instead of 3 rows , 3 columns here code in problem appears.. here main class: import java.awt.event.actionevent; import java.awt.event.actionlistener; import games.board.board; import games.board.cell; import games.board.mark; import javax.swing.jframe; import javax.swing.swingutilities; public class tictactoeguigame extends jframe { /** * @param args */ private board gb; private int turn; private void taketurn(cell c) { mark curmark = (turn++ % 2 == 0)? mark.nought : mark.cross; gb.setcell(curmark, c.getrow(), c.getcolumn()); } private tictactoeguigame() { gb = new board(3, 3, new actionlistener() { public void actionperformed(actionevent ae) { cell c = (cell) ae.getsource(); taketurn(c); } }); this.add(gb); this.setdefaultcloseoperation(exit_on_close); this.settitle("tic-tac-toe"); this.setsize(300, 300); this.setvisible(t

java - How to parse data from a json list by using Gson? -

now json file data in format: [ [ "name1", "age1", "gender1", url1 ], [ "name2", "age2", "gender2", url2 ], ... ] now want parse , store them in database using gson, don't know how write code it. the list may contains 200,000 small lists, don't know if take lot of memory if use gson.fromjson() whole json list. there dynamic method parse each small list in it? gson 2.1 introduced new typeadapter interface permits mixed tree , streaming serialization , deserialization. api efficient , flexible. see gson's streaming doc example of combining tree , binding modes. strictly better mixed streaming , tree modes; binding don't waste memory building intermediate representation of values. gson has apis recursively skip unwanted value; gson calls skipvalue(). source: java - best approach parse huge (extra large) json file jesse wilson

bash - Read all files line by line in a directory and do a command on them -

i trying make script allow me read files in directory line line while doing command specific column of these files. files dealing .txt files have values separated commas. able execute code single file inputting text file script , outputting values not multiple files, goal. files read in order in in directory. here have far. directory=$(/dos2unix/*.txt) file=$(*.txt") ifs="," "$file" in "$directory"; while read -ra line; if [ "${line[1]}" != "" ]; echo -n "${line[*]}, hash value:"; echo "${line[1]}" | openssl dgst -sha1 | sed 's/^.* //' else if [ "${line[1]}" == "" ]; echo "${line[*]}, hash value:none"; fi fi done done some of errors getting are: $ ./orange2.sh /dos2unix/test1.txt: line 1: hello: command not found /dos2unix/test1.txt: line 2: goodb

javascript - Google Charts - ScatterChart Tick Marks and Styling -

Image
i created scatterchart visualize relationships between different data-fields. visualized data can numeric or nominal/ordinal in nature. nominal/ordinal values therefore mapped numeric values. simple example "age + gender", gender nominal , map 'male' => 1, 'female ' => 2 desired output. so far good, chart working, need formatting it. as can see first gender column displayed on y axis , second 1 @ far right side of graph. them layed out "pretty" in space y-axis, space right end. also display appropriate tick marks "male" , "female" on y-axis. extension: i want split data different series able colorize e.g. 'male' , 'female' data points in different colors. what build 3 columns in data-table (age, male, female), can't quite output correctly. it's merging 1 displayed column. here's code far: var drawme = function(){ var columns = 0; var xcolumns = 0; var yc

sql server - How to edit this php function? -

how edit: 'char_transfertime' => $data['transfertime'], because display example: 2013-08-19 18:55:00 when it's null want display n/a ps. it's getting data mssql 2005 database (transfertime row in table) will appreciated. use php's ternary operator is_null() or isset() 'char_transfertime' => ((is_null($data['transfertime'])) ? 'n/a' : $data['transfertime']),

android - Which is the best way to add a button? -

i'm new android development. i've doubt. know can add button , initialize like button b1=(button) findviewbyid(r.id.button1); and can give unction name in xml file. android:onclick="click_event" my doubt is, best , efficient way? says better use @string resource instead of hard-coded one. i think confused. examples give 2 different things. adding button this line button b1=(button) findviewbyid(r.id.button1); doesn't add button . declares , initializes instance of button refers button in inflated xml has id of button1 so in xml have somewhere <button android:id="@+id/button1" <!-- other properties --> /> you can add button programmatically button bt1 = new button(this); // give properties but easier in xml because here have programmatically give parameters, properties, , add inflated layout onclick as far onclick() depends on feel easiest , best in situation. declare in xml can s

java - encoding issue in my web application -

i facing encoding issue in web application. i using properties file (resource bundle) store language text. if check encoding of properties file using notepad, it's utf-8 , see proper arabic character when open in notepad. login=دخول when build application using jdeveloper, in properties file under classes folder, arabic characters converted this: login=\u062f\u062e\u0648\u0644 also encoding of file shown ansi in notepad. surprisingly, in browser, characters appeared fine (دخول). now when build application using ant, i've copy task copying properties file src folder classes folder. after running build script, if see encoding of properties file under classes folder, still utf-8 , characters in arabic only. however in browser, characters doesn't appear properly. as far know utf-8 encoding supposed cater languages in case wrong somewhere. i tried following in copy task: encoding="utf-8" outputencoding="utf-8" however still no lu

counter - Winapi: GetTickCount() can't get ELAPSED TIME -

hi got simple fps counter in animation. fps counts fine don't know why can't measure animation time. normaly time glutget(glut elapsed time) since have go winapi (or must) use gettickcount() here code: int frames=0; int currenttime=0; int previoustime=0; int intervaltime=0; int countertime=0; float fps; void fpscount(){ frames++; currenttime = gettickcount(); intervaltime = currenttime - previoustime; if(intervaltime >= 1000) { fps = frames / (intervaltime / 1000.0f); previoustime = currenttime; frames = 0; countertime += intervaltime; } } i measure line: countertime += intervaltime; , strange values like: 44834406 44835420 if define line countertime = intervaltime+countertime; countertime gets values above. if define line countertime = intervaltime; countertime gets values: 1014 1014 are not summed. the correct values should be: 1014 2028 . . . what i'am doing wrong? try instead:

Rails / Memcached Error on Heroku -

i'm running issue using memcached rails 3.2.11 , dalli 2.6.4 on heroku. memcached works great in development, when push staging environment on heroku i'm running following error when hit cached page or when write rails.cache.clear in console: nomethoderror: undefined method `split' nil:nilclass /app/vendor/bundle/ruby/1.9.1/gems/dalli-2.6.4/lib/dalli/server.rb:35:in `initialize' /app/vendor/bundle/ruby/1.9.1/gems/dalli-2.6.4/lib/dalli/client.rb:334:in `new' /app/vendor/bundle/ruby/1.9.1/gems/dalli-2.6.4/lib/dalli/client.rb:334:in `block in ring' /app/vendor/bundle/ruby/1.9.1/gems/dalli-2.6.4/lib/dalli/client.rb:326:in `map' /app/vendor/bundle/ruby/1.9.1/gems/dalli-2.6.4/lib/dalli/client.rb:326:in `ring' /app/vendor/bundle/ruby/1.9.1/gems/dalli-2.6.4/lib/dalli/client.rb:238:in `flush' /app/vendor/bundle/ruby/1.9.1/gems/dalli-2.6.4/lib/active_support/cache/dalli_store.rb:196:in `block in clear' /app/vendor/bundle/ruby/1.9.1/gems/dalli-2.6.4/

java - Cannot write HSSFWorkbook to ByteArray and then read it to HSSFWorkbook -

5i need convert hssfworkbook (apache's poi) bytearray , later convert bytearray hssfworkbook. following testcase illustrates problem: @test public void testxlsexportimport(){ try { inputstream = new fileinputstream(filepath); hssfworkbook wb = new hssfworkbook(is); byte[] exported = wb.getbytes(); hssfworkbook wb2 = new hssfworkbook(new bytearrayinputstream(exported)); //in line above exception thrown } catch (exception e) { asserttrue(false); } } the testcase fails exception: java.io.ioexception: invalid header signature; read 0x0005060000100809, expected 0xe11ab1a1e011cfd0 (i using apaches poi 3.5-beta3) i hope can me... how can work?! you're not writing workbook correctly! need use write(outputstream) call. as shown in various examples on website , code should instead be: inputstream = new fileinputstream(filepath); hssfworkbook wb = new hssfworkbook(is);

javascript - submit form, reload parent, and close child -

i have issue cross-ie issue, not cross-browser one. i trying open child window, user submit form. on submission, php script should called load child form data. child should reload parent window containing of content added in child form, , close child form... users not have other browser in use other ie, different versions (i prefer make compliant, settle different ies). have had no trouble in ie10, can't work in ie8. there users must use ie8 (they stuck on xp due other software won't run on 7 or 8). i have tried this: <form name="parts" id="parts" action="tableaddrow_nw.php" method="get" onsubmit="window.opener.document.location.href='q.php?q=<?php echo $q; ?>&memberid=<?php echo $memberid; ?>'; self.close();"> i have tried this: <form name="parts" id="parts" action="tableaddrow_nw.php" method="get"> <input type="button"

acceleo get stereotypes' attributs from within a module -

i'm writing module writes ldif file, i've stereotype called 'user' defined metaclasse have many attributs (username, password, role,..) the problem cannot access attributs within module.. how should do! use getvalue operation. in example below elem has stereotype 'enumliteralcodevalue' of profile 'clbprofile' attached has property of type 'value' [elem.getvalue(elem.getappliedstereotype('clbprofile::enumliteralcodevalue'),'value')/]

html - Can't get CSS alignment of an image to work -

i working on page: http://g33ktalk.com/etsy-a-deep-dive-into-monitoring-with-skyline/ and see how towards bottom, image subscribe doesn't have padding , touches divs. i tried this: #gform_submit_button_8 { padding-left: 15px; } but had no effect. tried add padding class gform_footer had no effect. know how add padding left side of image? edit: this larger html in image in <div class='gf_browser_chrome gform_wrapper' id='gform_wrapper_8' > <form method='post' enctype='multipart/form-data' id='gform_8' action='/etsy-a-deep-dive-into-monitoring-with-skyline/'> <div class='gform_heading'> <h3 class='gform_title'>subscribe our youtube channel</h3> <span class='gform_description'>want more tech talks? subscribe our youtube channels , notified when new talks posted.</span> </div> <div class='gform_body'>

c - What is the difference between tasklet and workqueue -

i linux device driver newbie, , want know exact differences between tasklet , workqueue . additionally have following doubts too: which kernel stack interrupts, tasklet , workqueue use when running in interrupt/process context? at priority tasklet , workqueue run , can modify it's priority? if implement own work queue list, can schedule/prioritize independently? tasklets : are old (around 2.3 believe) have straightforward, simple api are designed low latency cannot sleep (run atomically in soft irq context , guaranteed never run on more 1 cpu of given processor, given tasklet) work queues : are more recent (introduced in 2.5) have flexible api (more options/flags supported) are designed higher latency can sleep bottom line is: use tasklets high priority, low latency atomic tasks must still execute outside hard irq context. you can control level of priority tasklets using tasklet_hi_enable / tasklet_hi_schedule (instead of respect

Multiple jQuery Pop-up Forms: Connect a href to <form> divs for user input -

i'm working on digital textbook feature allow student click link open simple div form them input answer specific question. pop-up form simple html/css jquery ui hide, show, , make draggable. here's twist. i've got multiple questions each need attached unique div. no problem, thought. i'll set each href link unique id i've assigned within div. problem is, can't seem target proper div corresponding href. instead same set of questions appear no matter link clicked. seems super simple , i'm overcomplicating it. can here? html: <div id="draggable" class="messagepop pop"> <form method="post" id="new_message" action="/answers"> <p><label for="body">what type of person carsten?</label><textarea rows="15" name="body" id="body" cols="55"></textarea></p> <p><label for="body">how know?

Grails global error handler -

i've defined following global error handlers in urlmappings.groovy "404"(controller: "error", action: "notfound") "500"(controller: "error", action: "servererror") the handlers implemented this: class errorcontroller { def notfound() { flash.msg = "not found" redirect uri: '/' } def servererror() { flash.msg = "oops" redirect uri: '/' } } when 404 error occurs works fine, when 500 error occurs flash scope empty when redirect / . there reason why flash scope should cleared after 500 (caused uncaught exception on server)? are sure have 1 mapping 500 error code? make sure have 1 mapping 500 in urlmappings.groovy (remove or comment out default mapping provided grails on create-app) static mappings = { "404"(controller: "error", action: "notfound") "500"(control

tabs - Using SherlockFragmentActivity works in newer android phone but not older model -

so have tested code on newer android , when test on older version , click on button take me page swipeview , tabs, error: the application has stopped unexpectedly. please try again. i have set minimumsdk level in android manifest 7. i'm not sure why won't work on older android phone. here's code swipeview class: import com.actionbarsherlock.app.sherlockfragmentactivity; import com.actionbarsherlock.view.menuitem; import android.app.actionbar; import android.content.intent; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.fragmentactivity; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; import android.support.v4.app.fragmentstatepageradapter; import android.support.v4.app.navutils; import android.support.v4.app.taskstackbuilder; import android.support.v4.view.viewpager; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; impo

java - Splitting string into several different strings -

i getting source code site , putting code string, this: 501252,110,34496 331550,30,14114 403186,1,18 325033,31,15750 460287,14,2384 286659,11,1366 419439,1,67 678464,1,0 505044,1,70 522192,1,75 454391,1,0 504858,1,20 505396,1,40 469927,1,0 336670,2,155 392887,5,437 403568,1,0 488324,1,0 524031,1,0 429226,1,0 389668,1,0 383021,1,0 384599,1,0 363131,1,0 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 -1,-1 i want split each number, , save them in there own strings, how go this? current code: (if help?) import java.awt.borderlayout; import java.awt.color; import java.awt.dimension; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.keyevent; import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.net.malformedurlexception; import java.net.url; import javax.swing.jbutton; import javax.swing.jf

css - Cache breaker as query parameter vs cache breaker in filename -

we have come across 2 ways cache breaking our css files. cache breaker passed query parameter: http://your1337site.com/styles/cool.css?v=123 cache breaker part of name: http://your1337site.com/styles/123.cool.css which way better? , why? i feel second way more verbose, because file matches name on folder structure. first way if want share "cool.css" on other parts of site, don't have access unique name generate each time. steve souder's article revving filenames: don’t use querystring makes argument changing filename better of two. ...a co-worker, jacob hoffman-andrews, mentioned squid, popular proxy, doesn’t cache resources querystring. hurts performance when multiple users behind proxy cache request same file – rather using cached version have send request origin server. as aside, squid 2.7 , above cache dynamic content default configuration

encryption - RSA Private and Public Keys have the same cipher text when encrypted with AES 256? -

is normal keypair of rsa (private , public) have same ciphertext when encrypt them aes 256? in fact i'm using php: <?php $key="abc"; $config = array( "digest_alg" => "sha512", "private_key_bits" => 4096, "private_key_type" => openssl_keytype_rsa, ); // create private , public key $res = openssl_pkey_new($config); // extract private key $res $privkey openssl_pkey_export($res, $privkey); // extract public key $res $pubkey $pubkey = openssl_pkey_get_details($res); $pubkey= $pubkey["key"]; aes256key = hash("sha256", $password, true); // entropy (for mcrypt_rand) srand((double) microtime() * 1000000); // generate random iv $iv = mcrypt_create_iv(mcrypt_get_iv_size(mcrypt_rijndael_256, mcrypt_mode_cbc), mcrypt_rand); $crypted_priv= rtrim(base64_encode(mcrypt_encrypt(mcrypt_rijndael_256, $key, $privkey, mcrypt_mode_cbc, $iv)), "\0\3"); $crypted_pub= rtrim

Pointers and Arrays in C - Extremely confused -

this question has answer here: what difference between char s[] , char *s? 12 answers i have learned traditional way of declaring character array follows: char c[] = "john"; however, have noticed can declare as: char *c = "john"; how work? know has pointers, please elaborate? appreciated. in first example, c array of char . in: char *c = "john"; c here not array pointer (type char * ) string literal. pointers , arrays different types in c. below link if want learn pointers , arrays: http://www.torek.net/torek/c/pa.html

java - How to refactor a step-wise code? -

consider code sample. is pattern not aware of ? how clean clutter ? int func1val = func1(); boolean val = checkiftrue(func1val); if (val) { int func2val = func2(); val = checkiftrue(func2val); if (val) { int func3val = func3(); val = checkiftrue(func3val); } } if (val) { // print func1val, func2val, func3val, } it looks you're printing out 3 values if , if checkiftrue returns true three. barring implementation detail of checkiftrue , couldn't like int func1val = 0, func2val = 0, func3val = 0; // value here if (checkiftrue(func1val = func1()) && checkiftrue(func2val = func2()) && checkiftrue(func3val = func3())) { // print func1val, func2val, func3val } to fair, like int func1val = func1(); if (checkiftrue(func1val)) { int func2val = func2(); if (checkiftrue(func2val)) { int func3val = func3(); if (checkiftrue(func3val)) { // print func1val, func2val, func3val

sql - Stored procesure Exact number of days between two dates -

i need store procedure oracle 11g whom calculate exact number of days between 2 dates, taking in count months have 28 days , others 30. i have problem managing leap years. idea fill procedure body? create or replace function days(p_from_date in date, p_to_date in date) return number -- insert code here! end; thanks in advance. i use one, works perfect: create or replace function days(p_from_date in date, p_to_date in date) return number b_days number; begin b_days := trunc(p_to_date) - trunc(p_from_date) - ((trunc(p_to_date,'d')-trunc(to_date(p_from_date),'d'))/7)*2 + 1; if to_char(p_to_date,'d') = '7' b_days := b_days - 1; end if; if to_char(p_from_date,'d') = '1' b_days := b_days - 1; end if; return(b_days); end; / function created. sql> select days(to_date('01/11/2007','dd/mm/yyyy'),to_date('06/11/2007','dd/mm/yyyy')) dual; days

Running Android Application In Backgroud All Time -

hello have application have timers , if timers stopped application wont work need keep application on time when app turn off ( know doesn't makes sense ) , save files if phone switched down. thanks. i need keep application on time when app turn off you can service . same purpose. save files if phone switched down you can receive intent action_shutdown in broadcast receiver, when phone switch off. can whatever want there. see is there way receive notification when user powers off device? details. hope helps.

Subtracting timestamps in MySQL -

i have following select statement subtract timestamps knowing how long truck has been stopped @ location: select f.id, f.imei imei, f.speed speed stops f, stops f2 f2.id = f.id-1 , f.imei = 7466 , hour(timediff(f2.timestamp,f.timestamp)) * 3600 + minute(timediff(f2.timestamp,f.timestamp)) * 60 + second(timediff(f2.timestamp,f.timestamp)) > 240 , f.speed = 0 , f2.timestamp >= '2013-08-20 00:00:00' , f2.timestamp <= '2013-08-20 23:59:59' order f2.timestamp desc the rows calculating stops: id imei timestamp speed 1 7466 2013-08-20 13:19:00 30 2 7466 2013-08-20 13:20:00 0 3 7466 2013-08-20 13:24:30 20 so select gives result there stop of 4 minutes vehicle 7466. the problem comes when rows this: id imei timestamp speed 1 7466 2013-08-20 13:19:00 30 2 7466 2013-08-20 13:20:00 0 3 7466 2013-08-20 13:21:00 0 4 7466 2013-08-20 13:22

excel - Remove specific strings only if the names begin with them -

i have cell values containing full names. i replace/remove following characters whole excel sheet: al al- el el- but fact want them replaced if word start characters. example: alorfze - (remove "al") aralfzi - (do not remove "al") ibrahim el-ketoob (remove "el-") moreover, replace characters if matched word has more 4 characters. replacing text in cells of workbook implies using vba code. put following code in module (use alt-f11 open vba editor, insert--> module add module, copy/paste following text; go worksheet, select "macros", run replacestuff , watch magic. few things note: the use of option explicit : idea, guards against typos etc option compare text : means "al" = "al" - in other words, removes case sensitivity comparison (usually want) the array of strings check variable: makes easy change want edit by setting application.screenupdating = false @ start of macro, , setting

Django Internal Server Error (takes exactly 1 argument (2 given)) -

i receive internal server error "typeerror: valid_month() takes 1 argument (2 given)" when try , submit django form. looks me i'm passing 1 argument valid_month(), not two. me understand i'm doing wrong here? i'm using google app engine launcher test this. import webapp2 form=""" <form method="post"> birthday?<br> <label> <input type="text" name="month"> </label> <label> <input type="text" name="day"> </label> <label> <input type="text" name="year"> </label> <br><br> <input type="submit"> </form> """ forms.py class mainhandler(webapp2.requesthandler): def valid_day(day): if day.isdigit() , int(day) in range(1, 32): return int(day) def valid_month(month): months

javascript - AngularJS Authentication + RESTful API -

angular+restful client-side communication w/ api auth/(re)routing this has been covered in few different questions, , in few different tutorials, of previous resources i've encountered don't quite hit nail on head. in nut-shell, need to login via post http://client.foo http://api.foo/login have "logged in" gui/component state user provides logout route be able "update" ui when user logs out / logs out. this has been frustrating secure routes check authenticated-state (should need it) , redirect user login page accordingly my issues are every time navigate different page, need make call api.foo/status determine whether or not user logged in. (atm i'm using express routes) causes hiccup angular determines things ng-show="user.is_authenticated" when login/logout, need refresh page (i don't want have this) in order populate things {{user.first_name}} , or in case of logging out, empty value out. // sample respo

reflection - Dynamic attribute lookup in java -

python has way dynamically find , retrieve object attribute using hasattr , getarr: try: if hasattr(obj,name) thing = getattr(obj, name) except attributeerror: pass else: break what efficient(coding , performance) way achieve java? serializing instances of class - , on time ,attributes may added class. so,on retrieval,i should able hand out getattribute-styled api client - , return attribute if particular version supports it. the best way using reflection field, make accessible (in case it's private or otherwise not accessible current scope), , value relation object in question. public static object getattribute(object obj, string name) throws exception { field field = obj.getclass().getdeclaredfield(name); field.setaccessible(true); return field.get(obj); } a nosuchfieldexception thrown in event no field exists called name .

javascript - Ajax breaks when you "add website to homescreen" on iPhone -

i have website uses ajax bring in content when user clicks button. works fine unless uses "add homescreen" function of mobile safari , opens website using icon on homescreen. when opens website homescreen icon works until ajax load part. when clicks link screen flickers white , content loaded in none of functions should run in load function run. contents gets loaded in animations supposed happen not happen , page looks broken. it weird problem , have no way of inspecting issue cannot access console. here link web app (it's not finished yet) - http://chrisgjones.com/aut/1.3/ my ajax load looks this <div class="inner"> <a href="farm.html">link</a> </div> function loadproject(){ var $load = $('#level'); $(document).on('click','.inner a',function(e){ e.preventdefault(); $this = $(this); var _sourcetarget = '#puzzle',

mysql - Why I cannot define an column named "index" in jpa? -

i use jpa persist object mysql databse. when define column named "index" below, table not generated in database. when delete or rename it, jpa works fine. import java.util.date; import javax.persistence.column; import javax.persistence.entity; import javax.persistence.id; import javax.persistence.table; import play.db.jpa.genericmodel; @entity @table(name="qa_assetvm") public class qaassetvm extends genericmodel{ private static final long serialversionuid = 1l; @id @column(name="vmassetname") public string vmassetname; @column(name="assetvm_index") //this works fine! public int index; /* @column(name="index") //when add this, table "qa_assetvm" not generated jpa in database. public int index; */ } i haven't tried using mysql, 'index' seems reserved word. check this out.

caching - requirejs config setting with expire cache -

i'm using requirejs i need set javascript(even css file) cache expiration(max-age) i know there's config urlarg require.config({ urlargs: "bust=v" + version }); in way, have change value version manually every single modification can config automatically change after modification or expiration time? besides using date() time because suitable development state i solved question dynamic generate urlargs https://github.com/huei90/requirejs-cache

plot - How to adjust legend in a row in R? -

Image
i have 1 plot , need adjust legends in row. how can it? plot(x,y) legend(c("x","y")) i need legend should in 1 line ----- x --------- y regards you want set horiz=true in legend . here's comparison of default behavior ( horiz=false ) horiz=true . this plot based on the second example legend documentation : layout(matrix(1:2,nrow=1)) # `horiz=false` (default behavior) plot(x, sin(x), type = "l", ylim = c(-1.2, 1.8), col = 3, lty = 2, main="horiz=false (default)") points(x, cos(x), pch = 3, col = 4) lines(x, tan(x), type = "b", lty = 1, pch = 4, col = 6) legend(-1, 1.9, c("sin", "cos", "tan"), col = c(3, 4, 6), text.col = "green4", lty = c(2, -1, 1), pch = c(na, 3, 4), merge = true, bg = "gray90") # `horiz=true` plot(x, sin(x), type = "l", ylim = c(-1.2, 1.8), col = 3, lty = 2, main="horiz=true") point