Posts

Showing posts from April, 2012

Mapping result rows to namedtuple in python sqlite -

i playing bit python api sqlite3, have little table store languages id, name , creation_date fields. trying map raw query results namedtuple docs recommend, way can manage rows in more readable way, here namedtuple . languagerecord = namedtuple('languagerecord', 'id, name, creation_date') the code docs suggest mapping follows: for language in map(languagerecord._make, c.fetchall()): # languages this fine when want return collection of languages in case want retrieve 1 language: c.execute('select * language name=?', (name,)) so first attempt this: language = map(languagerecord._make, c.fetchone()) this code doesn't works because fetchone() returns tuple instead list 1 tuple, map function tries create 3 namedtuples 1 each tuple field thought. my first approach solve explicitly create list , append tuple result, like: languages = [] languages.append(c.fetchone()) language in map(languagerecord._make, languages): # language my s

asp.net - how to update database colum with checkbox in gridview vb.net -

i have checkbox in gridview rows...and have database column name "active" default value "1" i bind checkbox database colum active... when click on checkbox default checked because default value of active in dbase column 1 .. i want when uncheck checkbox value updated on active column of selected row 0...and checkbox remains unchecked.... i have code sippet not working protected sub gridview1_rowdatabound(byval sender object, byval e system.web.ui.webcontrols.gridviewroweventargs) handles gridview1.rowdatabound each myrow gridviewrow in gridview1.rows 'find checkbox dim chk1 checkbox = directcast(myrow.findcontrol("checkbox1"), checkbox) dim id hiddenfield = directcast(myrow.findcontrol("hiddenfield1"), hiddenfield) dim active hiddenfield = directcast(myrow.findcontrol("hiddenfield3"), hiddenfield) dim sqldata new mysql.data.mysqlclient.mysqlconnection

php - How to pass variable in find using cakephp and mongo -

i have problem. before, using mysql in cakephp application. how search in database pretty easy like: $user = $this->user->find('first', array('conditions' => array('id' => $id))); but when started using mongodb, cannot use $id anymore. i tried querying: $id = 1; $user = $this->user->find('first', array('conditions' => array('id' => $id))); // query wont work $id = '1'; $user = $this->user->find('first', array('conditions' => array('id' => $id))); // work i have contain value in apostrophe's. in application, use session variables not contain apostrophe's. how make variables not contain apostrophe's , still make queries work. should have '_id' instead of normal 'id'.

iphone - ios - How to declare URL in NSURLConnection delegate? -

i'm following link http://www.stevesaxon.me/posts/2011/window-external-notify-in-ios-uiwebview/ access token,but how declare url here - (void)connectiondidfinishloading:(nsurlconnection *)connection { if(_data) { nsstring* content = [[nsstring alloc] initwithdata:_data encoding:nsutf8stringencoding]; [_data release]; _data = nil; // prepend html our custom javascript content = [scriptnotify stringbyappendingstring:content]; //here how declare url [_webview loadhtmlstring:content baseurl:_url]; } } any ideas? in advance. in given example, _url member variable. declare in property list , assign in [webview:shouldstartloadwithrequest:navigationtype:] callback _url = [[request url] retain]; and love of consider holy, please indent code properly.

How to draw a dotted line dynamically using OpenGL ES 2.0 in Android programmatically? -

i new opengl es 2.0 android. trying draw dashed line in opengl es 2.0 in android programmatically. found more ways opengl es 1.0 only. can give me suggestion or opengl es 2.0 sample code android? i found better solution. use horizontal , vertical lines. #define dot_vertex_code \ "attribute vec4 a_position;" \ "uniform mat4 projectionmatrix;" \ "varying vec2 v_xy;" \ "void main() {gl_pointsize = 1.0; gl_position = a_position*projectionmatrix; v_xy = a_position.xy;}" #define dot_fragment_code \ "precision mediump float;" \ "varying vec2 v_xy;" \ "uniform float isvert;" \ "uniform vec4 color1;" \ "uniform vec4 color2;" \ "void main() {gl_fragcolor = mod(isvert > 0.0 ? v_xy.y : v_xy.x, 2.0) >= 1.0 ? color1 : color2;}"

editor - Eclipse Graphiti, How to create "CustomFeature's create & get all Elements"? -

i have 2 questions, maybe can give me idea how can this i've created new "testfeature" extended abstractcustomfeature , can call in diagram. how can list contains elements diagram?(i want update names , colors @ start , later) my second question is: i'm trying add elements diagram without drag , drop them palette. for example have elements saved in diagram , "model miss 3 elements in diagram". want write custom feature, draw/put missing elements in graphiti diagram one/two clicks, maybe need use zest @ part? @ beginning want put few elements without drop them palette, how can this? maybe can give me direction? thanks help! how can list contains elements diagram? diagram containershape , can call getchildren() retrieve shapes add elements diagram without drag , drop them palette. is object created, inside emf model, , want add graphical counterpart diagram? if so, need instantiate , execute corresponding xxxaddfeature c

