Posts

Showing posts from January, 2015

jquery - unable to fix undefined index in my php page -

i trying access token html page having input element having token when run page on server (wamp) in windows 7. getting error undefined index on "api_key" . how fix ? php code: <?php $cname=$_post['api_key']; if($cname=="to-do") { $api_key=$_post['api_key']; $file1="i have url here not mentioning valid reason".$api_key; $data = file_get_contents($file1); $json_o=json_decode($data); echo "<pre>"; print_r($json_o); echo "</pre>"; } ?> //html page: //script within head <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js "></script> <script type="text/javascript"> $(document).ready(function() { $("#postjson").click(function(event){ $.post( "get_task_by_column.php",{hidden:$('#api_key').val()}, function(data) {

c# - LINQ Sorting, Titles grouped by Author -

so currently, have program sorts list of books & authors. right now, outputting authors grouped title, meaning prints author's name & books he/she wrote. i'm trying reverse & have output book, & authors wrote book. appreciated. // authors , titles of each book // co-authored; group author var titlesbyauthor = author in dbcontext.authors orderby author.lastname, author.firstname select new { name = author.firstname + " " + author.lastname, titles = book in author.titles orderby book.title1 select book.title1 }; outputtextbox.appendtext("\r\n\r\ntitles grouped author:"); // display titles written each author, grouped author foreach (var author in titlesbyauthor) { //display author's name outputtextbox.appendtext("\r\

Grails clean leaves java process -

i using grails 2.3.5, think might bug in version of grails. whenever execute clean command sts have grails suite installed leaves java.exe background task. i know grails clean jvm process should terminated when when grails clean finishes cleaning stays there forever instead wasting ~250 mb memory. before executing clean no of java processes : 1 (ie sts) after executing clean no of java processes : 2 (sts , clean) and whenever kill process, stays same. testes oss: win8 (jvm7) ubuntu13.10 (jvm7) in grails 2.3 there addition of forked execution , there option use daemon start time of grails. if comment out of forked mode config may fix issue.

android - Listfragment crashes when tab selected and gives errors -

when run app runs until select third tab consist listfragment made displays listview data , image, once selected app gives normal message unfortunately app stopped working , logcat sends lot of red errors. 03-06 01:44:23.200: d/dalvikvm(879): gc_for_alloc freed 99k, 6% free 3113k/3280k, paused 57ms, total 59ms 03-06 01:44:23.410: d/dalvikvm(879): gc_for_alloc freed 20k, 5% free 3143k/3280k, paused 20ms, total 21ms 03-06 01:44:23.410: i/dalvikvm-heap(879): grow heap (frag case) 3.811mb 709972-byte allocation 03-06 01:44:23.450: d/dalvikvm(879): gc_for_alloc freed <1k, 4% free 3836k/3976k, paused 33ms, total 33ms 03-06 01:44:23.530: d/(879): hostconnection::get() new host connection established 0xb7a51a38, tid 879 03-06 01:44:23.690: w/egl_emulation(879): eglsurfaceattrib not implemented 03-06 01:44:23.700: d/openglrenderer(879): enabling debug mode 0 03-06 01:44:35.760: d/androidruntime(879): shutting down vm 03-06 01:44:35.760: w/dalvikvm(879): threadid=1: thread exiting uncau

ruby on rails - Twilio post to url with params[:text_response] and params[:phone_number] -

i using ruby 2.0.0 , rails 4.0. i sending text message out via rails app end user. when respond, want redirect them api call: www.myapp.com/api/verify_text_response within api call, want see text message sent end user url is. ideally, receive param of " text_response " wanted with. how can redirect reply end_user above url, , capture phone number came message sent me in params? if isn't possible, how can use twiml similar? end goal for it's worth, i'm trying accomplish: i send text message out - " would subscribe? " the end user responds " yes " or " no ". i change subscribed attribute on subscription model true or false. i send text message saying either " you subscribed. " or " you not subscribed. ". item's #3 , #4 based on user responding "yes" or "no" in item #2. the twilio guide here ruby useful documentation out there. recommend using twilio gem i

linux - Cannot connect to Azure Ubuntu VM - Public Key Denied -

