Posts

Showing posts from March, 2015

Mysql two queries in one (inner join?) -

i need return results of 2 queries within one. i've read other posts , not sure if should inner join. i these 2 queries: mariadb [servers]> select * servers; +----+------------+---------+------------+ | id | servername | ip | returncode | +----+------------+---------+------------+ | 1 | server1 | 0.0.0.0 | 0 | | 2 | server2 | 0.0.0.0 | 1 | | 3 | server2 | 0.0.0.0 | 0 | | 4 | server3 | 0.0.0.0 | 0 | | 5 | server3 | 0.0.0.0 | 4 | | 6 | server3 | 0.0.0.0 | 4 | | 7 | server3 | 0.0.0.0 | 4 | +----+------------+---------+------------+ mariadb [servers]> select servername,count(returncode) servers returncode<>0 group servername; +------------+-------------------+ | servername | count(returncode) | +------------+-------------------+ | server2 | 1 | | server3 | 3 | +------------+-------------------+ into this: mariadb [servers]> se

parsing - RIFF Wave File Format: FourCC values and HEX conversion -

context: parsing riff/wave files. there documentation identifying fourcc values within riff chunks. here more important chunks wave files. fourcc id 2 .wav specific chunks: chunk id "fmt " (0x666d7420) chunk id "data" (0x64617461) so, these fmt values should equal: string "fmt " hex "666d7420" int "1718449184" and, these data values should equal: string "data" hex "64617461" int "1684108385" now, when read in valid .wav files, fourcc fmtchunkid fmt int always: fmt int: int "544501094" and data int always: data int: int "1635017060" question: why doesn't documented hex value match int returning stream? i'm guessing don't understand hex int conversion. extra: found .wav parser code online has suspect fmt value "1718449184". find more fmt value "544501094". finally, search google "1718449184 , 5445

cookies - Remember active class on reload -

i creating single page website - menu items change class "active" when user on current section of page - works out fine, browser "forgets" menu-item current 1 on reload. is there way make browser remember element the last 1 have class "active", before reload? use localstorage . when mark item "active", save it's id or number in localstorage . after loading of page, retrieve information , mark corresponding item.

regex - preg_match() text extraction -

i have string inside paragraph: today's quote is: 'learn yesterday, live today, hope tomorrow. important thing not stop questioning.' i need extract sentence "learn yesterday, live today, hope tomorrow. important thing not stop questioning." i not familiar regular expressions little here. tried: preg_match("today's quote is: '[a-za-z0-9]'",$response, $matches); off course imagined it's not working. appreciated. in advance. edit: need include "_" , "-" alphanumeric expression. example: $string = "site : '6lczwncsaaaaaecqkyccsteouaqs9jo7wdrgzvbl', rtl : false, challenge : '03ahj_vuv_3y7ky-gqacyzgrz9ztv_cfqn_f0jeqognq0-3qanrsxj18opj4bbhrqpoisizbqbbdeexvfpnnvjltsjoxqugi4j0zb1yrqu1m4wxzfgvrpuryxjmnju3d7ix0nhyo_obefcr7v9gxtz_bnn04tszxxvyvkcexo9i2vcqcihwjqe8k8'"; i need match string after word "challenge". containing underscores , "-". this should jo

javascript - How to stock array with localStorage (Chrome Extension)? -

i tried stock array in localstorage read impossible. tried : array = {}; array.name = $('[name="name"]').val(); array.username = $('[name="username"]').val(); array.password = $('[name="password"]').val(); alert(localstorage['accounts']); local = json.parse(localstorage['accounts']); localu = local.push(array); alert(json.stringify(localu)); in fact scripts stops @ first alert wich returns '[]' (i put value check result). why isn't script working ? javascript, {} object. [] array. var array = [] , var array = new array() same thing. an array ordered container of stuff, each value has index not key. an object named container of stuff, each "stuff" has key. your array object. var data = {}; data.name = $('[name="name"]').val(); data.username = $('[name="username"]').val();

actionscript - preventing mobile detection using flash content -

there websites force policy of showing different content desktop , mobile users. other using appropriate ua string, there .flv files on web too! somehow detect mobile device , don't show desktop content. analyzing flash behaviors important 1 of our projects mobile app, security reasons there has stealth mode in software protect mobile user being identified mobile user when access websites in our partner company. how can control behavior client browser? any appreciated! it depends on doing. mobile device detection can matter of checking screen size or user agent, number of other things well. to figure out need do, run swf file through swfscan or asdec . if using flash, imagine doing more basic user agent string. might looking @ device capabilities cannot adjusted. it strange use flash detection - since won't work on iphones @ all.

