Posts

Showing posts from September, 2013

How to edit cell value in VB.net - Using .Interop.Excel -

this simple question. have code: currentrow = 3 mycolumn = 2 currentcell = (currentrow & "," & mycolumn) workingsheet.cells(currentcell).value = (clientname & " " & "(" & clientlocation & ")" & " " & extradefinition) i thought place data on 'workingsheet' in position "b3" places data in cell "af1". why this? thanks, josh cell not expected used using it; have input row , column indices (as integers) separated comma. right code is: workingsheet.cells(currentrow, mycolumn).value = (clientname & " " & "(" & clientlocation & ")" & " " & extradefinition) another alternative have using range . example: workingsheet.range("b3").value = (clientname & " " & "(" & clientlocation & ")" & " " & extradefinition)

android - How to prevent double-click on refresh button -

i'm developing android app i've refresh button in action bar. button call function re-open same activity. activity contains asynctask load content. at moment i'm encountering problem. when click on refresh button works fine, if click on refresh button when asynctask still working (i've progress bar check status) app crashes. the error receive is: nullpointerexception is possible disable button until activity (and asynctask) loaded? in button's onclicklistener , execute asynctask , add code: button.setenabled(false); in onpostexecute() method of asynctask , place this: button.setenabled(true); if give 'cancel' option user(i.e. if have overridden oncancelled() method in asynctask ), enable button in oncancelled() . edit 1 : declare boolean flag in activity: boolean menubuttonisenabled = true; in onclicklistener , set flag false: menubuttonisenabled = false; in onpostexecute() method of asynctask : menubuttonisenable

.net - making sql query to get first id of a tourist and then all of it's surcharges -

i've got these tables in database: tourist - first table tourist_id - primary key excursion_id - foreign key name...etc... extra_charges extra_charge_id - primmary key excursion_id - foreign key extra_charge_description tourist_extra_charges tourist_extra_charge_id extra_charge_id - foreign key tourist_id - foreign key reservations reservation_id - primary key ..... tourist_reservations tourist_reservation_id reservation_id - foreign key tourist_id - foreign key so here example: i've got reservation reservaton_id - 27 reservation has 2 tourists tourist_id - 86 , tourist_id - 87 tourist id 86 has charges extra_charge_id - 7 , and extra_charge_id - 11; tourist id 87 has charge id - 10; is possible make sql query , name , id of tourist , of charges sothe output like: tourist_id: 86, name:john, charges: 7,11 (here query made extra_charge_description of of tourists reservation_id = 27 ) select extra_charges.extra_charge_description,touri

c# - Why does this not display the display name? -

i'm trying display displaynames properties in html in asp.net mvc 4 application. though i've set displaynames in viewmodel raw variable names still gets displayed instead. the viewmodel: public class manage_managepasswordviewmodel { [display(name="name")] public string name; [display(name = "subid")] public string subid; [display(name = "conversions")] public int conversions; [display(name = "password")] public string password; public userprofile owner; public manage_managepasswordviewmodel(protectedpassword pw) { name = pw.name; subid = pw.subid; conversions = pw.getconversions(); password = pw.password; owner = pw.owner; } } the cshtml file: @model areas.admin.models.viewmodels.manage_managepasswordviewmodel <div class="editor-label"> @html.displaynamefor(m => m.name): @html.displaytextfor(m => m.name) <

.net - AppFabric NHibernate provider does not forward requests to DB if Cache Cluster fails -

i've given assignment setup appfabric 2nd level caching using nhibernate appfabric cache provider (by simon taylor ). i've setup , it's working. in failure scenario, if cache cluster or whole service stops working (assuming have 1 cache server) application requests don't forward database. when restart cluster, application works intented. so, despite having 1 cache server isn't practically right, should make application use db in such failure cases? any suggestions appreciated.

javascript - PHP - How to avoid "echo" HTML when there is a need for conditional html blocks for example -

echoing html blocks in php pain, echoed parts not marked , parsed ide's since it's string. deficiency makes difficult edit , change echoed html (especially javascript). wonder if there elegant solution except using include in such cases. here example using alternative if-syntax: <?php if($a == 5): ?> <p>a=5</p> <?php endif; ?>

Convert string to image in python -

i started learn python week ago , want write small programm converts email image (.png) can shared on forums without risking lots of spam mails. it seems python standard libary doesn't contain module can i`ve found out there's pil module (pil.imagedraw). my problem can't seem working. so questions are: how draw text onto image. how create blank (white) image is there way without creating file can show in gui before saving it? thanks :) current code: import image import imagedraw import imagefont def getsize(txt, font): testimg = image.new('rgb', (1, 1)) testdraw = imagedraw.draw(testimg) return testdraw.textsize(txt, font) if __name__ == '__main__': fontname = "arial.ttf" fontsize = 11 text = "example@gmail.com" colortext = "black" coloroutline = "red" colorbackground = "white" font = imagefont.truetype(fontname, fontsize) width, heigh

c++ - Fastest way to split a word into two bytes -