we have been using ubuntu vm's on azure time , had problems. however, 1 of vms has gone bonkers lately. out of blue, ubuntu vm starts rejecting public key - ssh -i ~/azure.key abc@xyz.cloudapp.net permission denied (publickey). verbose gives me more confusing signs - ~$ ssh -i -v -v -v ~/azure.key abc@xyz.cloudapp.net warning: identity file -v not accessible: no such file or directory. openssh_5.9p1 debian-5ubuntu1.1, openssl 1.0.1 14 mar 2012 debug1: reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: applying options * debug2: ssh_connect: needpriv 0 ssh: not resolve hostname /home/abc/azure.key: name or service not known wondering if saw problem or can suggest ideas/solutions? how following? $ ssh -i ~/azure.key -v -v -v abc@xyz.cloudapp.net

git - Can not access via ssh and view layout without css -

Image
i set gitlab in company lan, now, can access gitlab server http://dqa-test but when ran sudo -u git -h bundle exec rake gitlab:check rails_env=production i got check gitlab api access: failed. code: 404 i've change `host:` dqa-test, dqa-test/ , `http://` or not but after above tries, still got same error running self-check i can clone project via http , no way in ssh git clone git@dqa-test:vvtk_dqa_automation_team/sandbox.git cloning 'sandbox'... access denied. fatal: not read remote repository. please make sure have correct access rights , repository exists. my gitlab.yml ## gitlab settings gitlab: ## web server settings (note: host fqdn, not include http://) host: "http://dqa-test" port: 1987 https: false i have no idea why don't have correct layout it doesn't work when ran sudo -u git -h bundle exec rake assets:clean assets:precompile cache:clear rails_env=production i found source code of html page wei

validation - calling laravel route in javascript -