java - Selecting multiple data from the database at the same time -

i creating java application needs collect loads of data, process data objects , return objects list. all of data collected different tables in database (some joined of them different sql calls) i thinking of getting data through different threads since multiple threads cannot use same connection acess data in database have create new connection each of these threads. my question is: best way acess , process multiple data database @ same time? if have enough memory use full second level change syncs database. using cache makes extremely faster. if won't have enough memory on server/client can cache query on sqlserver table has values query , table gets updated every second. otherwise can use threadpool threads inserts queryresults shared object result.

Avoiding dead-ends in Battleships random placement algorithm -

i need advice building algorithm placing number of ships on board according rules ships cannot overlap or touch (even diagonally). in way ensure still have enough space rest of ships, after picking random position? for example, want fit 5 ships on 6x6 board (a 2d array). ships' sizes : 5, 4, 3, 1, 1. there several ways arrange them, 1 such shown below: ------------- | 1 1 1 1 1 . | | . . . . . . | | 2 2 2 2 . 4 | | . . . . . . | | 3 3 3 . . 5 | | . . . . . . | ------------- random algorithm this: 1. next ship 2. random cell , orientation 3. try fit ship (find conflicts) 3a. if ship cannot fit, try different cell , orientation, untill cells have been tried (function fails) 3b. if ship fits, ship (goto 1) but if use it, may end (edit: changed reflect sorting ships size in step 0): ------------- | . 3 3 3 . 4 | 5 | . . . . . . | | . 2 2 2 2 . | | . . . . . . | | 1 1 1 1 1 . | | . . . . . . | ------------- meaning no place 1 cell-size

I have created an application using QT.Can I update my executable using patch file -

i have created desktop application using qt. want update exe file sending patch file. can using qt there update.exe job,it contact server(//localhost:getversion?proname=myapp),the web side return version of software,and compare version in local side,at last recover local exe or nothing.there simple way,put exe ftpserver(use https://filezilla-project.org/ ),write latest version number in txt,download txt compare local exe version. there 1 problem, update program can not update itself.

c# - ArgumentException when adding many coordinates on the map -

i add pushpins can clickable on map. first, display them when add them on map, argumentexception occured , application crashes. if add 1 place on map, works when i'm trying add more places, crashes. whole list has been traversed. my code: var mycircle = new ellipse { fill = new solidcolorbrush(colors.blue), height = 20, width = 20, opacity = 50 }; maplayer locationlayer = new maplayer(); foreach (var place in r.result) { //it's method created placecoordinate in format because can commas var placecoordinate = geolocalisation.getcoordinateingoodformat(place.google_lat, place.google_lng); if (placecoordinate == null) { continue; }

regex - regular expression to negate a string nocache not working -

i trying build regular expression in apache match files extensions .html, .css, .js, .jpg, etc... except url has word "nocache" i have read other entries in stackoverflow, , i've create following regular expresion <filesmatch "^(.*(?!nocache)\.(png|bmp|jpg|gif|html|htm|css|js|ttf|svg|woff|txt))$"> expiresactive on expiresdefault "now plus 1 month" </filesmatch> the problem regular expression not working fine. files extensions being cached, file word "nocache" being cached too. does see problem? that because put lookahead assertion in wrong place ^(?!.*nocache).*\.(png|bmp|jpg|gif|html|htm|css|js|ttf|svg|woff|txt)$ when place before dot, position ahead , sees file extension, not "nocache", true. in expression placed after anchor , has own .* , start of string, if there "nocache" anywhere in string.

unix - understanding socket recv behaviour -

i'm reading manpage recv http://linux.die.net/man/2/recv , doesn't answer questions have, hope can answers here. i call recv way: numbytes = ::recv(getsocketid(), pdata, nsize, msg_dontwait); now questions are: when package bigger buffer, recv read nsize bytes , place in memory location. returnvalue nsize, right? can call recv again until data received. when package smaller nsize rcv read many bytes available , return value < nsize && >= 0. or recv try wait until nsize bytes received? if understand man page correct, think not case (at least hope it). or recv return -1 , errno = eagain or ewouldblock? if recv returns -1 happens buffer? stay untouched in case or part of data has been put it, never know how many bytes transfered, assume not case, right? what want have is, reads many bytes available, , return, giving me number of bytes transfered. in additional layer construct actual message, independent of how fragemented received. however, don'

How can I get my own status bar below a Map fragment in Android -

i'm trying google map occupy screen, want own full width status bar @ bottom of screen underneath map. this, i'm trying use linearlayout, textview status bar. status bar never appears. xml is <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="wrap_content" class="com.google.android.gms.maps.mapfragment" /> <textview android:id="@+id/main_status_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:padding = &

java - DB Connection Leak in Item Reader when using AsyncTaskExecutor -

in spring batch job have developed using asynctaskexecutor, allow parallel processing @ step level. have concurrency limit set 5. use jdbccursoritemreader pick-up input records need process. jdbccursoritemreader configured pick connections connection pool. on job execution have noticed job aborts due exhaustion of connections in pool, leading believe jdbccursoritemreader not releasing connections connection pool. suggestion? below batch xml <?xml version="1.0" encoding="utf-8"?> <beans:beans xmlns="http://www.springframework.org/schema/batch" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/bat

linux - schedule crontab in ubuntu -

i have created cronjob task list in cron.txt file. file contains list of cron jobs executed. from this, consider job should run 3 times every day, * job b should run 4 times in week * job c should run 8 or 9 times in month. i have created crontab execute in every minute. gives more load server. how reduce load server? [**because events scheduled 2 or 3 times in day]. how schedule dynamic crontab this, in linux ubuntu? edit: is possible schedule cron in linux, based on value retrieved mysql db instead of running crontab in every minute or every hour ? (can schedule crontab dynamically based on value retrieved mysql db?) else, we run crontab every day midnight schedule times , per schedule times, can run crontab. [running cron in every minute or every hour unnecessary loading server.] you should read man page on crontab : (e.g. man crontab ) to edit crontab, need call crontab -e . open editor defined in editor environment variable. c

java - How to get API_KEY in Android Transliteration -

need help... working on transliteration in android , requires api_key, i'm new android, don't know how api_key, can tell me, have api_key...? in advance...!! following code snippet--- public class mainactivity extends activity { edittext myinputtext; button mytranslatebutton; textview myoutputtext; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); myinputtext = (edittext)findviewbyid(r.id.inputtext); mytranslatebutton = (button)findviewbyid(r.id.translatebutton); myoutputtext = (textview)findviewbyid(r.id.outputtext); mytranslatebutton.setonclicklistener(mytranslatebuttononclicklistener); } private button.onclicklistener mytranslatebuttononclicklistener = new button.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub

xcode - cordova file not recognised when app built from command line + ios -

i have created app in ios cordovav 2.1.0 framework. building app command line(from path proj_name.xcodeproj exists) command :- xcodebuild -sdk iphoneos6.1 -target blahapp . error fatal error: 'cordova/cdvviewcontroller.h' file not found. why error coming? error does'nt come when run app xcode. seems not recognising cordova files. appreciated hi use latest phonegap version , cli, may solve problem. check this

php - Avoid Duplicates of Unique Key Within INSERT Query -

i have mysql query looks this: insert beer(name, type, alcohol_by_volume, description, image_url) values('{$name}', {$type}, '{$alcohol_by_volume}', '{$description}', '{$image_url}') the problem name unique value, means if ever run duplicates, error this: error storing beer data: duplicate entry 'hocus pocus' key 2 is there way ensure sql query not attempt add unique value exists without running select query entire database? you of course use insert ignore into, this: insert ignore beer(name, type, alcohol_by_volume, description, image_url) values('{$name}', {$type}, '{$alcohol_by_volume}', '{$description}', '{$image_url}') you use on duplicate key well, if don't want add row insert ignore into better choice. on duplicate key better suited if want more specific when there duplicate. if decide use on duplicate key - avoid using clause on tables multiple unique indexes. if have tab

jquery - What culture does the javascript Date object use? -