so fastest way split word 2 bytes ? short s = 0x3210; char c1 = s >> 8; char c2 = s & 0x00ff; versus short s = 0x3210; char c1 = s >> 8; char c2 = (s << 8) >> 8; edit how about short s = 0x3210; char* c = (char*)&s; // c1 = c[0] , c2 = c[1] let compiler work you. use union , bytes split without hand made bit-shifts. @ pseudo code: union u { short s; // or use int16_t more specific // vs. struct byte { char c1, c2; // or use int8_t more specific } byte; }; usage simple: u u; u.s = 0x3210; std::cout << u.byte.c1 << " , " << u.byte.c2; the concept simple, afterwards can overload operators make more fancy if want. important note depending on compiler order of c1 , c2 may differ, known before compilation. can set conditinal macros make sure order according needs in compiler.

JQuery UI draggable within a triangle -

i have div (it's rectangle of course) image of triangle background. want move image of circle inside triangle. i chose jquery ui's draggable use couldn't manage constrain draggable image within triangle. i thought should use containment option array can't define triangle 2 coordinates. then found topic: constrain within triangle there answer pretty uses sinus curve , i've got no idea how define triangle path use. anyone can how should constrain circle's movement triangle? one of friends came simple , nice solution: see it $( "#circle" ).draggable({ drag: function(e, ui) { var width = $('#triangle').width(); var height = $('#triangle').height(); var x = ui.position.left + $(this).width() / 2; var y = ui.position.top + $(this).height() / 2; var difference = math.abs( x - width / 2 ); var min_y = height * ( difference / (width / 2) ); if ( y < min_y ) y = min_y; if ( x <

php - Variable inside curly brackets -

i know how execute php variable inside quotes $q1 = 1; $q2 = 2; $q3 = 3; $q4 = 4; $q5 = 5; echo "${q1}"; //outputs 1 how can output them in loop? for($i=1; $i<=5; $i++) { echo "${q$i}"; //how make $i work here? } how make $i work along $q ? update i want quotes there, because creating string in loop , want pass loop mysql query. want string $str = '$q1, $q2, $q3'; and when pass mysql query should interpret values of $q1, $q2, $q3 1,2,3 mysql_query("insert users (col1, col2, col3) values ($str)"); so should become mysql_query("insert users (col1, col2, col3) values (1,2,3)"); it example know syntax of mysql_query wrong know i think looking this: <?php $arr = array(); $q1 = 1; $q2 = 2; $q3 = 3; $q4 = 4; $q5 = 5; for($i=1; $i<=5; $i++) { $arr[] = ${"q".$i}; } $str = implode($arr, ','); print_r($str); outputs: 1,2,3,4,5 in action: http://codepad.org/ep7s

c++ - QDial change position indicator text -

Image
i use qdial control input time values in sec. how change automatically added text shows in middle of these dials? edit: come qtcurve style. if there no code in program explicitly display integral value (in signal/slot), may current qt style it. see following examples of qt styles see display of integer not part of qdial display: http://qt-project.org/doc/qt-4.8/gallery-plastique.html http://qt-project.org/doc/qt-4.8/gallery-cde.html http://qt-project.org/doc/qt-4.8/gallery-gtk.html http://qt-project.org/doc/qt-4.8/gallery-cleanlooks.html http://qt-project.org/doc/qt-4.8/gallery-windowsvista.html http://qt-project.org/doc/qt-4.8/gallery-macintosh.html see: http://qt-project.org/doc/qt-4.8/qstyle.html more info on styles. you can in program code following code: qapplication::setstyle(...); you check following: qt_style_override environment variable -style= argument passed program if still don't find how style set, may default style platfo

cocos2d iphone - How remove color of ccsprite? -

Image
i had applied color ccsprite. sprite initilize image of green color. after applied red color it. how remove red color , bring original image color? suppose original image now when apply red color it, colored red. question how remove color applied? the code use ccsprite *ballsprite=[[ccsprite alloc]initwithfile:@"ball.png"]; ballsprite.color=ccred; simple: allsprite.color = ccwhite;

c# - query time-out after database restore -

i have clr compiled stored procedure in sql server 2008 has worked fine. after database restore stopped working. times out. running query same parameters ssms takes 2 seconds complete. i've dropped , recreated it, tried dbcc freeproccache , rerun, no avail. keeps timing out. cant take down db used heavily. since clr compiled sp doubt parameter sniffing problem. does know do? have tried command? alter database somedatabase set trustworthy on

asp.net mvc - Purpose of namespace section in web.config in the root folder -

so understand namespaces defined in ~/views/web.config add namespaces views. why there namespace section in ~/web.config in root folder`? every view inherit namespaces in ~/web.config . potentially build different namespace hierarchies using different levels of config files.

javascript - Problems transforming toolbar on CKEditor -

this code display ckeditor4: <script type="text/javascript"> ckeditor.replace( 'description', { toolbar: 'basic' }); </script> this works fine , gives following options: bold, italic, ordered list, unordered list, indent, outdent, link, unlink, ckeeditor my question is, without linking external config file, , using code above, how can make have following options: bold, italic, unordered list, ordered list this code tried broke editor (it didn't display): <script type="text/javascript"> ckeditor.replace( 'description', { toolbar = [ { name: 'basicstyles', items: [ 'bold', 'italic' ] } { name: 'paragraph', groups: [ 'list'] }, ]; }); </script> can show me have gone wrong please? you're missed semicolon between objects in array. you can remove unnecessary buttons .removebuttons property: config.removeb

components - Spring: Properly setup @ComponentScan -

i have following set spring application context . @configuration public class rmicontext { @bean public rmiproxyfactorybean service() { rmiproxyfactorybean rmiproxy = new rmiproxyfactorybean(); rmiproxy.setserviceurl("rmi://127.0.1.1:1099/service"); rmiproxy.setserviceinterface(service.class); return rmiproxy; } } @configuration public class localcontext { @bean public controller controller() { return new controllerimpl(); } } @configuration @import({rmicontext.class, localcontext.class}) public class maincontext { } the above setup works fine, want enable @componentscan annotating controller s @component there many controller s in application tedious when declared 1 one using @bean . @configuration @componentscan(basepackageclasses = {controller.class}) public class localcontext { /* ... */ } problem when @componentscan(basepackageclasses = {controller.class}) , fine working rmiproxyfactorybea

c - Wireless-tools for linux to scan for wireless devices without them being connected -

is possible use wifi router scan existing wireless-capable devices (e.g. smartphones) have wi-fi enabled on scanning mode, not connected anyone. my ultimate goal using openwrt on tp-link wireless router , scanning mobile phone devices in surrounding area. so can done without them connecting device? using wireless-tools, libiw library? thanks what want called "passive scanning". de-facto standard linux utility kismet , distribution's package manager has package. depending on used hardware may work in parallel acting regular router. mose w-lan interfaces can not operate in passive mode , master mode @ same time.

android - Storing date-time values -

from this link read best data type storing date-time values in sqlite integer . what best format should used store current date , time said attribute? simpledateformat accepts strings, yet datatype integer . you store time in milliseconds. retrieve date object simpledateformat , equivalent value in ms long milliseconds = date.gettime (); . store milliseconds

c# - GridView with columns and rows swapped -

i using gridview. requirement - name c1 c2 c3 c4 age 24 25 26 27 gender m f m f i didn't solution. please suggest correct solution. do need create new usercontrol this? try http://www.aspdotnet-suresh.com/2012/09/how-to-convert-rows-to-columns-in-sql.html or try create view bind data ur gridview .

java - Is there a language-independent way to add a function to JSR223 scripting bindings? -

the jsr223 bindings class allows expose arbitrary java objects scripting languages. have objects. define function quit() can called scripting environment turns quitobject.run() in java. jsr223 doesn't define concept of function object. there language-independent way following in javascript, namely take runnable() , create function in scripting environment? static private object asfunction(scriptengine engine, runnable r) throws scriptexception { final bindings bindings = engine.createbindings(); bindings.put("r", r); return engine.eval( "(function (r) { var f = function() { r.run(); }; return f;})(r)", bindings); } runnable quitobject = /* get/create runnable here */ bindings bindings = engine.createbindings(); bindings.put("quit", asfunction(engine, quitobject)); with builtin javascript support jsr223 creates sun.org.mozilla.javascript.internal.interpretedfunction want. won't

c++11 - Passing by reference to std::thread c++0x in VS2012 -

void threadfn(int& i) { cout<<"hi thread "<<i<<endl; } int x = 0; void createthreads(vector<thread>& workers) { for(int = 0; i< 10; i++) { workers.push_back(thread(&threadfn, x)); } } i expecting compilation error in thread creation ( workers.push_back(thread(&threadfn, x)); ) since x should passed ref. though right syntax should've been: workers.push_back(thread(&threadfn, std::ref(x))); of course, code compiles fine , behaves properly. using vc11 . idea why isn't being flagged? this vc11 bug, thread object makes internal copies of arguments (as should) doesn't forward them threadfn function correctly, happens reference binds thread object's internal int member. gcc's std::thread used have similar bug because used std::bind implement it, replaced use of std::bind different implementation detail forwards captured arguments function value.

c++ - How to split a full=number into two groups according to their position(even or odd) -

this question has answer here: how split full=number 2 groups according position(even or odd) 2 answers my input 4 1 2 3 4 5 6 7 8 what want split 2 groups. how split full=number 2 groups according position(even or odd) asked here.ithought answer correct.when check boy[3]; there seems problem.here code,i cannot find mistake?what should out 8 #include<fstream> #include<iostream> using namespace std; int main(){ ifstream ifs("q3_in.txt"); int g; ifs>>g; int boy[g];int girl[g]; int =0; int b = 0; for(int i=0;i<g;i++){ if(i%2) ifs>>boy[b++]; else ifs>>girl[a++]; } cout<<boy[3]; system("pause"); return 0;} i < g*2 solution. input size 2*g not g.

performance - Jmeter 2.9 in distributed testing mode - cannot see response data in View Results Tree -

i have jmeter-client on local windows-based machine , jmeter-server on ubuntu-based machine in amazon aws. it works well. can generate load , results in csv-files on local machine. have little problem. when use it, can`t see response data server in csv files , in view result tree. see response code - it's 200 ok, see latency, response time etc. when try test local machine, without jmeter-server, looks good, , can see response data. can please me? since jmeter 2.9: distributed testing uses mode_stripped_batch, returns samples in batch mode (every 100 samples or every minute default). note mode_stripped_batch strips response data sampleresult, if need change mode (mode property in jmeter.properties) usually full responses not useful during load test , impact negatively performances of jmeter, sure need them

selenium - Webdriver/Firefox - how to specify another firefox installation -

i want create instance of firefox, not place looking - "/usr/bin/firefox", "/opt/firefox/firefox" how can here: firefoxbinary firefox = new firefoxbinary(); firefox.setenvironmentproperty("display", "0"); webdriver driver = new firefoxdriver(firefox, null); the constructor of firefoxbinary takes file argument! file ffexe = new file("path/to/exe"); firefoxbinary firefox = new firefoxbinary(ffexe);

active directory - AD RMS Managed Code Error The system cannot find the file specified. HRESULT: 0x80070002 -

i'm new active directory rights management services (ad rms) , i'm developing application use ad rms encrypt documents. i'm using interop example , error - system cannot find file specified. hresult: 0x80070002 - when try run code below: i error when try run statement: collection ipctemplates = ipc.gettemplates(); internal static class ipc { static ipc() { safenativemethods.ipcinitialize(); } public static collection<templateinfo> gettemplates() { collection<templateinfo> templates = null; try { templates = safenativemethods.ipcgettemplatelist(null, true, true, false, false, null, null); } catch (exception /*ex*/) { /* todo: add logging */ throw; } return templates; } } stack trace: the system cannot find file specified. hresult: 0x80070002 @ microso

javascript - PHP / JS Document viewer within browser -

i have many different document filetypes should downloadable users. these include presentations, pdf, excel etc etc. may mac filetypes too. i'd possible if user can view document before downloading it. i've hunted around found nothing except extension specific posts. any appreciated there 3 ways present content user: content-disposition: attachment — tells browser should saved rather displayed content-disposition: inline — tells browser should displayed (either natively or plugin) rather saved via scripting / applets / flash / etc — in provide program code render content the first 2 approaches generic http. third has handled on file-type file-type basis since need different renderers each kind of content.

camera - How to take pictures in android application without the user Interface..? -

i have design application, application has take picture camera without displaying in layout , without user interface (like click of button....) , store picture? camera mcamera; private boolean safecameraopen(int id) { boolean qopened = false; try { releasecamera(); mcamera = camera.open(id); qopened = (mcamera != null); } catch (exception e) { log.e(getstring(r.string.app_name), "failed open camera"); e.printstacktrace(); } return qopened; } private void releasecamera() { if (mcamera != null) { mcamera.release(); mcamera = null; } } //somewhere in code call this: mcamera.takepicture(null, null, mcall); camera.picturecallback mcall = new camera.picturecallback() { public void onpicturetaken(byte[] data, camera camera) { //decode data obtained camera bitmap fileoutputstream outstream = null; try { outstream = new fileoutp

.net - Async Await Handler Deadlock -

i'm stuck in async deadlock , can't figure out correct syntax fix it. i've looked @ several different solutions, can't seem quite figure out causing problem. i using parse backend , trying use handler write table. handler looks like: public class visitorsignuphandler : ihttphandler { public void processrequest(httpcontext context) { //get user's name , email address var userfullname = context.request.querystring["name"].urldecode(); var useremailaddress = context.request.querystring["email"].urldecode(); //save user's information var tasktoken = usersignup.saveusersignup(userfullname, useremailaddress); tasktoken.wait(); .... } public bool isreusable { { return false; } } } then calling middle tier: public static class usersignup { public static async task saveusersignup(string fullname, string emailaddress) { //initialize parse client appl

Default Values - Java Clarification -

why aren't default values assigned variables, haven't been initialized within class main function??? class test { public static void main(string[] args) { int x;// x has no default value string y;// y has no default value system.out.println("x " + ); system.out.println("y " + ); } } whereas default values assigned in case variables remain uninitialized in class without main function. class student { string name; // name has default value null int age; // age has default value 0 boolean issciencemajor; // issciencemajor has default value false char gender; // c has default value '\u0000' int x; string y; } be aware code in question represents different situations. in first case, variables local , exist inside main() method. in second case you're declaring instance attributes , not local variables. in java, attributes initialized automatically default values. in

How to get the height and width of an image when android:minSdkVersion="8" -

normally, can use following code width of image, require api level 16. how height , width of image when android:minsdkversion="8" cursor cur = mycontext.getcontentresolver().query( mediastore.images.media.external_content_uri, null, mediastore.images.media._id + "=?", new string[] { id }, ""); string width=cur.getstring(cur.getcolumnindex(mediastore.images.media.height)); pass option decode bounds factory: bitmapfactory.options options = new bitmapfactory.options(); options.injustdecodebounds = true; //returns null, sizes in options variable bitmapfactory.decodefile("/sdcard/image.png", options); int width = options.outwidth; int height = options.outheight; //if want, mime type decoded (if possible) string type = options.outmimetype; or you can height , width of imageview using getwidth() , getheight() through while not give exact width , height of image, getting image width height first

javascript - Firefox Close Event from Extension -

how can detect when main firefox window closed extension? you can listen few different observer notifications find out: https://developer.mozilla.org/en-us/docs/observer_notifications the 1 want quit-application.

eclipse - Android post innexplicable error -

i trying post user , password php file situated on remote server , android gives me exception not understand. i mean, code looks this: string url_connect = "http://myhost.com/mylogin.php"; boolean result_back; public boolean loginstatus(string username ,string password ) { int logstatus=-1; arraylist<namevaluepair> postparameters2send= new arraylist<namevaluepair>(); postparameters2send.add(new basicnamevaluepair("uzer",username)); postparameters2send.add(new basicnamevaluepair("pass",md5(password))); jsonarray jdata=post.getserverdata(postparameters2send, url_connect); ... more code here } and error in logcat error in http connection: java.net.unknownhostexception: myhost.com but problem is... if copy entire url_connect string declared above, , paste browser... works fine. why eclipse throw me error? how can fix this? my androidmanifest.xml is: <?xml version="1.0" encoding="utf-8"?> &l

mysql - YII Inventory Control system issue -

Image
guys me this. i'm new yii. want display each item branches stock this. actual database what best way this? what looking cross tab or pivot table. here link: http://www.artfulsoftware.com/infotree/qrytip.php?id=523

javascript - Angularjs how to pass in data using a directive -

what trying make function can change height of ng-grid column width. irrelevant besides fact scope controller needs communicate scope in directive. .directive('getwidth', function(){ return{ controller: 'quotesctrl', link: function(scope){ scope.smrowheight = function(the value want){ scope.therowheight = value want; } } } }) and want able go html , hey div want height 20 <div getwidth = '20'></div> i have looking around , couldn't find doing exact thing. , way, in quotesctrl initialized row height so $scope.therowheight; any suggestions? try this: .directive('getwidth', function(){ return{ controller: 'quotesctrl', link: function(scope){ console.log(scope.therowheight); }, scope: { 'therowheight': '=' } } }); markup: <div the-row-height=

Insertion sort c++ vectors -

void insertion_sort(int *data, unsigned int n) { (unsigned int uns = 1; uns < n; ++uns ) { int next = data[uns]; unsigned int idx; (idx = uns; idx > 0 && data[idx - 1] > next; --idx) { data[idx] = data[idx - 1]; } data[idx] = next; } } int main() { vector<person> crew= ucitaj_osobe("osobe.txt"); /*this reads file osobe.tx , stores in vector crew,this works */ person o; insertion_sort(polje, 100); // ??? ispisi_osobe(popis); /* prints out vector,this works too*/ return 0; } how send vector insertion sort,and sort it? please help,the code insertion sort implemented source your function insertion_sort implemented sort arrays of int , function not work sorting of vector of person objects. if want sort vector of person objects suggest use std::sort standard library. use must implement < operator person objects. example: // demonstrate.

CSS: Transition on shadow filter -

so i'm trying cast shadow onto non-rectangular object in png file transparency. works far, when try add transition effect on hovering on image, filter seem max out set value , bounce actual set value when timer transition feature up. i'm running chrome 28 mac appears on safari. i have demonstrated effect here: http://jsfiddle.net/dbananas/3pms8/ transition: 0.2s ease-in-out; -webkit-filter: drop-shadow(0px 0px 13px rgba(0, 0, 0, 0.9)); recommendations fix , make transitions smooth? thanks, db i'd check see if works , happens in firefox. if had guess, i'd it's bug in webkit (checking in firefox can confirm it's browser bug , not bug in code). can file bug report here: https://bugs.webkit.org/ that said, in order work around it, might have reconsider how you're going solving problem. for example, if you're doing text, can use text-shadow property, animatable. if it's actual image, resort making "shadow image" fade

php - paging with sql srv -

i have found following code show 25 persons on every page. shows pagenumbers on top of page depending of results. eksempel: 1 2 3 4 5 6 7 8 9 10 osv. but this: example: 1 2 3 4 5 next if click on "5" example: forrige 3 4 5 6 7 næste has "ceil" function do? $conn = sqlsrv_connect("localhost", array("database"=>"test", "uid"=>"test", "pwd"=>"test")); $rowsperpage = 25; $tsql = "select count(id) persons"; $stmt = sqlsrv_query($conn, $tsql); $rowsreturned = sqlsrv_fetch_array($stmt); if($rowsreturned === false) { echo "error in retrieving number of rows."; die( print_r( sqlsrv_errors(), true)); } elseif($rowsreturned[0] == 0) { echo "no rows returned."; } else { $numofpages = ceil($rowsreturned[0]/$rowsperpage); for($i = 1; $i<=$numofpages; $i++) { $pagenum = "?pagenum=$i"; if ($_get["pagenum"] == $i) {

java - Parsing JSON Data (Android) -

alright. have json object sent me server contains following data: { "result": [ {"status":"green","type":"data1"}, {"status":"green","type":"data2"}, {"status":"green","type":"data3"} ], "status":"ok" } the data want status 3 status values. data1, data2, , data3 show in order, i'm trying grab data index (e.g. data1 = index 0, data2 = index 1, data3 = index 2). how do that? try following: string stat1; string stat2; string stat3; jsonobject ret; //contains original response //parse value try { stat1 = ret.getjsonarray("results").getjsonobject(0).getstring("status"); stat2 = ret.getjsonarray("results").getjsonobject(1).getstring("status"); stat3 = ret.getjsonarray("results").getjsonobject(2).getstring("status&quo

sql - How to get multiple counts based on different criterias -

i need making query found site first time , hoping here knows how it. lets database has 3 columns (name,type,and decision). in name field there 100 records , there can duplicates. there 2 different types (online , offline), , 2 kinds of decisions (match or mismatch). what need count of matches , mismatches each type, grouped name. the table columns below: name|online match count|online mismatch count|offline match count|offline mismatch count| also if of fields have count of 0, want display 0 well. does know how this? appreciate it. this common technique , called pivot query. select name, sum(case when type='online' , decision='match' 1 else 0 end) "online match count", sum(case when type='online' , decision='mismatch' 1 else 0 end) "online mismatch count", sum(case when type='offline' , decision='match' 1 else 0) "offline match count", sum(case when type='offline'

spring - Jackson Json Object mapper : how to map an array? -

i trying map array backend api call. how can map data knowing : the following classes used hold json array data : @data private static class userlistbean { private list<userbean> userlist; } @data private static class userbean { private string id; private string username; private string password; } the json have following format (the following example have 1 item in it) : [ { "id":1, "username":"bob", "password":"403437d5c3f70b1329f37a9ecce02adbbf3e986" } ] i using jackson , have tried following far keeps sending me exception final objectmapper mapper = new objectmapper(); mapper.configure(feature.fail_on_unknown_properties, false); final objectreader reader = mapper.reader(userlistbean.class); geohubaccountlistbean accounts = null; try { accounts = reader.readvalue(jsonstring);

javascript - D3.js enter transition for path not working -

i using d3 create line graph visualization bunch of data. data line comes array of objects, , use function translate data svg path can displayed: this.line = d3.svg.line() .interpolate('linear') // .x(function(d,i) {return x(d['date']);}) .x(function (d,i) {return x(i);}) .y(function (d,i) {return y(d[this.key]) - this.yoffset;}); however, if leave data single array of objects (and set data point path), not able use enter , exit transitions add/remove segments composing line if data set changes size. so, solve issue, use function split array of points 2d array: array of arrays of length 2 each contain start , end point 1 particular segment of line, , use array data path, each segment on screen bound separately own 2-element array. when call setdata , enter, path draws should. however, when update data update function (in case transitioning longer data set), path goes through appropriate update , exit transitions, shows key function supplied whe

class - what is the correct way to add classes to a controller in rails? -

if need add (project specific) classes controler in rails, correct way/place put , "include" them/there .rb files? (quotes for: not ruby keyword include) i new rails, , did not find the correct way. lib sounds more public libraries , - have learned - not reloaded per default in dev mode. sure, put in controler.rb, ... the anser me: first: there no rules, if keep in mind (or learn me) rails rules: nameofcla -> name_of_cla(.rb) <-- not using class word clearence name class how like: class extendcon #<--- not using controller here clearence .... put in file extend_con.rb , wait path explaination, please. if named class 'mygreatthing' 'm_y_great_thing' (never testet that), avoid chineese charachters if controller uses @letssee=extendcon.new rails learns class , file (extend_con) on own. still did not figure out if server restart needed. (the first time) choose path put file: (i preferre daves way) app/myexten or like, ma

using the time function for srand in pseudo-random number generator in c -

#include <time.h> ((unsigned)time(null)); i don't understand why have include time header file , use time function in program when creating pseudo-random number generator using function srand(). can please explain significance of time in case? * please note code shown part of program. thank you. it makes code non-repeatable when called second time. if include no seed or fixed number seed, program act same, because random number same.

ruby on rails - authenticate_or_request_with_http_token fails even when the token matches -

def restrict_access # raise apikey.exists?(access_token: params[:token]).to_s authenticate_or_request_with_http_token |token, options| apikey.exists?(access_token: token) end end apikey.exists?(access_token: token) returns true , yet every time def called returns http token: access denied. , have no idea why. can hard code correct token , still fails. seems in dev , test, works in prod scares me. started happening seemingly out of blue. can't debug within authenticate_or_request_with_http_token block, it's kicking me out before apikey.exists?() executed. i've looked @ source it's not helpful me. https://github.com/rails/rails/blob/04cda1848cb847c2bdad0bfc12160dc8d5547775/actionpack/lib/action_controller/metal/http_authentication.rb#l393 there note in docs, maybe have problem: on shared hosts, apache doesn’t pass authentication headers fcgi instances. if environment matches description , cannot authenticate, try rule in apache setup:

Create 3 html form xml regarding <app> element -

if have xml document, in wich have code: <app> <lem>nuvem<lem> <rdg w=x>novem</rdg> <rdg w=y>nuvens</rdg> </app> is there way insert code in xsl 2.0 produce 3 version html of same xml, choosing lem rdg (let's version z), or x rdg or y rdg text , open window in wich have tree version, smt like: z nuvem x novem y nuvens. thanks

javascript - Disqus throws JS error and doesn't work when logged in -

i'm @ wits end one, can me. i have website running wordpress (latest version, up-to-date) own custom theme. i trying add disqus comments it. have installed disqus plugin wp , have done setup. however, experiencing error whenever logged disqus. when iframe loads js error thrown on console stating (from chromes console) uncaught typeerror: cannot call method 'insertbefore' of null client.js:106 (anonymous function) client.js:106 backbone.view.extend.updatedom client.js:144 backbone.view.extend.updatedom client.js:168 u.alert client.js:106 n.extend._alertmustverify client.js:191 n.extend.render client.js:190 n.extend.redraw client.js:187 b

jquery - trying to remove a class when image is clicked -

i'm try remove class jquery when image clicked can seem work. i'm using $(this).removeclass('.title'); to remove class it's not working. .title{ font-size: 100%; top: -40px; color: white; left: 0%; position: absolute; z-index: 1; } here's jsfiddle . its not $(this).removeclass('.title'); its $(this).removeclass('title'); you must not use . when you're using addclass , removeclass , toggleclass . , metioned other answerers, in demo, class title not applied li , div . must remove title : $(this).find("div").removeclass('title'); demo : http://jsfiddle.net/hungerpain/xyzzx/39/

Android : java.lang.IllegalArgumentException: column '_id' does not exist -

cursor ck = db.rawquery("select name,title,text,type abstracts_item,abstract_author,authors_abstract abstract_author._id == authors_abstract.abstractauthor_id , abstracts_item._id == authors_abstract.abstractsitem_id", null); i run same query other sqlite tool. works fine. but, when try use cursor . got error java.lang.illegalargumentexception: column '_id' not exist i got many solutions. but, nothing worked me. happy, if guys me solve that. the sql language not use == rather = . so s/b: cursor ck = db.rawquery("select name,title,text,type abstracts_item,abstract_author,authors_abstract abstract_author._id = authors_abstract.abstractauthor_id , abstracts_item._id = authors_abstract.abstractsitem_id", null); you increase performance using inner joins rather clause: cursor ck = db.rawquery("select name,title,text,type abstracts_item inner join abstract_author on abstract_author._id = authors_abstract.abstractauthor_id

using $(this).each inside a plugin not working jquery -

i have simple plugin $(this).each() not working, calls once instead of onve each of selector $("input.[class~='checking']") bascailly want call each once each input box class of "checking" , totally lost why not working (function ($) { moshclass = '' $.fn.ischeckedmo = function (moshclass) { $("input.[class~='" + moshclass + "']").hide(); $(this).click(function () { var amchecked = 0 $(this).each(function () { if (this.checked == true) { alert('am:' + amchecked) amchecked = amchecked + 1 } }); if (amchecked > 0) { $("input.[class~='" + moshclass + "']").show(); } else { $("input.[class~='" + moshclass + "']").hide(); } }); } })(jquery)

html - element flickering on iphone when jquery.on('click') is used -

consider following js: $('#main').on('click', '.button', function); and corresponding html: <div id="main"> <span class="button">button</span> </div> this works fine far. when element class button clicked, child of main element, function called. unfortunately when viewed iphone, every tap on main element, causes flicker once. i found out can avoided not binding click event #main, entire $(document). i haven't found issue online far. know going on , if there nicer solution binding every click element document? * { -webkit-tap-highlight-color: transparent; } adding css solve problem.

java - Having for loop output sets of numbers? -

i have following code (int k=0; k<maxthreads; k++) { int firstpart = k * tasksperthread; int secondpart = ((k+1) * tasksperthread) - 1; system.out.println(firstpart + "," + secondpart); } where maxthreads inputted user , tasksperthread 10/maxthreads. maxthreads never less 1. outputs pairs of numbers. example, if maxthreads = 2 (making tasksperthread = 5) outputs 0,4 5,9 covering ten values 0-9 i want ten values covered if maxthreads = 4. right code outputs this 0,1 2,3 4,5 6,7 but cover 0-9. ideally output 0-2 3-5 6-7 8-9 or combination has maxthreads number of sets of numbers , covers 0-9. how can adjust loop this? thank you. it being rounded down think, try using ceiling.

indexing - Slow query after upgrade mysql from 5.5 to 5.6 -

we're upgrading mysql 5.5 5.6 , queries deadly slow now. queries took 0.005 seconds before taking 49 seconds. queries on 5.6 skipping indexes, seems: +----+-------------+-------+-------+----------------------------------------------------+---------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | | +----+-------------+-------+-------+----------------------------------------------------+---------+---------+------+--------+-------------+ | 1 | simple | pens | index | index_contents_on_slug,index_contents_on_slug_hash | primary | 4 | null | 471440 | using | +----+-------------+-------+-------+----------------------------------------------------+---------+---------+------+--------+-------------+ 1 row in set (0.00 sec) but not being skipped on 5.5: +----+-------------+-------+-------------+------------------------------------------------

java - local variable made final in method of a class -- but why? -

today while searching piece of code google, came across 1 q/a blog, been said can declare local variable inside method of class final. however, author reluctant enough explain need/ benefit of doing so. like public class { private void show() { final string s="checking"; } } i seek java gurus' educate me on this. in advance kind support , guidance. best regards! in addition other answers, making variable final enables use of variable in inline implementation of classes , interfaces: final string test = "test"; foo = new foo() { public void bar() { system.out.println(test); } }; edit: if beginner might worth pointing out variable in fact reference instance . when make variable final in fact making reference constant, is, final variable can never refer other instance after initialization. makes no claims whether actual referenced instance constant. for example, if final string[] foo = { "ba

Google Maps Display in Android: +/- symbols visible, no map -

Image
for reason, have google maps application attempting run, gives me grey screen , +/- options map. i've used 2 guides extensively, , continue have same problem. i've googled extensively, , seems issue must api console or dependencies, , i've included screenshots of those: must noted storing these files in folder syncs dropbox - don't know if that's bad thing or not. when export android application, i'm using keystore made, , alias made. doing because trying run on phone opposed emulator (because i've heard play isn't working emulators). i'm extracting so: and finally, here's console: here's manifest: <uses-sdk android:minsdkversion="13" android:targetsdkversion="17" /> <permission android:name="com.hotspotprime.permission.maps_receive" android:protectionlevel="signature" /> <uses-permission android:name="com.hotspotprime.pe

How to use MySQL to return a concatenated string? -

i using custom built version of data tables list records tables. of time wonderful need join 2 or more tables show specific data lookup tables. here new problem. have 3 tables... event_categories, themes, , themes_eventcategories. event_categories , themes normal tables , themes_eventcategories has fields 'id', 'theme_id', , 'event_category_id'. what need list of event categories , if there themes associated event category, need themes in comma separated string. possible? what want group_concat , maybe like: select event, group_concat(theme) themes_eventcategories join event_categories b on a.event_category_id = b.id join themes c on a.theme_id = c.id group event

vim - Vimscript: Number of listed buffers -

in vimscript, need count of buffers considered listed/listable (i.e. buffers not have unlisted, 'u', attribute). what's recommended way of deriving value? you use bufnr() number of last buffer, create list 1 number , filter removing unlisted buffers, using buflisted() function test expression. " 'possible' buffers may exist let b_all = range(1, bufnr('$')) " unlisted ones let b_unl = filter(b_all, 'buflisted(v:val)') " number of unlisted ones let b_num = len(b_unl) " or... @ once let b_num = len(filter(range(1, bufnr('$')), 'buflisted(v:val)'))

for loop - Unknown error in java code -

okay, earlier posted this thread asking how make multiple values out of loop. after while ran problem, wich don't know how fix nor know why happend. code have: for(int x = 0; x < con.length; x++) { maxs[x] = main.getconfig().getstring("areas." + con[x] + ".max").split(", ").tostring(); mins[x] = main.getconfig().getstring("areas." + con[x] + ".min").split(", ").tostring(); event.getplayer().sendmessage("1"); for(int y = 0; y < maxs.length; y++) { maxv[y] = new vector(integer.parseint(maxs[y]), integer.parseint(maxs[y+1]), integer.parseint(maxs[y+2])); minv[y] = new vector(integer.parseint(mins[y]), integer.parseint(mins[y+1]), integer.parseint(mins[y+2])); event.getplayer().sendmessage("2"); } } the error message: 2013-07-29 20:32:12 [severe] not pass event playermoveevent factionpl

java - How to tell if an X and Y coordinate are inside my button? -

i have managed, great difficulty, make bitmap overlay screen. can touch input, gets touch input everywhere on screen. i want know how able check if touch on bitmap, visible on screen. the service , view class below. have thought , thought, couldn't think of way :( package <package>; import android.app.notificationmanager; import android.app.pendingintent; import android.app.service; import android.content.context; import android.content.intent; import android.graphics.bitmap; import android.graphics.bitmapfactory; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.pixelformat; import android.graphics.rect; import android.os.ibinder; import android.support.v4.app.notificationcompat; import android.view.gravity; import android.view.motionevent; import android.view.viewgroup; import android.view.windowmanager; import android.widget.toast; public class myservice extends service { buttonview mview;

javascript - Applied tween inside each(), how do I use reverse()? -

let's suppose apply tween each element on canvas elements.each(function (element) { new kinetic.tween({ node: element, rotationdeg: 180 }).play(); }); all items have been tweened , have passed original state final state. question is: how apply reverse() revert each item original state? store tweens inside array, , loop through array , use .reverse() elements = stage.get('rect'); var tweenarray = []; // reverse tween document.getelementbyid('reverse').addeventlistener('click', function () { (var i=0; i<tweenarray.length; i++) { tweenarray[i].reverse(); } }, false); // play tween forward document.getelementbyid('play').addeventlistener('click', function () { elements.each(function (element) { var tween = new kinetic.tween({ node: element, rotationdeg: 180 }).play(); t

kernel - Multicast packets not received if socket was bind without network cable -

i've got c++ application running on busybox (kernel 3.0.35 arm) listens multicast packets. seemed working fine until discovered if start app network cable unplugged , plug in later won't received multicast packets. can't figure out why. there no error, setting operations (bind, setsockopt, ...) finish successfully, ip maddr shows correct information well. select() won't report incoming data. there kernel differently if link not up? interestingly same app sends multicast packets on different addresses , doesn't seem affected link status, it's happily transmitting once plug cable in. any ideas? thanks, tom presumably issue join when startup. if cable isn't plugged in, igmp join request can't go anywhere, router doesn't know send multicasts you.

jdk1.6 - Error in starting tomcat 5.0 from cmd prompt "The system cannot find the file -Djava.endorsed.dirs=." -

Image
i executing web app in tomcat 5.0 web app folder when trying start tomcat 5.0 getting error "the system cannot find file -djava.endorsed.dirs=. below u can see error getting: ************************************************************** set java_home c>program files>java>jdk>bin , in system varaibles added ;%catalina_home%\bin path have jdk1.6.0_14 , below jre7 folder. but tomcat 5.0 starting in eclipse ide without trouble. have done known steps me help me friends!! 1 : http://postimg.org/image/sfpfw4b97/ hey guys got rectified problem we need set java_home upto c>programmfiles>java>jdk and path c>programmfiles>java>jdk>bin note down difference .. happy coding

javascript - Access to readonly Rally account in app displayed outside of rally -

Image
i'm using rally sdk 1.33 display rally apps outside of rally. i've generated rally login key on rally's login key encoder site , have used value so: <script type="text/javascript src="https://rally1.rallydev.com/apps/1.26/sdk.js?loginkey=..." /> the problem is, members on scrum team have been getting following error message when trying display .html page: "unable login user: ... on https://rally1.rallydev.com/ " i'm looking way let members of team have access readonly rally account can view html page. know of way without using login key encoder or there else i/my team members need in order access readonly account using login key value? thank you it unusual users read-only credentials work, , others not. when custom app loaded in browser read-only credentials encoded: <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.25/sdk.js?loginkey=your login key goes here">&l