jquery - Ajax json Parser Error -

i keep on getting json parser error (firebug console 'there no child objects') following data: (string) var data each iteration var data='['; data+= '{ "title": " nac", "no1": "1212","no2": "12126"},'; data+= '{ "title": " nac", "no1": "1212","no2": "12126"},'; data+= '{ "title": " nac", "no1": "1212","no2": "12126"},'; data+= ']'; and javascript parsing json var json = json.parse(data) and jquery ajax request $.ajax({ type: "post", data: json, url : 'ticket.php', datatype: 'json', async: false, contenttype : 'application/json; charset=utf-8', error: function(jqxhr, exception) { if (jqxhr.status === 0) {

node.js - Promise-based node http framework? -

node frameworks work via (err, result) callbacks. is there promise-based http framework node, healthy community , in active development (such express)? on http client side, there new fetch api https://fetch.spec.whatwg.org/ fetch() allows make network requests similar xmlhttprequest (xhr), main difference [it] uses promises, enables simpler , cleaner api, avoiding callback hell , having remember complex api of xmlhttprequest ( https://developers.google.com/web/updates/2015/03/introduction-to-fetch ) some implementations: browser "poly-fill" (older browsers) https://github.com/github/fetch node version https://www.npmjs.com/package/node-fetch cross platform version https://github.com/matthew-andrews/isomorphic-fetch (i don't word "isomorphic" used in situation... anyway) here example code: fetch('/some/url', {method: 'get'}) .then(function(response) { // rejoice \o/ }) .catch(function(err) { //

Login twitter IOS without go to the Settings (like instagram) -

i'm newer in twitter integration ios so, have doubt that. i saw in many examples on web when don't have account connected in twitter, show alert , redirect user setting login in twitter account. how can make login form instagram? user can insert user_name , password , submit it? my code @ moment: accountstore = [[acaccountstore alloc] init]; acaccounttype *twittertype = [accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifiertwitter]; // request access user use twitter accounts. [accountstore requestaccesstoaccountswithtype:twittertype options:nil completion:^(bool granted, nserror *error) { if (granted == yes){ //get accounts use. accounts = [accountstore accountswithaccounttype:twittertype]; if ([accounts count] > 0) nslog(@"account: %@", accounts); }else{ // show alert inser user_name , password login on twitter alerttwitteraccount = [[uialertview alloc]

eclipse - Android Widget - Click for action, update under 30 minutes, separate instances -

i've tried create widget that, on click calls routine on configuration activity, on update calls routine on configuration activity, update must under 30 minutes , instance created must work separately (in onupdate , in onclick). the code below: click doesn't work (can't see toast message , other function) update works fine first instance multiple widget instance works bad: if create 2 instances between 10 seconds (and refresh set 20 seconds) update every 10 seconds. that's manifest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.fraschi.controllogiardinowg" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <application android:allowbackup="true" android:icon

visual studio - Is it possible to change the debugging shortcut keys in IntelliJ IDEA -

i have spent s lot of time in vs, , have started working in idea. debugging shortcuts in vs , idea differ. instance idea use f7 stepping in, whereas vs uses f11. i looking ability change debugging shortcuts in idea. did research , found keymaps . brief research shows keymaps lets change editor shortcuts, , not debugging shortcuts. or initial assessment keymap wrong , can use configuring debugging shortcut? if not keymap, there way change idea shortcuts? i think can edit relevant shortcuts under keymap > main menu > run

python - Splitting Lines and Lines -

so, wondering how split lines of file , put them list? tested out code works 1 segment of list not other chunks: the file looks like: rank ballots riding 0 ndp liberal green cpc ndp green liberal cpc cpc liberal green ndp ndp green liberal cpc riding 1 ndp liberal green cpc liberal green ndp cpc ndp green liberal cpc liberal green ndp cpc ndp green liberal cpc and forth. this code first half, riding 0: line = f.readline() while line !='': district = str.split(line) line = f.readline() a.append(district) print(a) and code did second half: header = f.readline().rstrip() riding = f.readline().rstrip() riding = f.readline().rstrip() votes = [] while riding !='': rank = str.split(riding) votes = [] while rank != '': votes.append(rank) rank = str.split(riding) riding = f.readline().rstrip() print(votes) riding = f.readline().rstrip() when print it's blank space. wonderi

xcode - Having trouble installing specific font in an iOS app - incompatible TTF? -

Image
there font files in code repo font nubian , nubian-alt. licensed , paid , need used. cannot use font in ios, , cannot open font font book though font previews ok in finder , identified truetype font. i started trying add nubian-medium ios app - using key "fonts provided application" in app's info.plist. font did not appear in list generated using: (nsstring *familyname in [uifont familynames]) { (nsstring *fontname in [uifont fontnamesforfamilyname:familyname]) { nslog(@"%@", fontname); } } i checked target's "copy bundle resources" build phase, saw font had been added list. i tried adding font have used in app, "chess-merida-unicode.ttf", check adding font correctly - copied app , added array of fonts provided application, saw appear in "copy bundle resources" list, reported available using above code snippet. next took @ font in os x - double-clicking open font book font not opened or added. when t

import - How to extract KML data from embedded Google Map -

we have map ski runs i want extract them kml file , import them google earth, can use on ski holiday. is possible? importing part easy, don't know how them.

android - Launch an SL4A script from an SL4A script -

i start background sl4a script (on remote device) within different sl4a script. can launch script terminal running this: $ start -a \ com.googlecode.android_scripting.action.launch_background_script -n \ com.googlecode.android_scripting/.activity.scriptinglayerservicelauncher -e \ com.googlecode.android_scripting.extra.script_path /sdcard/sl4a/scripts/main.py i can't translate startactivity call in python. the answer a different question on opening twitter client works nicely, don't know how extend code. example, how add script path, , put line com.googlecode.android_scripting/.activity.scriptinglayerservicelauncher ? this function launch sl4a script inside one. the first argument should path script want launch. script can in language have interpreter installed for. the second argument optional , should bool. defaults false . controls whether terminal visible, can see output , errors. not effect whether script has ui or not. from android import androi

javascript - php callback function to next page -

i'm using widget allow me execute callback php function after events. i want have php function allow me go next page using get method. from mypage.php?page=1 to mypage.php?page=2 to mypage.php?page=3 and on... i tought like $page = mysql_real_escape_string($_get['page']); // ==0 if no $_get['page'] function next_page($page) { header('location: mypage.php?page='.++$page.'');} i know using header tricky. might obvious i'd prefer reliable , scalable. maybe if execute javascript.location script. suggestions? $page = 0; if(isset($_get['page'])) $page = intval($_get['page']); function next_page($page) { $page ++; header('location: mypage.php?page='.$page); exit; } header shouldn't considered tricky. have make sure no output has been sent browser before using it.

r - XLConnect loadWorkbook error - POIXMLException (Java) -

i'm trying load hefty excel workbook (.xlsm format, ~30 mb) has large number of array calcs. > wb1 <- loadworkbook("mar_sp_20130227_v6.1.xlsm") error: poixmlexception (java): java.lang.reflect.invocationtargetexception but able load values-only/no-macro version of workbook. > wb2 <- loadworkbook("mar_sp_20130227_v6.1_values_only.xlsx") > wb2 [1] "mar_sp_20130227_v6.1_values_only.xlsx" what causing error? from maintainer's website can see there can issues workbooks containing array calcs or unsupported formula functions, doesn't same errror. java info: c:\> java -version java version "1.6.0_21" java(tm) se runtime environment (build 1.6.0_21-b07) java hotspot(tm) client vm (build 17.0-b17, mixed mode) it turns out root of error jvm running out of memory (even options(java.parameters = "-xmx1024m") ). i tried increase memory, couldn't jvm take more -xmx2048m , still wasn'

git - Yahoo Group and Bitbucket/GitHub? -

i automatically send email notification of git push action on bitbucket or github. used google group it, , works well. since google blocked in china, inconvenient manage mailing list. want switch yahoo group appears google group. my question how add bitbucket email "commits-noreply@bitbucket.org" in yahoo group? thanks!

Is it allowed to instantiate a class without specified variable name in C++ -

this question has answer here: most vexing parse 1 answer i have these 2 classes: class foo { public: foo() { std::cout << "in foo constructor" << std::endl; } }; class bar { public: bar() {}; bar(foo foo); private: foo m_foo; }; bar::bar(foo foo) : m_foo(foo) { std::cout << "in bar constructor argument foo" << std::endl; } int main() { bar bar(foo()); // wrong here ? return 0; } i compiled , excuted , nothing printed on screen, did bar bar(foo()) ? have seen similarity in do parentheses after type name make difference new? , foo f = foo(); // no matching function call 'foo::foo(foo)' , still can't figure out. to achieve same without changing semantics (ie. not using copy or assignment constructor ), add parentheses disambiguate syntax (the compiler not kno

asp.net - Call function from code behind in Global.asax -

how can access control or function asp page (code behind) in global.asax? i use below code background task, code check new emails every 60 seconds , want update label show new email's count in default.aspx void application_start(object sender, eventargs e) { addtask("checkemails", 10); } private void addtask(string name, int seconds) { oncacheremove = new cacheitemremovedcallback(cacheitemremoved); httpruntime.cache.insert(name, seconds, null, datetime.now.addseconds(seconds), cache.noslidingexpiration, cacheitempriority.notremovable, oncacheremove); }//addtask public void cacheitemremoved(string k, object v, cacheitemremovedreason r) { //check new emails , update label .aspx addtask(k, convert.toint32(v)); }//cacheitemremoved create seperate class common function, put in app_code folder, access function default.aspx , global.asax....

java - using SOAP web services with android 4.2 -

i developing application connects web services using soap, not make connection correctly activity: import java.io.ioexception; import android.os.strictmode; import android.os.asynctask; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.edittext; import android.widget.textview; import android.widget.toast; import android.app.activity; import android.app.progressdialog; import android.content.intent; import android.content.pm.activityinfo; import android.database.cursor; import android.database.sqlite.sqlitedatabase; import org.ksoap2.soapenvelope; import org.ksoap2.serialization.soapobject; import org.ksoap2.serialization.soapprimitive; import org.ksoap2.serialization.soapserializationenvelope; import org.ksoap2.transport.httptransportse; import org.xmlpull.v1.xmlpullparserexception; import com.google.gson.gson; public class autenticacion extends activity { //constantes para la invocacion del web service private static fina

c# - How do I use proxy in webkit-sharp i nMonoDevelop -

i want know how can detect if network computer connected has proxy, , if want able proxy address , port of network , use in web browser. i know cannot done through webkit's properties, , dlls need imported. so, have far: [dllimport("webkit-1.0")] static extern intptr webkit_get_default_session(); [dllimport("soup-2.4")] static extern intptr soup_uri_new(string uri); [dllimport("gobject-2.0")] static extern void g_object_set(intptr obj, string name, intptr value, intptr zero); as can see, have imported dlls needed, don't know next. i need this. if can give me link or give me codes can fulfill requirements have stated in beginning please give me. thanks lot. webkit not use connect internet, afaik rendering engine. underlying using sockets connect internet. .net search msdn httpwebrequest learn how request object makes use of proxies making request. also if computer software configured run via proxy in internet options, r

performance - OpenVZ, apache2 and wordpress: long first byte time -

i have openvz vps 400mb ram , 800mhz cpu. os debian 6. have install apache2 , wordpress. i test site perfomance using web tool. test results here: http://www.webpagetest.org/result/130405_04_5tf/ all works fine, first byte time long. can't understand why apache long time not give static content. why happening? can provide config files if needed. apache2.conf: lockfile ${apache_lock_dir}/accept.lock pidfile ${apache_pid_file} timeout 300 keepalive on maxkeepaliverequests 100 keepalivetimeout 15 <ifmodule mpm_prefork_module> startservers 1 minspareservers 1 maxspareservers 5 maxclients 10 maxrequestsperchild 0 </ifmodule> <ifmodule mpm_worker_module> startservers 1 minsparethreads 1 maxsparethreads 4 threadlimit 64 threadsperchild 25 maxclients 10 maxrequestsperchild 0 </ifmodule> <ifmodule mpm_event_module> startservers 1 maxclients 10 minsparethre

email - Always receive org.apache.http.NoHttpResponseException: The target server failed to respond Android -

i working on http post in android. here code: sendmail sending = (sendmail) new sendmail() .execute(url + "/mob/android/dummy.php"); public class sendmail extends asynctask<string, string, string> { private string endresult; @override protected string doinbackground(string... val) { string url = val[0]; log.i("url", url + ""); httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(url); try { cookiestore cookiestore = new basiccookiestore(); ((abstracthttpclient) httpclient).setcookiestore(cookiestore); list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("name", post_name)); namevaluepairs namevaluepairs.add(new basicnamevaluepair("email", post_email));

java - ScheduledExecuterService.scheduleAtFixedRate creating multiple thread pools - Android -

i have asynctask called uploadmanager in android application, checks processed items, , uploads them server. purpose i'm using scheduledexecutorservice.scheduleatfixedrate check items after every 1 minute, , upload them server. however, @ times, there multiple pools of thread created (this happens 10% of times), due @ times same request send twice server, though concurrency handled @ both server & client level, still don't want happen on client side. below how code looks like. in mainactivity (start-activity), initiate uploadmanager as: public class mainactivity extends baseactivity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); . . . new uploadmanager().execute(this); } } uploadmanager works follows: public class uploadmanager extends asynctask<context, integer, integer> { private scheduledexecutorservice scheduledexecutorservice; private stati

Javascript, Ajax and Alert Not Working -

i'm new javascript , ajax, , trying figure out why code below isn't working. <script type="text/javascript"> $(document).ready(function() { $('.cadlib').bind('click', function () { $.get("/models/"+this.id+"/viewmodelinfo/", function(data) { alert ("yo"); // line bellow doesn't execute if (data.fact_type=="t") { guess_result="this fact true! " + data.fact_note; } else { alert ("yo"); guess_result="this fact false! " + data.fact_note; } $('#result').replacewith("guess_result"); }); }); }); </script> here's html <a href = "#mysymbolmodal" class = "cadlib" id = "{{symbol.id}}" data-toggle="modal" style = "text-align:center; color: #ff761a;" href="/models/{{symbol.id}}/view_model/"><

jquery - Ajax-PHP not working correctly -

the ajax-php bug has bit me again.now here's problem send form data html php using ajax,(i'm using jquery this) , use data, play in php , give result. ajax call made successfully, issue not data being sent php data goes missing if interpreted correctly jquery/ajax code $(document).ready(function(){ $("#button").click(function(e){ e.preventdefault(); var data=$("#form").serialize(); console.log(data); $.ajax({ type:'post', url:('php/api.php'), data:"datastring="+data, success: function(d){ console.log("php response "+d); } }); }); }); and php <?php $data=$_post['datastring']; echo($data); ?> now here's output console first+name=first&last+name=second&some+detail=third&comments=fourth //output 1st console.log() statement php response first name=first //o

database - How to do search on a table while table have millions of record -

i have run below query in sybase database , return millions of record. when run took lot of time , many of times timeout. select * table1 t1 t1.oneid in ( select t2.oneid table2 t2 t2.twoid in ( select distinct t3.twoid table3 t3 ) ) @ isolation 0 so can 1 suggest me way can bulk operation getting data? try : select t1.* ( select distinct t3.twoid table3 t3 ) tmp inner join table2 t2 on t2.twoid = tmp.twoid inner join table1 t1 on t1.oneid = t2.oneid it should faster if have indexes on t2.twoid , t1.oneid

c# - CheckBoxList not working properly -

i have code. gives fales item.selected <asp:literal id="literalemployeelist" runat="server" /> <asp:linkbutton id="linkbuttonrecipients" runat="server">add/remove recipients</asp:linkbutton> <ajaxtoolkit:modalpopupextender id="modalpopupextenderto" runat="server" targetcontrolid="linkbuttonrecipients" dropshadow="true" popupcontrolid="panelemployeelist" okcontrolid="buttonok" enableviewstate="true"> </ajaxtoolkit:modalpopupextender> <asp:panel id="panelemployeelist" runat="server" width="200" height="100" scrollbars="vertical"> <div id="divpanelbody"> <div id="divlist"> <asp:checkboxlist id="checkboxlistemployee" runat="server" enableviewstate="true" onselectedin

design patterns - Processing attachments with Heroku and Mailgun Routes -

my webapp ruby on rails application deployed heroku. i use mailgun routes forward email web application. documentation mailgun routes here http://documentation.mailgun.net/user_manual.html#um-routes . basically mailgun routes posts stuff subject, body, senders etc http parameters. attachments posted file uploads encoded in multipart/form-data. in controller, show uploadedfile ( http://api.rubyonrails.org/classes/actiondispatch/http/uploadedfile.html ). in controller, proceed upload attachment(s) s3. however if there large attachments or many attachments, request time out (heroku's infamous h12 error). i tried using background worker (delayed job) ran these issues sending entire uploadedfile object or uploadedfile.tempfile background worker leads unreliable behavior (delayed job doesn't play nice large objects such model instances) sending path tempfile , trying open doesn't work since tempfiles accessible dyno on (tempfile stored in web worker dyno , acces

java - Please Help Fix My add Method -

it supposed keep contact_list in alphabetical order last name. have been @ hours , cannot figure out. added post both add method , findcontactindex method supposed find index of contact. keep getting nullpointer exceptions , other errors. need find out goes alphabetically , insert new contact there , move ones come after down, in correct order. public void add(contact frnd) { if(numcontacts == 0) { contact_list[0] = frnd; } else { for(int = 0; < numcontacts; i++) { int x =contact_list[i].getlastname().comparetoignorecase(frnd.getlastname()); if(x < 0) { contact_list[findcontactindex(contact_list[i].getlastname())] = frnd; break; } } } numcontacts++; } /** * searches contact_list find contact last name * @param lstnm last name of contact found * @return indexofcontact index of contact has been found */ public int findcontactind