the language of os (windows) in danish, , language of browsers. when trying parse date in danish format (dd-mm-yyyy) this: var x = "18-08-1989" var date = new date(x); i wrong date javascript (i want 18'th of august 1989). when transform string english, , parse it, returns correct date. does format of date string have be: yyyy-mm-dd when using js date object?? in basic use without specifying locale, formatted string in default locale , default options returned. var date = new date(date.utc(2012, 11, 12, 3, 0, 0)); // tolocalestring without arguments depends on implementation, // default locale, , default time zone date.tolocalestring(); // "12/11/2012, 7:00:00 pm" if run in en-us locale time zone america/los_angeles using locales var date = new date(date.utc(2012, 11, 20, 3, 0, 0)); // formats below assume local time zone of locale; // america/los_angeles // english uses month-day-year order alert(date.tolocalestring("en-us&quo

mysql - Doctrine query optimizations -

i have created query using doctrine query builder inserts 65000 rows(including 3 tables) 3 different tables @ time when performed.and complete process finish takes 2-3 mins execute . have done persist records in loops , flush finally. there ways minimize execution time , inserts data within seconds. no, unfortunately doctrine doesn't support grouping inserts single statement. if need bulk inserts, 1 possibility doing $em->flush() , $em->clear() after every 100th or row, see manual's recommendation: https://doctrine-orm.readthedocs.org/en/latest/reference/batch-processing.html

c# - Unexpected results with StreamReader.ReadLine() -

i testing application stores user's contact details in file. information stored in local compact database primary method - storing details in file backup in case details lost. the file i'm using testing has personal data in it, hope understand have replaced lines placeholders! structure of file follows (minus first line): file: business name mr. joe bloggs user@email.com address line 1 address line 2 city postcode country 07777123456 below, have code reads file , stores each line variable. structure of file never change, hence simple code: public static bool restorebusinesstable(out string title, out string busname, out string mobilenumber, out string firstname, out string lastname) { string email = "", referral = "", contactno, addressline1 = "", addressline2 = "", city = "", postcode = "", country = "", district = ""; busname = null;

javascript - Cross-site Ajax WebService or WebMethod -

i developing 2 sites. in 1 of them have page service.aspx , have webmethod . want have access them other site. service.aspx : namespace interface { public partial class service : system.web.ui.page { [webmethod] public static bool checkuserlogin(string login) { bl.userbl logic = new bl.userbl(); return logic.isunique(login); } } } script.js : function isgoodlogin() { var login = $("[id$='tbsignuplogin']").val(); var data = '{"login":"' + login + '"}'; var flag = false; $.ajax({ type: "post", url: "http://95.31.32.69/service.aspx/checkuserlogin", async: false, data: data, contenttype: "application/json; charset=utf-8", datatype: "json", success: function (msg) { if (msg.d == true) { flag = true;

database - Can't connect to MySQL databse of any webhost from anywhere other than the webhost itself -

Image
i have 2 different webhost ( pagodabox & 000webhost , both free) , i've set localhost mysql. i've installed wordpress on 3 of them work fine within own domain -- ie. when localhost wordpress using localhost database, pagodabox using pagodabox database , on. however if change database access credentials wp-config.php in order to, say, make localhost wordpress connect 000webhost database, doesn't work: "error establishing database" . here's respective credentials use: <?php wp-config.php - relevant differences * members.000webhost.com/panel/manage mysql databases // ** mysql settings - can info web host ** // /** name of database wordpress */ define('db_name', '--------_db'); /** mysql database username */ define('db_user', '--------'); /** mysql database password */ define('db_password', '--------'); /** mysql hostna

Delphi XE4 Indy compatibility issue between TBytes and TidBytes -

today try compile xe3 project in xe4. first problem face indy's ftcpclient.socket.readbytes() method. before accepting tbytes type, insists on tidbytes. definitions: tidbytes = array of byte; tbytes, im not sure guess generics tarray array of byte. question number 1: why compiler complain saying that'[dcc32 error] historicalstockdata.pas(298): e2033 types of actual , formal var parameters must identical'. see identical. question number 2: should modify source code each new delphi version? thanks. the reason tidbytes simple alias tbytes in earlier indy 10 releases compatibility sysutils.tencoding , uses tbytes . indy's tidtextencoding type used simple alias sysutils.tencoding in d2009+, tidbytes needed simple alias tbytes match. however, tbytes caused quite bit of trouble indy in xe3, because of rtti problems generics ( tbytes simple alias tarray<byte> in recent delphi releases). so, indy 10.6 re-designed tidtextencoding no long

If I use Selenium WebDriver in java, do I need the source code of the application to test? -

can run test using selenium 2 without source code of application test?. want use selenium java (eclipse). i believe not need source code, can grab element through view source function. more details also.

c++ - How to get the integers 35 and 50 in the output of this program ? -

i new in c++ programming , been month started learning object oriented programming , learning program of inheritance , not getting output wanted. wrong in source code below. #include<iostream> using namespace std; class enemy{ private: int attackpower; public: void enemys(int x) { attackpower=x; } }; class monster : public enemy { public: enemy::enemys; }; class ninja : public enemy { public: enemy::enemys; }; int main() { monster object1; cout<<"you points : - "<<endl; object1.enemys( 35); ninja object2; cout<<"you points : - "<<endl; object2.enemys( 50); } well output : output : points : - points : - i suppose integers mentioned after "you points : - 35 " , "you points - 50&qu

java - JComboBox ActionListener not working after removeAllItems() was used -

i have 2 jcomboboxes; 1 removes items in other if it's populated , adds new set of items, , second fires event gets information database using selected item. problem occurs after first combo box thing removing items , adding new ones; when select of items in second jcombobox, event fires doesn't happen anymore. below have provided snippets of code: the first combo box cmbids.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { selection = (string)cmbids.getselecteditem(); if (!(selection.equals("select username")))//current selection in combobox stored string { comboactivate(selection); if (!unitc.gettext().equals("")){ unitc.settext(""); } if (!lecturer.gettext().equals("")){ lecturer.settext(""); }

How to write Windows Event log records with non-existing source -

somebody gave me testing program write records windows event log (but don't have sources). understand general way of writing , reviewing event log, program behaves special in way can write records, have source not exist. there not registry entry in .../eventlog/application, hence no formatting libs. if try own code, can write such record windows event viewer tells me "description cannot found" (which correct , understand why happens). the question now: since foreign test prog can it, must possible somehow - how? many thx!! :-) ok, found (also, got sources) - prog creates registry entry (probably happens when calling createeventsource()), not visible until refreshing regedit :-| and, register formatting lib, cannot rely on: c:\windows\microsoft.net\framework64\v2.0.50727\eventlogmessages.dll or, can i? ah, here go explanation: difference between eventlog.writeentry , eventlog.writeevent methods so, cannot, i'm not using .net ... :-| now, if

javascript - Dropdown options can't access with jquery selector? -

i have drop down in webpage.it's aspx page.but try access drop down javascript.here code. code working. var = document.getelementbyid('mydropdown'); alert(a.options.length); this code not working var = $('#mydropdown'); alert(a.options.length); i getting following error. typeerror: cannot read property 'length' of undefined any 1 have idea. $('#mydropdown') jquery object , treating dom object. try changing var = $('#mydropdown'); to var = $('#mydropdown')[0];

Selenium Webdriver C# : Need help accessing the Elements inside iFrame -

i having iframe inside overlaywindow , not able access iframe , element. have lots of menus inside iframe , need test that. the html code looks below: <div class="exp overlaycontainer" style=""> <div class="overlaybackground"></div> <div class="overlaywindow" style="position: absolute;"> <div class="overlaywindowinner" style="top: 30px; left: -410px;"> <div id="closetab"> <iframe class="overlaywindowcontent" frameborder="0" src="/templates/frame_loading.html?/my-exp/pers... i using below selenium code locate iframe iwebelement detailframe = driver.findelement(by.xpath("//iframe[@class='overlaywindowcontent']")); driver.switchto().frame(detailframe); but getting below error message. frameelement cannot converted remotewebelement let me know comments i had same problem , used driver.switchto().frame(0)

visual studio 2010 - C++ #include relative path -

is possible relative path correct, nevertheless compilation error: 2>src\wfbuilderapp.cpp(15): fatal error c1083: cannot open include file: '../project/include/public/core/paths.h': no such file or directory in particular, possible error occurs not because path wrong, because included file "does not permit" have binding between files ? file including , included file located in same solution, in subfolders of folders located in different projects. here questions #include : can include file long path correct , included file in same solution ? can include .cpp file ? do need include both .cpp , .h files ? can include file long path correct , included file in same solution ? if path correct, yes. being in same solution has no effect on include. compiler file in places it's told (adding file solution doesn't modify places). the proper way adding path additional include directories in project properties. can include .cpp fil

database - How do I apply my php code to a bootstrap code? -

i trying display database on bootstrap bar , have no idea how combine or implement two. ive made bootstrap html's file .php, correct thing do? here's code (ignore filler words) <ul class="nav nav-list well"> <li class="nav-header"></li> <li class="active"><a href="#">hit info</a></li> <li><a href="#">linky link</a></li> <li class="divider"></li> <li><a href="#">another hit info</a></li> <li><a href="#">another linky link</a></li> <li class="divider"></li> <li><a href="#">yet hit</a></li> <li><a href="#">aaaaand link</a></li> </ul> and php want include (the code making want display in file) <?

php - Proper way of creating a list of objects -

i wondering on best way go creating list of objects. currently, have class deals orders. in order retrieve order needs call api provided with. api calls expensive point make call returns 5000 orders faster make 2 separate calls 2 separate orders. because of this, built class initialized 2 ways, 1 way allows me pass order number , initializes itself, if pass array, uses data array create object. now have functions getorderlist($startdate, $enddate) make 1 call api , fill array full of order objects returned can stuff them. this feels 'hacky' me, wondering if there accepted way of doing trying accomplish while being more oop. note: personal project using learn best practices rather hear 'should have done' vs 'what can here' it sounds fine me in case. if want "more correct" (which can be), might want make ordermanager object has class method manage collections of orders. example call might this: <?php class ordermanager {

asp.net mvc - Find MVC template view by name -

i writing htmlhelper extension , need search existence of template name. template in question may display or editor template depending on context. initial thought use viewengines.engines.findpartialview method. however, appears method not searching ~/views/shared/displaytemplates , ~/views/shared/editortemplates directories. suppose reason. after all, how viewengine know whether return display or editor template without additional information of context? so, leads question: how can search specific editortemplate / displaytemplate i've considered adding custom view engine viewengines collection include these locations. i'm concerned, however, might problematic. my main concern displaytemplate / editortemplate view might served unintended. else see problem? better idea new specific displaytemplateviewengine / editortemplateviewengine instance when necessary , keep viewengines collection clear of specific functionality? there else i'm missing? i a

Time with minutes and Hours wheel type in android -

i developing wheel type piker in android should show min figure min text , hour figure hour text displaying same text min or hour should separate min , hour. got code following link. android-wheel android picker widget http://code.google.com/p/android-wheel/source/browse/trunk/wheel-demo/src/kankan/wheel/demo/citiesactivity.java http://code.google.com/p/android-wheel/downloads/list* try this one , this one . both supply sample codes.

html - Cannot open the same Jquery UI dialog using another DIV tag -

i've been trying find solution allow me open same dialog box when user doesn't have access particular site. able open first div assigned id to. you can view live example of working code here: http://jsfiddle.net/jtgcf/216/ only first "open" button works second 1 doesn't. example of html: <div id="content"> <a href="#open" id="open">open dialog</a> </div> <div id="content"> <a href="#open" id="open">open dialog</a> </div> <div id="ok-dialog"> <p>it's ok!</p> </div> the function: $(function() { $('#open').click (function() { $('#ok-dialog').dialog ({ modal: true, title: 'ok!' }); }); }); id's supposed unique, used 1 element. jquery select first element given id. use class instead.

unity3d - Sphero iOS Unity Plugin - Crash Following Sphero Connect -

similar existing question more specifics. i'm trying setup sphero unity plugin unity asset store can't seem run bundled helloworld sample on device. app crash connects sphero. looking @ debug output issue seems coming handlerobotonline function in rkunbridge.mm in libraries folder, specifically: rkdevicemessageencoder *encoder = [rkdevicemessageencoder encodewithrootobject:notification]; receivedevicemessagecallback([[encoder stringrepresentation] utf8string]); it appears issue keyedrepresentation. error is: [__nsdictionarym rkjsonrepresentation]: unrecognized selector i've been attempting debug myself haven't gotten anywhere. i'm using ios 6.0 on 4th gen ipad, unity v4.1.2, , xcode v4.6. suggestions fantastic, thanks! the sphero unity plugin has post process build script in editor directory want use when building xcode project. error experiencing because of missing linker flag. add: -all_load to build settings in xcode, , error shou

c++ - Qt When will the dialog return QDialog::Rejected -

i'm in trouble. have qdialog login form. when log in, form closes , mainwindow appear. login fine when closes returns qdialog::rejected. what can prevent return of qdialog::rejected? , when return qdialog::rejected? code when log in : void login::on_cmdlogin_clicked() { if( ui->txtusernamelogin->text().isempty() || ui->txtpasslogin->text().isempty() ) { qmessagebox::critical(this, "vocabulary trainer", "please fill in both textboxes.", qmessagebox::ok); return; } user user(filepath + "/users.txt"); if ( user.checkpassword( ui->txtusernamelogin->text(), ui->txtpasslogin->text() )) { username = ui->txtusernamelogin->text(); close(); } else qmessagebox::warning(this, "vocabulary trainer", "sorry, password incorrect.\nplease type in correct password.", qmessagebox::ok); } main() : mainwindow w; //real window lo

java - Missing semicolon in JSONWithPadding -

the result of jsonwithpadding missing semicolon in end: jsonwithpadding jsonwithpadding = new jsonwithpadding({"key":"value"}, "cb"); return response.status(200).entity(jsonwithpadding).build(); expected: cb({"key":"value"}); --> semicolon actual: cb({"key":"value"}) --> without semicolon any ideas? the semicolon not missing, optional in (this example and) situations. jsonwithpadding class working correctly. the ecmascript language specification defines 7.9.1 rules of automatic semicolon insertion , summarised javascript , semicolons as certain ecmascript statements (empty statement, variable statement, expression statement, do-while statement, continue statement, break statement, return statement, , throw statement) must terminated semicolons this covered @ what rules javascript's automatic semicolon insertion (asi)?

Paypal Express Checkout for Digital Goods hangs when login is popup -

i have been testing paypal integration - on sandbox - number of days , have found that, when paypal login presented in browser, fine; when login environment changes popup/lightbox, browser hangs , remains on 'loading' after successful test payment has gone through. i used paypal integration wizard generate code , amended accordingly. advice appreciated it's doing head in! i have seen issue occur several times lately, reported few of customers. while can't provide definitive solution, have had success 1 or more of following: clear browser cacher. shutdown , restart browser. login standard paypal site, logout , restart browser. try different browser identify whether there going on specific browser. switch between sandbox, live, , sandbox mode. may require repeat of step #1. contact paypal customer support. i typically resolve problem before getting #4, well. best of luck!

python - How can I calculate the area of an object by using its contour (chain code)? -

say have rotated squared object chain code [1, 1, 1, 1, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7] using 8-connectedness. how can derive area, in number of pixels? edit: i derived chain code boundary pixels. if easier calculate area boundary pixels, how can done? the algorithm should able find number of pixels enclosed boundary (including boundary pixels). shape of boundary can arbitrary, long closed , not intersect itself. the area of polygon can calculated vertices using formula: a = 1/2 sum(i = 1..n, x[i]*y[i+1] - x[i+1]*y[i]) source: wolfram mathworld

vbscript - Incorrect syntax was used in a comment -

please consider kind of xhtml document: <?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head></head> <body> <!--- comment 3 dashes causes parsing error ---> <!-- rest of xhtml --> </body> </html> and partial vbscript code i'm trying parsing: with createobject("msxml2.domdocument.6.0") .async = false .setproperty "prohibitdtd", false .validateonparse = false .setproperty "selectionlanguage", "xpath" .setproperty "selectionnamespaces", "xmlns:xhtml='http://www.w3.org/1999/xhtml'" .load(url) end i error report: incorrect syntax used in comment apparently because comment uses 3 das

php - How does remember me cookie work with session life time? -

i'm bit confused this, say session has been started default php ini settings gc_maxlifetime 1440 seconds. , supposed use remember me functionality this, set cookie lifetime 14 days. long session max life time set 24 minutes lesser cookie life time (14 days), after 10 days (for example) session (of course depends on gc probability ) expired , have no reference session id remember me cookie has. so how setting remember me cookie lifetime longer session lifetime remember/resume session? or need change session max lifetime according cookie lifetime? generally "remember me" cookie persistent cookie, not session cookie. contains encrypted information allows automatic login action occur. i.e. when there no active session already, "remember me" cookie present, new session started.

css - Trying to give margin to evenly divs inside a container -

i have code: <div class="container"> <div class="contained one">foobar</div> <div class="contained two">foobar</div> </div> -- css -- .container { background: red; width: 500px; height: 200px; } .contained { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; width: 50%; float: left; padding: 10px; } .one { background: blue; } .two{ background: green; } i give margin around contained divs , don't know how.. it's padding. margin: 10px; example. note margin needs calculated width of elements also. suggest giving % margins, make sure total % of margins plus widths = 100%. you like... .contained { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; width: 45%; margin: 2.5%; float: left; padding: 10px; } this works because (2.5left +

c# - Return Different JSON in WCF method on error -

i have method return class cono in json format [datacontract] public class cono { [datamember(order = 1)] public companies[] companies; } public class companies { [datamember(order = 1)] public string cono; [datamember(order = 2)] public string name; } [webget(uritemplate = "getcompanies?requestkey={requestkey}", responseformat = webmessageformat.json)] public cono getcompanies(string requestkey); this method first validate request key if correct returns data this: { companies: [ { cono: "001", name: "company001" } ] } but if request key not correct want return error code in json this {-100} how can change return type of method int or how can return desired data in above format you can change return type of method stream ( public stream getcompanies(string requestkey); ) , write method static stream tojson(object o) { var result = jsonconvert.serializeobject(o); var data = encod

php - MySQL: Ignore row when summing a field if another table contains a certain value -

i have 3 tables, 1 called orders (containing customer info), called orders_total (containing order subtotals, discounts, , totals), , last 1 called orders_products (containing names , prices of items being ordered). tied common field called orders_id. i trying aggregate (sum) total sales revenue except orders contain item x (from orders_products table), reason sum of sales revenues aren't adding when introduce third table (orders_products). know how aggregation , item exception separately 2 of 3 tables, complexity me combining both functions introducing third table. here working query far 2 original tables: select o.orders_id, ot.orders_id, o.delivery_state, sum(ot.revenue) ordersum orders_total ot, orders o ot.orders_id = o.orders_id group o.delivery_state order ordersum desc; how implement exception ignore orders contain item x? you can exclude orders original query identified via subselect: select o.orders_id, ot.orders_id, o.delivery_state, sum(ot.revenue)

How to show git log history for a sub directory of a git repo? -

lets have git repo looks this. foo/ .git/ a/ ... big tree here b/ ... big tree here is there way ask git log show log messages specific directory. example want see commits touched files in foo/a only? from directory foo/ , use git log -- b you need '--' separate <path>.. <since>..<until> refspecs. $ git log --oneline -- src/nvfs d6f6b3b changes mac os x 803fcc3 initial commit $ git log --oneline 803fcc3 -- src/nvfs 803fcc3 initial commit $ git log --oneline d6f6b3b changes mac os x 96cbb79 gitignore 803fcc3 initial commit

python - Plotting grouped data by date -

Image
i'm trying plot counts of pandas dataframe columns, grouped date: by_date = data.groupby(data.index.day).count() the data correct, the data.index.day specified no plotting purposes: is there way of specifying want group python date objects, or doing wrong? update: dan allan's resample suggestion worked, the xticks unreadable. should extracting them separately? i think task more accomplished using resample , not group . how about data.resample('d', how='count')

Setting multiple Spring MVC locales in jsp -

following locale configuration in spring xml file: <bean id="localeresolver" class="org.springframework.web.servlet.i18n.sessionlocaleresolver"> <property name="defaultlocale" value="en" /> </bean> <bean id="localechangeinterceptor" class="org.springframework.web.servlet.i18n.localechangeinterceptor"> <property name="paramname" value="language" /> </bean> <bean class="org.springframework.web.servlet.mvc.support.controllerclassnamehandlermapping" > <property name="interceptors"> <list> <ref bean="localechangeinterceptor" /> </list> </property> </bean> <bean id="messagesource" class="org.springframework.context.support.reloadableresourcebundlemessagesource"> <property

jquery - Zero Padding a Date with JavaScript -

i want format date this: may 02 2013 but @ moment, formatting looks this: may 2 2013 how can 0 pad type of date day in date 02 instead of 2 ? here code using: var m_names = new array("january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"); var d = new date(); var curr_date = d.getdate(); var curr_month = d.getmonth(); var curr_year = d.getfullyear(); alert( m_names[curr_month] + " " +curr_date + " " + curr_year); jsfiddle code here try this: var d = new date(); var curr_date = ("0" + d.getdate()).slice(-2); var curr_month = d.getmonth(); var curr_year = d.getfullyear(); alert( m_names[curr_month] + " " +curr_date + " " + curr_year); fiddle

html5 - Structured Data for Reocurring Event -

i'm webmaster smctheatre.com. we're community theatre puts on handful of plays each year. i'm adding toolbox learning structured data. microformat, microdata, or rdfa, don't have strong preference 1 on another. syntax of rdfa lite , microfomat on microdata , full-blown rdfa. the thing haven't been able answer how mark event occurs on multiple dates, , @ different times. here's trimmed down snippet site: <article> <header> <h1>play name</h1> <div class="addthis_toolbox">...</div> </header> <aside> <h2>dates</h2> <ul> <li>may</li> <li>fridays 17 &amp; 24</li> <li>saturdays 18 &amp; 25</li> <li>sundays 19 &amp; 26</li> <li>monday 27</li> <li>all shows start @ 7:30 pm</li> </ul> <h2>tickets</h2> <ul>

Got unauthorized error when renaming mongodb collection -

i using mongohq sandbox plan. in command prompt, db["oldcollectionname"].renamecollection("newcollectionname", true) works fine without using admin database. however, got "unauthorized" exception when in java: oldcollection.rename(newcollectionname); since using mongohq sandbox plan, don't have access admin database. there way rename collection without creating new collection, copying on documents, , dropping old collection? in java , using jongo can following: mongocollection col = new jongo(dbconfigurer.getdb()).getcollection("code"); col.getdbcollection().rename("code45", true); i've tested , works. now using 'runcommand' (same using db.command) in following example: db db = ....getdb(); jongo jongo = new jongo(db); jongo.runcommand("{ renamecollection : 'old_name', to: 'new_name', droptarget: true}"); i obtain same error have. i read documentation have conn

ios - How to use an internal method in a Objective-C category? -

trying extend capabilities open source project, wrote category add new method. in new method, category needs access internal method original class, compiler says can't find method (of course, internal). there way expose method category? edit i don't want modify original code, don't want declare internal method in original class header file. the code in original class implementation file (.m), have method implementation: +(nsdictionary*) storekititems { return [nsdictionary dictionarywithcontentsoffile: [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent: @"mkstorekitconfigs.plist"]]; } in category, want add method: - (void)requestproductdata:(nsarray *(^)())loadidentifierblock { nsmutablearray *productsarray = [nsmutablearray array]; nsarray *consumables = [[[mkstoremanager storekititems] objectforkey:@"consumables"] allkeys]; nsarray *nonconsumables = [[mkstoremanager storekititems]