can call laravel route in javascript? i trying implement front-end validation jquery validate plugin. reason doing front-end validation instead of validation function provided laravel using bootstrap modal login form , not want user dismiss form upon clicking "submit" button. currently doing this: $("#modal-form-login").validate({ errorclass: "error", errorplacement: function(error, element) { error.insertafter(element.parent("div")); }, rules: { email: { required: true, email: true }, password: { required: true, minlength: 4 } }, messages: { email: { required: "メールアドレスが必要です", email: "有効なメールアドレスを入力してください" }, password: { required: "パスワードが必要です", minlength: jquery.format("少なくとも {0} 文字") } }, submithand

multithreading - Python timer not waiting as expected -

so, have code: t = threading.timer(570.0, reddit_post(newmsg)) t.start() to start quick reddit post. sadly, instead of waiting 570 seconds, automatically executes reddit_post without waiting. what can fix this? to explain in more detail: when call timer constructor, should give 3 arguments. first argument should how long want timer wait. second argument should callable (for example function). third argument should list of arguments call function. an example. # first define function call. def say_hello(name): print('hello ' + name) # can call function. say_hello('john') # when make timer call later, use not call function. timer = threading.timer(10, say_hello, ['john']) timer.start()

Delphi Insufficient RTTI available to support this operation -

i new using rtti , i'm stuck on error. i trying call procedure name , pass parameter array of tvalue . first problem getparameters returns array of 0 length ( instead of 1 ), , can't ignore try call procedure empty array. here's code: procedure tformgenpopupmessaggi.execmethod(form : tobject; methodname:string; const args: array of tvalue); var r : trtticontext; t : trttitype; m : trttimethod; lparams : tarray<trttiparameter>; begin t := r.gettype(tformacqgestionerichiesteacquisto); m in t.getdeclaredmethods if (m.parent = t) , (m.name = methodname)then begin lparams := m.getparameters; showmessage(inttostr(length(lparams))); m.invoke(tformacqgestionerichiesteacquisto.create(self), parametri); end; end; procedure tformgenpopupmessaggi.eseguimessaggio(sender : tobject); var procedura, tipoclasse : string; argomenti : string; arrayargomenti : array of tvalue; idmessaggio, idelenco : integer; :

python - Python2: List splitting syntax - tail of a list -

this question has answer here: explain slice notation 24 answers why sequence[1:0] return empty list when sequence[1:] or sequence[1:n] (where n >= sequence length) returns tail of list successfully? i'm pretty sure it's way python iterates on loop, can't fathom why wouldn't work, considering works numbers less zero. example: >>> l = [1,2,3,4] >>> l[1:] [2,3,4] >>> l[1:100] [2,3,4] >>> l[1:0] [] >>> l[1:0:1] [] >>> l[1:-2] [2] to elements backwards, need pass step negative value l = [1,2,3,4] print l[1:0:-1] # [2] when l[1:0] python takes the step value 1, default, step 1 . and when step greater 0 , start greater or equal stop , length of slice returned set 0. so, empty list returned. if ((*step < 0 && *stop >= *start) || (*step > 0 && *star

C++ - Weird thing, input got reversed -

i found weird, tested code: #include <iostream> using namespace std; int main() { int i=0, a[5]; cin>>a[i++]>>a[i++]>>a[i++]; for(int j=0; j<i; j++){ cout<<a[j]<<endl; } } with input: 1 2 3 and got input reversed this: 3 2 1 i thought output should same code: #include <iostream> using namespace std; int main() { int i=0, a[5]; cin>>a[i++]; cin>>a[i++]; cin>>a[i++]; for(int j=0; j<i; j++){ cout<<a[j]<<endl; } } anybody had experienced before? thanks. -edit- thanks answers!!! cin>>a[i++]>>a[i++]>>a[i++]; is syntactic sugar for cin.operator>>(a[i++]).operator>>(a[i++]).operator>>(a[i++]); now, 3 calls operator>> executed left right, 3 arguments a[i++] can evaluated in order. let's call arguments x , y , z : cin.operator>>(x).operator>>(y).operator>>(z);

datepicker - Is it possible to remove the timezone from a cal event? -

im using fullcalendar , remove timezone calevent.start. how can this? thought this: $("#startstatus").val(calevent.start)({ startformat: 'yy-mm-dd' }); instead of: $("#startstatus").val(calevent.start),

ruby - Disable Rack::CommonLogger without monkey patching -

so, want have custom logging sinatra application, can't seem disable rack::commonlogger . as per sinatra docs should need add following line (tried setting false well): set :logging, nil to configuration. not work however, , still receive apache-like log messages in terminal. solution i've found far monkey patch damn thing. module rack class commonlogger def call(env) # nothing @app.call(env) end end end anyone got ideas if it's possible disable without restorting such matters? puma adds logging middleware app if in development mode , haven’t set --quiet option. to stop puma logging in development, pass -q or --quiet option on command line: puma -p 3001 -q or if using puma config file, add quiet it.

Textual order of static variables and initialization order in Java -

i spend 5 minutes find duplicate in so. my question simple. following code work? public class lexicalorderstatic { private static integer a1 = inita1(); private static integer a2 = inita2(); private static integer inita2(){ return new integer(5) / a1; } private static integer inita1(){ return new integer(5); } public integer geta1(){ return new integer(a2); } public static void main(string[] args) { lexicalorderstatic lexluthor = new lexicalorderstatic(); system.out.println(lexluthor.geta1()); } } in java can sure a1 always initialized before a2 ? thanks. dw ok if asked or if simple. in java can sure a1 initialized before a2 ? yes, because specification (section 12.4.2) guarantees (emphasis mine): next, execute either class variable initializers , static initializers of class, or field initializers of interface, in textual order , though single block. note consta

r - Platform-dependent data output -

in order aid myself displaying debugging information, decided create following tiny function dynamically switch between displaying data in rstudio's internal data browser , simple character-based output, depending on capabilities of platform, modules being sourced at: view <- function (...) { if (.platform$gui == "rstudio") view(...) else print(...) } this function located, along other utility functions, in module <proj_home>/utils/debug.r . modules need these functions, include via source("../utils/debug.r") . running project's code on amazon ec2 instance's linux console fine. however, running on same virtual machine via rstudio server results in following error message: error: evaluation nested deeply: infinite recursion / options(expressions=)? error during wrapup: evaluation nested deeply: infinite recursion / options(expressions=)? it seems me r gets confused view() function needs called. initially, assumed rstu

php - Different results for date() and gmdate() -

i found can't explain, maybe here can give me hint. i have following test code, prints 2 formatted timestamps, 1 31.03.2013 , 1 31.03.2014, using date() and gmdate() : <?php function print_date($timestamp, $year) { // add timezone offset germany $timestamp += 3600; print "in $year\n"; print "date: " . date('d.m.y h:i:s', $timestamp) . "\n"; print "gmdate: " . gmdate('d.m.y h:i:s', $timestamp) . "\n"; print "\n"; } $end_2013 = 1364684400; // 31.03.2013 $end_2014 = 1396216800; // 31.03.2014 print_date($end_2013, '2013'); print_date($end_2014, '2014'); print "default timezone: " . date_default_timezone_get() . "\n"; the result surprises me: in 2013 date: 31.03.2013 01:00:00 gmdate: 31.03.2013 00:00:00 in 2014 date: 31.03.2014 01:00:00 gmdate: 30.03.2014 23:00:00 default timezone: europe/berlin where difference in 2014 come from? first

jquery - Find certain text on page and make it underlined -

how find text on web page , make underlined? for example, have text on page , want find words hello , make them underlined. my trial code is: $( "body:contains('hello')" ).css( "text-decoration", "underline" ); but ends underlining whole line instead of word. try this. html <p>for example, have text on page , want find words hello , make them bold.</p> script $('p').html( $('p').html().replace(/hello/g, '<strong>hello</strong>') ) fiddle demo

How the Class file is including in another file php using the namesapce and Use? -

i have class called errors in errors.php namespace myclass; class errors { private $_codes = array( 301 => array( "code"=> 301, "message"=> "user id not found", "type"=> "error" ) ); public static function geterror($code) { return $this->_codes[$code]; } in myclass.php have namespace myclass; use myclass\errors; require'vendor/autoload.php'; inside myclass have afunction , checking errors echo errors::geterror(301); it shows class myclass not found error fatal error: class 'myclass\errors' not found in /var/www/myclass/myclass.php what have missed here? you have include errors.php

sql server - how to set rowcount to zero in SQL -

anyone have idea how set rowcount 0 again in sql. i have used rowcount fetch number of records inserted in insert statement. have use rowcount again find rows updated. trying reset rowcount again zero. code : insert table ...... insert statistics (id,inserted_records ) values (1,@@rowcount) ---some operations-- update table .... update statistics set updated_records=@@rowcount id= information rowcount here: http://technet.microsoft.com/en-us//library/ms187316.aspx statements such use, set , deallocate cursor, close cursor, begin transaction or commit transaction reset rowcount value 0 so maybe can put statements transaction, better isolated against each other. and can send request not update anything, update mytable set x=1 0=1;

git log - Is there a git log argument to filter files only with large changes? -

given have 40 files in current git log --stat , want show have 500 changes. example output: .../mymodule.java | 10 + .../mysecondmodule.java | 560 +++++++++ .../mythirdmodule.java | 5 +- .../myforthmodule.java | 12 +- in case want filter out except mysecondmodule.java . command run on repo haven't worked on in awhile idea of major work done since have hundreds thousands of changed files. i don't see command line options doing that, @sashoalm says, can pipe output command (or write script) kind of filtering. this kinda works showing files have > 100 lines changed: git log --stat | egrep "(commit|author|date|^ |^$|\|.*[0-9][0-9][0-9])"

visual studio 2010 - can't connect to tfs using VPN -

i trying connect tfs using vpn: at our offices have tfs installed , working fine. we have team abroad trying connect tfs through vpn our tfs server name @ offices tfssrv under , ip 192.---.---.196, when ping ip abroad, there connection it, when try access browser should popup enter username , password, not getting. when try connect vs , try add ip as tfs server, error tf31002: unable connect team foundation server. am missing anything? did have setting of firewall on tfs apptier, such allow domain inbound? can access other applications via vpn? can try use userid , password connect tfs , see if works? could please follow steps in blog http://blogs.msdn.com/b/granth/archive/2008/06/26/troubleshooting-connections-to-tfs.aspx hope helps!

Python function for recursively remove data from a list -

i have pandas dataframe following(c2). session 1 2 3 5 8 session 1 nan 0.8 0.67082 0.676123 0.730297 2 nan nan 0.67082 0.845154 0.912871 3 nan nan nan 0.566947 0.612372 5 nan nan nan nan 0.925820 8 nan nan nan nan nan and list of values. listofdata = [1,2,3,4,5,6,7,8,9,10] i 2 list of tuples following greater = [(c2.index[i], c2.columns[j]) i, j in np.argwhere(c2 > 0.8)] less = [(c2.index[i], c2.columns[j]) i, j in np.argwhere(c2 < 0.8)] for 'greater' following values get. [(2, 5), (2, 8), (5, 8)] .i want find how these 2,5 , 8 grouped. first want find maximum 3 groups. b = [] item in greater: b.append( c2.ix[item] ) maxindex = [(c2.index[i], c2.columns[j]) i, j in np.argwhere(c2 == max(b))] since maximum (5,8) want remove both 5 , 8 initial 'listofdata'. k = [j in maxindex j in i]

email - Getting the content to a mail message from a rule in applescript fails -

i trying grab body text of email message (in example i'm using email subject avoid issues text formatting) i'm sure used work:- using terms application "mail" on perform mail action messages themessages tell application "mail" activate set themessage item 1 of themessages try set themessagesubject subject of themessage on error errmsg display dialog "error: " & errmsg end try end tell end perform mail action messages end using terms result -> error: can't <<class mssg>> 1 of <<class mact>> "incoming pop messages" of <<class mact>> "my email account". invalid index. i have tried using "repeat themessage in themessages" same result. i've tried inserting multiple delays because read that didn't here. this seems bug how apple mail handles incoming pop messages. using imap account instead , acceptable solution me.

javascript - jQuery CSS Hooks slow. Could be disable or fixed? -

i'm building widget in javascript using jquery 1.10.2 , used old trick of having 2 divs, outside div smaller , hides partially internal div. use jquery .css() change left , width of internal div allowing implement panning , zooming of contain of internal div. , it's working well, complex dom inside these internal div. the problem in firefox 26 , 27 slow. profile it, , see calls " jquery.csshooks[name].get() " being painful slow (in chrome 33.0.1750.146 these calls quick), hurts badly performance. keeps being usable, difference , feel between chrome , firefox issue appreciable , unacceptable. i find slow csshooks happens when use .css() change left property pixels. var left = string(- (this.view_cursor - this.options.start) * this.ppy + offset) + 'px'; var width = string(this.ppy * interval) + 'px'; this.container.css({ left: left, // line launchs painful slow csshooks calls width: width, }); any idea or suggestion of how can avoi

c# - How to disable ItemsSource synchronization with Text property of ComboBox -

i use combobox binding string property of view model. choose combobox instead of textbox, because want have option choose list (as suggestion), don't want change selected text if itemssource changes. i tried set issynchronizedwithcurrentitem property false, when list of suggestions change (at position of selected text), text changes empty. seems combobox has remembered entered text in list , when item disappears, text property cleared. so question is: bug, or doing wrong? if bug, suggest work around? i created sample project preproduces this: in xaml: <window x:class="testproject1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525"> <grid> <combobox issynchronizedwithcurrentitem="false" itemssource="{binding items}"

c# - Which IE add-on is crashing my application -

case: have a websites authenticates second sso website using federated authentication. go main website redirect sso authentication site -> , fill in correct credentials go main authentication cookies -> crash extra info error logs: it's in ie browser (ff , chrome work perfectly) i can't reproduce problem myself: tested on every operating system , browser version browserstack nor can colluegues. when contacting end-users have problem. consistently have in ie. when asked use browser works. my current guess it's due ie-add-on. not know 1 , bit of guess. fact happens on end-users computers means have no control on computers , i'm unable go on screen , check out plug-ins have. are ways check this? , find out add-on's installed on end-users pc? the error one: the token '>' expected found 't'. line 1, position 1572. stacktrace: at system.xml.xmlexceptionhelper.throwxmlexception(xmldictionaryreader reader, str

linux - second "send" command in expect script is not waiting to finish the Output of first command -

i have small expect script . flow follows ssh remote machine execute command , after executing command in different prompt ( prompt name enter cmd> . on enter cmd> prompt, need run many commands hence designed script #!/usr/bin/expect set full_cmd { #cmd1 #cmd2 #cmd3 } puts "starting......." log_file myfile.log ;# <<< === append output file spawn ssh tempuser\@dummyserver match_max 100000000 expect "password:" send "temppasswd\r" expect "*temp*" send "cd \/home\r" expect "*temp*" send "new cmd prompt\r" expect "enter cmd>" foreach tempcmd $full_cmd { send "${tempcmd} \r " expect -exact "enter cmd>\r" send -- "\r" expect eof } send "q" send "exit\r" puts "i have ended......." my problem: o/p of first command cmd#1 long , can see expect script not waiting o/p of first command complete , s

pythonxy - ImportError: DLL load failed: The specified procedure could not be found. Python -

recently, have installed current version of python(x,y) package (2.7.6.0) , when run python code, shows error: traceback (most recent call last): file "d:\projects\comparison\lagebestimmung\main.py", line 11, in <module> import cv2 importerror: dll load failed: specified procedure not found. i correctly selected opencv module during installation. also, use have older version of python(x,y) before in computer uninstalled before installing new version. in version, there no such problem. use dependency walker ( http://www.dependencywalker.com/ ) on cv2.pyd 'site-packages'. look @ higher-left corner, library tree is. normal libraries have blue or gray icons, find libraries red icons on left, this: http://i.stack.imgur.com/yieud.png . find api's having red flag , remember parent library names of libraries red icon. red flag means parent library requires api, absent in underlying library. in case library red icon 'kernel32.dll', ,

javascript - What can I use instead of typeof in JS -

if have javascript array objects inside, this articlesparams[itemid].properties.loaded if try this: if ( typeof articlesparams[itemid].properties.loaded != 'undefined' && ...) { // something... } i have encountered problem if articleparams[itemid].properties undefined got error: cannot read property 'properties' of undefined. so in case should stupid this: if ( typeof articlesparams[itemid].properties != 'undefined' && typeof articlesparams[itemid].properties.loaded != 'undefined' && ...) { // something... } is equivalent in javascript in php isset() ? an alternative this, quite typical in js: if (articlesparams[itemid] && articlesparams[itemid].properties && articlesparams[itemid].properties.loaded && ...) { // something... } or this: var item = articlesparams[itemid]; if (item && item.properties && item.properties.loaded &

cluster computing - SQL SERVER replication or mirroring configuration to achieve the following scenario? -

suppose have master server called master a "slave" server called a a "slave" server called b a "slave" server called c.. , on. every slave server have several clients. the environment should work described below, taking server example: when change made in a, replicates it's changes master server. then, master server replicates changes across slaves. (b,c,...). if slave server lose connection master server, server clients can still operate , connecting . when connection back, slave server should upload changes master server, , download every change made other slaves, through master server well. any guidance on configuration should use appreciated. what you're describing sounds merge replication.

java - Docx4j: PPTX got corrupted while inserting an ellipse object -

i have been searching whole day solution i'm unable find one. that's why decided ask question. my problem i'm inserting ellipse object pptx file. when tries open presentation ms office says it's corrupted , tries repair. ends deleting slide , presents master slide. see below code: function officexreport.gettemplatename() contains filename of pptx (e.g. *status_report_template.pptx*) template pptx file contains 1 slide. function officexreport.getnewfilename() contains new filename of pptx (e.g. *status_report_2014-03-16.pptx*) try { presentationmlpackage presentationmlpackage = (presentationmlpackage)opcpackage.load(new java.io.file(officexreport.gettemplatename())); mainpresentationpart pp = presentationmlpackage.getmainpresentationpart(); boolean noline = false; stshapetype st = stshapetype.ellipse; int = 1; slidepart slidepart = (slidepart)presentationmlpackage.getparts().getparts().get(pp.gets

How to pass a value/variable from an android java class to javascript/.html file in android 4.4.2 kitkat -

i need pass value/variable (e.g. integer, string) java class .html file inside android assets. let's integer value based on user's click. need pass this integer .html file(scripts) determine ajax call made (via if-else loop). googled everywhere couldn't find answer this. i need achieve on android 4.4.2. in advance. have seen http://developer.android.com/guide/webapps/webview.html ? interested in binding javascript code android code section. first declare interface, implement method return integer. inside js code call method value. edit interface working js: public class webappinterface { context mcontext; /** instantiate interface , set context */ webappinterface(context c) { mcontext = c; } /** value */ @javascriptinterface public int getvalue() { return value } } add interface webview : webview webview = (webview) findviewbyid(r.id.webview); webview.addjavascriptinterface(new webappinterface

php - Change data format from mm/dd/yyyy to yyyy-mm-dd -

i have data string data in format -> 03/15/2014 (mm/dd/yyyy) , need replace date in format 2014-03-15 (yyyy-mm-dd) . i know how change '/' '-', don't know how turn 2014 end start. try this $dates = explode("/","03/15/2014"); $newdate = $dates[2]."-".$dates[0]."-".$dates[1]; this works in version of php note: input date should of format mm/dd/yyyy if php less 5 can use this. if php > 5 advised use datetime class advised gordonm in order find date valid or not . demo

set url value globaly in javascript or jquery? -

i have calculate bonus. on first page 2 options: yes , no. if select yes, piccal.html?value=yes <a onclick="window.location.replace('piccal.html?value=yes')"> when select no, piccal.html?value=no <a onclick="window.location.replace('piccal.html?value=no')"> if have yes calculate bonus otherwise not on calculator page there 3 links other pages. <a href="piccal.html" class="btn noselect"></a> <a href="picinfo.html" class="btn noselect">pic grant information</a> <a href="#">contact us</a> piccal.html calculator page if select link inside have no value "yes" or "no" . how set url yes or no value default page if value selected page i think getting question. in advance if you're asking think, want persist querystring page page. can simple or involved, depending on many other factors, simple answ

java - Prevent duplicate entry for unique constraint -

i trying save tags related article in mysql database. relation between 2 columns 1:n. each item has auto generated key. name of tag unique. if insert new article existing tag, duplicate entry exception unique constraint (mysqlintegrityconstraintviolationexception). 2 entities: article.java @entity public class article implements serializable { @id @generatedvalue(strategy = generationtype.identity) private long id; @onetomany(cascade = cascadetype.all) @jointable private set<tag> tags = new hashset<tag>(); /* getter , setter */ } tag.java @entity public class tag implements serializable { @id @generatedvalue(strategy = generationtype.identity) private long id; @column(unique = true) private string name; /* getter , setter */ } hibernate generate following tables : article , tag , article_tag . first article records correct. i use following code insert new article (only testing): article article = ne

terminal - Install MongoDB and give access only to groups in Linux Ubuntu Server -

i have created user group , know how can install mongodb on ubuntu 12.04.4 lts such read/write access given users in user group. thanks. the users define on os side has nothing users inside mongodb, take @ http://docs.mongodb.org/manual/core/access-control/ . need setup users inside db restrict access. can check security related topics here , documentation contains detailed description of concepts , explanation how setup.

php - How to throw an exception but include parameters as part of the message? -

what best way this: $params = array ('a' => 'b', 'c' => 'd'); // etc etc throw new exception( "could not because params << insert parameters >> bad", $code ); what best way include parameters part of exception , if must go in message, best way transform text no details lost? keep in mind, want see this: "could not because params: = b, c = d bad", you can use sprintf function throw new exception( sprintf("could not because params %s, %s bad", 'b', 'd'), $code );

Wrong executing sqlplus command on php cron job -

i have php code: <?php define('oracle_sid', 'mydb'); define('oracle_home', '/usr/lib/oracle/11.2/client'); shell_exec('oracle_sid=' . oracle_sid); shell_exec('export oracle_sid'); shell_exec('oracle_home=' . oracle_home); shell_exec('export oracle_home'); putenv("oracle_home=".oracle_home); putenv("oracle_sid=".oracle_sid); $path = shell_exec('echo $path'); $oracle_home = shell_exec('echo $oracle_home'); $abs_path = str_replace("\n","",$path. ":" .$oracle_home . "/bin"); putenv("path=".$abs_path); echo exec('sqlplus myuser/mypass@mydb @/absolute/route/to/script.sql'); ?> here export environment variables in order run sqlplus command. works fine when execute line command, when "cron" executes it, doesn't run sqlplus command. i checked "exports" part on cron running "echos" on v

windows phone 8 - ScrollViewer's scrolling control by coding in xaml.cs -

in windows phone app, try control scrolling of scrollviewer.in requirements wants scroll page when variable value bla blaa. way resolve type of thing? please let me know . <grid x:name="contentpanel2" grid.row="2" margin="12,0,12,0"> <scrollviewer margin="-10,0,10,169"> <stackpanel height="916"> <textbox x:name="txtnomecliente" height="auto" textwrapping="wrap" text="" background="white" borderbrush="white" isreadonly="true"/> <button x:name="botaocatalogo" content="catálogo" width="auto" height="80" verticalalignment="top" background="#ff3faaca" borderbrush="#ff3faaca" /> <button x:name="botaoitens" content="itens"

javascript - deepclone affected only on the last iteration in loop -

i trying clone select handler within loop, but handler binds clone in last iteration. this html of select <select class="usertype" id="<?...?>"> <option>o1</option> <option>o2</option> <option selected>o3</option> </select> this js var usertype = $('.usertype'); usertype.change(function(){ console.log(1); }); $('#okbtn').click(function(){ // obj.data json getting ajax result. var selectraw = $(usertype).first(); searchresult.html(''); for(var value in obj.data){ searchresult.html(searchresult.html()+'<div id="userresult'+obj.data[value].id+'">'+obj.data[value].name+' - '+obj.data[value].email+' </div>'); selectraw.clone(true, true).appendto('#userresult'+obj.data[value].id).attr('id', obj.data[value].id).children().attr('selected', false); } }); ok strange. change way insert

sql - Can I use a modulo to specify an interval in postgres? -

i have list items have not been updated multiple of 2 years after last update. run cron job once day. i know can ugly like: select art_id, art_update items art_update = now()::date - interval '2 years' or art_update = now()::date - interval '4 years' or art_update = now()::date - interval '6 years' or art_update = now()::date - interval '8 years' or art_update = now()::date - interval '10 years'; is there way avoid checking modulo interval? or other generalised way express this? you can generate series of dates @ 2 year intervals going today (to 10 years ago in below) , join table: select i.art_id, i.art_update items inner join generate_series(2, 10, 2) s (years) on i.art_update = now()::date - interval '1 years' * s.years; example on sql fiddle n.b appears marginally faster if generate dates in series, rather numbers: select i.art_id, i.art_update items inner join generate_series(now() - inter

sorting - Print struct inputs in alphabetic order C++ -

i want print strings struct in alphabetic order, , have got thread how alphabetically sort strings? , sorting. problem when run compiler sorted output includes name struct. code looks this: #include <iostream> #include <set> #include <algorithm> #include <string> using namespace std; const int antalshops = 2; const int antalworkers = 5; struct employ { string workername; int workerage; }; struct themall{ string shopname; string shoptype; int shopsize; employ workername; employ workerage; }; // declaration of structs themall shops[antalshops] = { {"gamestop","toy", 250,}, {"frandsen", "cloth", 300,}, }; employ workers[antalworkers] = { {"andrea valente", 41}, {"giovanni pirolli", 25}, {"marco cipolli", 33}, {"jensine jensen", 19}, {"andrea jensen", 99}, }; // functions sorting , printing names void print(const strin

java - How can StringBuilder read more than 16 empty elements? -

here code: public class stringclass { public static void main(string args[]) { stringbuilder s=new stringbuilder(); s.append("v g f j v n x jc kn vd df jdf jkd kfd kfk dfkd lkd fmk dkkdfd kfdkfn kdfd end"); system.out.println(s); } } and output v g f j v n x jc kn vd df jdf jkd kfd kfk dfkd lkd fmk dkkdfd kfdkfn kdfd end according [java docs] ( http://docs.oracle.com/javase/tutorial/java/data/buffers.html ) string builder can store 16 empty characters,so how able characters output. if write code output same: public class stringclass { public static void main(string args[]) { stringbuilder s=new stringbuilder("v g f j v n x jc kn vd df jdf jkd kfd kfk dfkd lkd fmk dkkdfd kfdkfn kdfd end"); system.out.println(s); } } you misread that. documentation speaks of initial capacity . "space", should read "empty cell can put character". the underlying array s

jquery - Javascript API gets preperties of member methods -

hello i'm creating small api project @ work, here code: var vdsl = (function(){ var defaults = { resolvephonenumberurl: '/domain.com/test' }; return { map: function(el, options) { el = (el.jquery) ? el.get(0) : el; this.mapsettings = { center:new google.maps.latlng(37.983716, 23.72931), zoom: 10 }; $.extend(this.mapsettings, options); this.m = new google.maps.map(el, this.mapsettings); this.kmlparser = new geoxml3.parser({map: this.m}); this.drawarea = function(data) { this.kmlparser.parsekmlstring(data); }; this.cleararea = function(i) { this.kmlparser.hidedocument(i); this.kmlparser.docs.splice(i, 1); }; this.clearmap = function() { this.kmlparser.hidedocument(); this.kmlparser.docs

c++ - variadic template to call a function -

i trying write teamplate function looks this: template<t funcptr, params...> void callfunction(params...) { funcptr(params...); } example usage: typedef void (__stdcall* test_t)(int a1, bool a2, char* a3); test_t fn = ....; //pointer obtained somehow callfunction<fn>(10, true, "hello"); is possible? dont know how work parameter pack have unpacked each member of pack servers parameter. i suggest minor rewrite this: #include <iostream> template<class fun, class... args> void callfunction(fun fun, args&&... args) { fun(std::forward<args>(args)...); } void fn(int a1, bool a2, char const* a3) { std::cout << a1 << a2 << a3; } int main() { callfunction(fn, 10, true, "hello"); } live example . think can deduce proper ... syntax (after class... in paramter list, after arg... unpacking arguments @ call site. the std::forward distinguish between lvalues , rvalues. it