Posts

Showing posts from April, 2012

objective c - UITabBar Controller and UITableView Controller - would one effect the other? -

perhaps simple or stupid question. have tested 3 separate apps, each simple uitableviewcontroller apps detail view controllers pushed onto stack. work no problems. i've decided build new app uses 3 tab uitabbar controller rootviewcontroller , have these 3 separate tableviewcontrollers running off tabbar controller. can fire first level tableviews can't push respective childviewcontrollers onto stack. i'm using same class code each uitableviewcontroller in tabbar app tested in tableview app. am missing obvious here? why wouldn't work because of tabbar controller? thanks insights in advance. if closer @ 3 separate apps, you'll see have uitableviewcontrollers inside of uinavigationcontrollers. left navigation controllers out of version uitabbarcontroller. the hierarchy should this: uitabbarcontroller ┣ uinavigationcontroller ┃ ┗ uitableviewcontroller ┣ uinavigationcontroller ┃ ┗ uitableviewcontroller ┗ uinavigationcontroller ┗ uitablev...

.net - Setting the size of char datacolumn -

i add new column datatable. column of type char length of 10. datacolumn d = new datacolumn(fieldname, typeof(char)); dt.columns.add(d); my question how add "size" column? thanks lot. note in c#, char always 1 character. try this: datacolumn d = new datacolumn(fieldname, typeof(string)); d.maxlength = 10; dt.columns.add(d);

javascript - Expose socket via web sockets -

i have server creates socket on port 8181. access socket web page opened in google chrome 14. suppose not possible in straight manner. chrome provides support web sockets not standard sockets. right? is possible somehow create intermediary expose socket server listening on port 8181 web socket server running on other port? websockify generic websockets tcp socket proxy/bridge. created websockify allow novnc (html5 vnc client) able connect unpatched vnc server. generically useful (not vnc specific) spun off separate project. on unix/linux system run websockify this: ./websockify 8080 my_server:8181 port 8080 in above example port listen websocket connections. my_server name/ip of system have server listening on port 8181. if running websockify on same system server can use localhost in place of 'my_server'. the websockify project comes javascript wrapper library called websock.js. websockify supports new protocol versions (used chrome 14+ , firefox 6+) ...

c - remove newline characters from text file while writing data -

i getting newline character text file while writing content text file using code below sprintf(str,"godownname,lorrynumber,invoicenumber,cementcompanyname,rcvdprsnname,rcvdprsndsgnation,entityqty,date\0"); write(fd,str,strlen(str)); the text writing 2nd row , unwanted newline writing @ 1st row. want text written 1st row. please 1 me remove newline characters or spaces text file thanks in advance my guess have function writes in fd before call of function. besides, writing "\0" @ end of string litteral useless, there's one.

c# - How to eliminate duplicates from a list? -

class infocontact { private string contacts_first_namefield; private string contacts_middle_namefield; private string contacts_last_namefield; private phonenumber[] phone_numbersfield; private emailaddress[] emailfield; } i have list<infocontact> list contains 7000 other program. in list out of 7000, 6500 duplicates. looking way how eliminate duplicates. a infocontact duplicate if first_name, last_name, emailaddresses, phone numbers same. i thought of using hashset<infocontact> , override gethashcode() of infocontact. i curious know if best way do. if not way better way? firstly think of extracting unique values. use distinct() linq method comparer like: public class infocontactcomparer : iequalitycomparer<infocontact> { public bool equals(infocontact x, infocontact y) { return x.contacts_first_namefield == y.contacts_first_namefield && x.contacts_last_namefield == y.conta...

How would you use a Distributed Version Control System like Mercurial or Bazaar to manage large binary files? -

specifically situation i'm thinking of have large asset .psd 200 mb. artist goes , changes few pixels , checks in. assuming deltas not kept thats 200 mbs updates clone/branch have history off. given full development cycle lot of information pull each client. what ability mark files these "keep history on server", traditional centralized vcss svn or perforce. may lose benefits of dvcs these files willing accept long can use 1 vcs (as opposed 1 assets , 1 code). any suggestions on how (if possible) appreciated. for mercurial, can use bfiles extension (or 1 of others listed on page). file metadata stored inside repo, , content of big files kept on central server. haven't used of extensions, though, can't tell 1 best choice.

onclick - Possible to track a div click with google analytics -

i have video playing within div on site. video requires click play. i'm wondering if possible apply analytic event tracking parent div tracks anytime there click within div. i know can use onclick event analytics, not quite sure if applied div rather than, say, outbound link this: <a href="#" onclick="_gaq.push(['_trackevent', 'videos', 'play', 'vid 1']);">click here</a> has body ever done this? realize there downfalls (user repeatedly clicking play/pause) etc. thanks. *edit - should have mentioned unclear of how turn div clickable event. say div . need make whole div onclick event? you can this: <div onclick="_gaq.push(['_trackevent', 'videos', 'play', 'vid 1'])" style="cursor: pointer;"> content here </div> however : when place flash inside, there issues click propagation, depending on browser. better give library try...

.net - Common causes of SlSvcUtil.exe not reusing a data contract types -

i have wcf web service that's being consumed both silverlight , .net clients. in order share data contract types both clients, contracts defined in 2 class libraries: 1 silverlight , 1 .net. files defining data contract types shared between 2 library projects via links. generation of proxy consume service works nicely .net. specifically, data contract types .net class library reused expected. however, generation of silverlight proxy via slsvcutil.exe not reuse data contract types. true whether invoke slsvcutil.exe command line /r switch or use "add service reference" dialog visual studio. through trial , error, i've determined single type utilized in single service method source of problem. if service ceases use type, slsvcutil.exe generates proxy expected (with types reused data contracts assembly). now i've narrowed issue down type, i'm not sure next. type contain member implements ixmlserializalble. cause behavior? common causes this? a...

r - Set up default sound player -

by using r packages tuner , seewave generated sounds want play software not windows media player don't know how set up. command setwavplayer("mplay32") is thing works (and wmp). when try this setwavplayer("c:/program files/foobar2000/foobar2000.exe") the synth or play command gives error when try playback sound 'c:/program' not recognized internal or external command, operable program or batch file. any hints? here's works me under osx: assuming i've installed app called 'play.app' , setwavplayer('/applications/play') in case appear somewhere along line path string's space (in "program[space]files" ) causing string split up. error message pretty coming commandprompt or similar shell. need quote string using shquote space handled properly: setwavplayer(shquote("c:/program files/foobar2000/foobar2000.exe"))

rails cancan first time use with roles_mask -

first time use of cancan roles_mask. keep getting undefined method '&' "1":string in edit view. form.html.erb <% role in user::roles %> <%= check_box_tag "user[roles][]", role, @user.roles.include?(role) %> <%=h role.humanize %><br /> <% end %> <%= hidden_field_tag "user[roles][]", "" %> <% end %> user.rb class user < activerecord::base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :email, :password, :password_confirmation, :remember_me, :firstname, :lastname, :username, :roles roles = %w[admin manager employee banned] def roles=(roles) self.roles_mask = (roles & roles).map { |r| 2**roles.index(r) }.sum end def roles roles.reject |r| ((roles_mask || 0) & 2**roles.index(r)).zero? end end def ro...

c# - WPF Combo box - Select Item by Tag -

i have combo box this <combobox name="mymenu"> <comboboxitem content="question 1" tag="1" /> <comboboxitem content="question 2" tag="2" /> <comboboxitem content="question 3" tag="3" /> <comboboxitem content="question 4" tag="4" /> </combobox> how can programmatically set selected index tag value? e.g. 'mymenu.selectedtag = 3' , question 3 selected item? i want easier current solution really... int tagtoselect = 3; foreach (comboboxitem item in mymenu.items) { if(item.tag.equals(tagtoselect) { mymenu.selecteditem = item; } } looks you're looking proeprty selectedvaluepath of combobox control. see example here http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.selector.selectedvaluepath.aspx ...

trace - How can I extract HTTP data going over SOCKS with Wireshark? -

i took pcap trace when accessing website using opera mini on mobile, , opera mini uses socks proxy tunnel http traffic, wireshark trace shows of packets socks packets. there way extract http payload this? once socks connection has been established , authenticated, exchanged data afterwards on same connection http data. locate first data packet after socks handshake complete , tell wireshark decode , subsequent packets http instead of socks.

apache - Trouble configuring trac to work with Apache2 -

i've been trying set trac deployed apache little while , i'm running wall. i can work via tracd i'm going have multiple projects , might want use tsl connections trac. this response i'm receiving server internal server error server encountered internal error or misconfiguration , unable complete request. please contact server administrator, webmaster@localhost , inform them of time error occurred, , might have done may have caused error. more information error may available in server error log. apache/2.2.14 (ubuntu) server @ ***.***.***.*** port 80 this apache v-host file: (comments removed) <virtualhost *:80> serveradmin webmaster@localhost directoryindex index.html documentroot /home/***/public_html/app/public alias /trac/chrome/common /home/***/trac/htdocs/common alias /trac/chrome/site /home/***/trac/htdocs/common scriptalias /trac /home/***/trac/cgi-bin/trac.fcgi/ defaultinitenv trac...

python re.search (regex) to search words who have pattern like {{world}} only -

i have on html file in have inserted custom tags {{name}} , {{surname}} . want search tags match pattern {{world}} not {world}} , {{world} , {world} , { word } , {{ world }} , etc. wrote small code re.findall(r'\{(\w.+?)\}', html_string) it returns words follow pattern {{world}} ,{world},{world}} don't want. want match {{world}}. can please guide me? um, shouldn't regex be: '\{\{(\w.+?)\}\}' ok, after comments, understand requirements more: '\{\{\w+?\}\}' should work you. basically, want {{any nnumber of word characters including underscore}}. don't need lazy match in case may remove th ? in expression. something {{keyword1}} other stuff {{keyword2}} not match whole now. to keyword without getting {{}} use below: '(?<=\{\{)\w+?(?=\}\})'

wpf - Attached Behavior on ButtonBase to do something before the Click event is fired for others? -

is there way can wire attached behavior based on buttonbase class before other subscribers click event notified? from current understanding of events , routedevents no maybe i'm missing something. you can use registerclasshandler add handler called before other instance handlers. realize not "attached behavior".

sql - how to find people with same family name? -

you have table 4 columns: primary key / name / surname / middle name how write sql query find people has same family name? 1 / ivan / ivanov / ivanovich 2 / petr / levinsky / aleksandrovich 3 / alex / ivanov / albertovich should return ivan , alex thanks in standard sql can join table itself: select a.name, b.name t a, t b a.surname = b.surname , a.id < b.id where t table , id primary key column. this returns distinct pairs of first names every surname has multiple entries. you might want add surname list of selected columns.

iphone - Calendar view instead of UIDatePicker -

does know of view controller iphone/ipad shows monthly calendar? there no in-built view controller that. need create own. there projects in github exact purpose. check these out. titanium calendar klazuka

Monodevelop 2.8, XCode 3.2.6, Interface Builder: Outlets and Actions -

edit: since haven't installed xcode 4 yet, know if md 2.8 compatible xcode 3.2.6 or not. in particular, able connect outlets , actions new procedure described in mt documentation ? i've installed monodevelop (md) 2.8. seems not working expecting. in md 2.6 when create new uiviewcontroller, controller presented following: controller.xib <- inside same tree controller.xib.cs controller.xib.designer.cs in addition if open xib file, controller.xib, interface builder (ib) opened. if add outlets xib, outlets visible in controller.xib.designer.cs. in md 2.8 when create new uiviewcontroller, controller presented following: controller.xib <- no more inside same tree controller.cs controller.designer.cs so have 2 files instead of one. in addition if open xib file, controller.xib, ib , xcode opened. if add outlets xib, outlets aren't visible in designer. any suggestions? monodevelop 2.8 introduced new xib designer model in order suppo...

tortoisehg - tortoise hg clone two separate mercurial projects to the same directory -

i wanted combine 2 projects separate remote mercurial repositories same local directory (one framework, other code). my thoughts doing clone them both same working directory generates error abort: destination 'c:\workspace\project' not empty using tortoise hg. is right way approach , if know how work? first of all, sure want this? there's no way safely push original sources without getting everything, both "projects" after have combined. in other words, become 1 project, , won't easy split up. you should consider using sub-repositories typical way mercurial deals these sorts of things. having said that, combine 2 distinct repositories, need pull 1 other. in other words, here's do: clone 1 of projects pull new clone, , specify url second project. need force pull, otherwise complain not being same repository. optionally: move 1 or both of projects own sub-directories, separate them in directory structure merge 2 heads comb...

iphone - BackgroundImage problem with my back button -

i have concern image attributed button not appear added statement nothing win1.setbackbuttontitleimage('back.png'); here code var buttonretour = ti.ui.createbuttonbar({labels:['retour'], backgroundcolor:'#ae4041', backgroundimage:'back.png', color:'#ffffff' }); buttonretour.addeventlistener('click', function(){ tabgroup.close(); }); win1.leftnavbutton = buttonretour; win1.setbackbuttontitleimage('back.png'); you have idea problem thank i found solution i changed code creation of button using following var backbutton = ti.ui.createbutton({ title:'accueil', backgroundimage:'images/back.png', font:{fontsize:13,fontweight:'bold'}, textalign:'center', width:75, height: 35 ...

Ios UIButton subclassing with OpenGL -

is possible create subclasses of uibutton button drawing in opengl es? have game app uses opengl es far , not want add composited uikit elements on top of both performance , aesthetic reasons. again not want implement hit testing of touches against rects because correctly apple inner , outer rects , various state transitions quite lot of code. want have uibutton touch state changes have no drawing, while allowing me draw buttons myself in various states using opengl along rest of drawing code. suggestions or code examples of how proceed? i found 1 answer question make use of uibutton use custom style. if not set actual images button states not draw @ all, still functions button calling when desired action detected in rectangle supply. way can make regions of gles texture active buttons. can callbacks when button touched or released or without action , can update texture in response these if desired. in end did not this, used custom buttons images per normal uikit use. did ...

spring - NoSuchMethodException thrown by AnnotationValidationInterceptor when executing an action -

details of jars used: struts2 2.2.1 spring 3.0.5.release hibernate 3.6.0.final i experiencing strange issue when trying execute action mapped follows: <action name="suppliersearch" class="suppliersearchaction"> <result>/pages/suppliersearch.jsp</result> </action> <action name="searchforsupplier" class="suppliersearchaction" method="dosearch"> <result>/pages/suppliersearch.jsp</result> </action> the first action sends user search page, enter search string , second action invoked when post form. the action in spring config follows: <bean id="suppliersearchaction" class="com.blah.suppliersearchaction" scope="prototype"> <property name="searchservice" ref="suppliersearchservice"></property> </bean> the search service uses hibernate search , defined follows: <bean id="supp...

ios - ShouldAutoplay on MoviePlayerController -

i new developer, therefore i'm still learning , know i'm doing things wrong. have segmented control object in when user presses 1 of segments, goes play video. have setup press segment, have press play button video play. want cut out play button , have play automatically. i'm having trouble. found shouldautoplay option when use , cut out button, won't take me video @ all. i'm sure i'm not using shouldautoplay option correctly. hoping or @ least point in right direction. - (ibaction)playmovie:(id)sender; { nsbundle *bundle = [nsbundle mainbundle]; nsstring *moviepath = [bundle pathforresource:@"mytestimony" oftype:@"m4v"]; nsurl *movieurl = [[nsurl fileurlwithpath:moviepath] retain]; mpmovieplayercontroller *themovie = [[mpmovieplayercontroller alloc] initwithcontenturl:movieurl]; themovie.shouldautoplay = yes; themovie.scalingmode = mpmoviescalingmodeaspectfill; [themovie autorelease]; mpmovieplayerview...

applet - How best to interact with peripheral from browser -

this may elementary question, apologize in advance. need interact device web app. more twain device. use signed java applet this. works well; signed applet works on multiple platforms , provides device interaction needed. issue have applets not seem long browser world, @ least in allowing non-sandboxed access this. need know other options available. requirements meet can access local devices. code signing certificate not problem. is web based. long can delivered via web, , initiated via web app going forward, ok. be cross platform. can use scanners on macs , pcs via twain, , linux machines via sane. i not familiar technologies such flash , silverlight. either of these viable options? anything? right know of activex, applet, or browser extensions available (just search web, , pick 1 looks you). pretty i'd imagine flash, , silverlight options available, know of none of right now.

javascript inheritance, reflection and prototype chain walking? -

i'm trying figure out how can use of javascript language , how have implement myself when comes object reflection. here's intended result // property inheritance schema (defining default props) (stored in db "schemas" table) foo bar moo baz ugh // method inheritance schema (stored in code) foo bar moo baz ugh // mytree structure + property overrides (stored in db "structs" table) mybar mybaz myugh mybar mybaz mymoo an instance of tree object constructed mybar structure. when building each node, compose methods code, "inherited" property schema , non-default properties node defined in mybar struct itself. the goal create a system that, given node instance of tree, can self-analyze own property inheritance path , identify @ level property defined. this allow editing of mybar structure , indicate properties inherited defaults base schema (and @ level) , ones expl...

Java Eclipse Taking Command Line Arguments Continously in Running Time -

first of all, read related topics , none of them answered question. developing program in java using eclipse , need pass arguments program continously after starts. example somehow need give command command line after starts execute: createtable students 2 10 10 and must able give more commands such : addrecord students jack 1456 run configurations of eclipse not solve problem since can give arguments program once using run configurations. need multiple lines? has solution? in advance it doesn't seem possible in eclipse according this question (which lists possible workarounds). update it's not possible allocate system.console() , true but work system.in (thanks stephen c): scanner scanner = new scanner(system.in); string line; while (true) { system.out.println("type please:"); line = scanner.next(); system.out.println(line); }

silverlight - Extend computed properties in WCF Ria Services on client -

i have business object comes wcf service. know can extend business object creating partial class on client . however, possible extend property comes generated business object. example, let's business object has property called name. want is, on client , mark property [displayattribute]. any appreciated. never used attributes, use pre-compiler statements hide silverlight/client side code, when compiles on server. example, done entitystate on both server , client side: #if silverlight using system.servicemodel.domainservices.client; #else using system.data; #endif silverlight defined on client side, not on server side projects (conditional compilation symbol - project properties, build tab). i haven't tried it, i'm thinking might work attributes?

jboss - autocomplete select listener -

i use method in rich:autocomplete component same way valuechangelistener, problem cannot submit form in order listener fired, that's why wanted ask how intercept event in order execute listener in backing bean. have tried this: <rich:autocomplete id="autocompleteoficina" value="#{agenciadm.oficinaseleccionada}" converter="entityconverter" autocompletelist="#{suggestionentitiesdm.availableentitieslist(suggestionentitiesdm.oficina)}" var="oficina" fetchvalue="#{oficina.label}" showbutton="true"> <a4j:ajax event="change" listener="#{oficinacontroller.empresasearchselectedlistener}"></a4j:ajax> <rich:column> <h:outputtext value="#{oficina.label}" /> </rich:column> </rich:autocomplete> i have tried select event, no 1 executed listener, why not fired?. could please enclose inside <h:form></h:form> a...

how to check the version of jar file? -

i working on j2me polish application, enhancing it. finding difficulties exact version of jar file. there way find version of jar file imports done in class? mean if have thing, import x.y.z; can know version of jar x.y package belongs to? decompress jar file , manifest file ( meta-inf\manifest.mf ). manifest file of jar file might contain version number (but not version specified).

mysql - XML parsing, populating database and text indexing -

i trying populate database parsing xml files , directly putting parsed values database. have 1000 xml files , huge text data. want use full-text indexing while populate database , using mysql text indexing this. want know idea index while populate database or populate database first , index it? because think taking day parse single file , populate database.

database - SQL: Find filled area -

this question has answer here: finding filled rectangles given x, y coordinates using sql 2 answers i have table: create table coordinates ( x integer not null, y integer not null, color varchar(1) not null, primary key(x,y) ) here sample data: insert coordinates (x, y, color) values (0, 4, 'g'), (1, 0, 'g'), (1, 1, 'g'), (1, 2, 'g'), (1, 3, 'g'), (0, 4, 'g'), (1, 0, 'g'), (1, 1, 'g'), (1, 2, 'g'), (1, 3, 'g'), (1, 4, 'g'), (2, 0, 'b'), (2, 1, 'g'), (2, 2, 'g'), (2, 3, 'g'), (2, 4, 'g'), (4, 0, 'b'), (4, 1, 'r'), (4, 2, 'r'), (4, 3, 'g'), (4, 4, 'g'), (6, 0, 'r'), (6, 1, 'g'), (6, 2, 'g'), (6, 3, 'r'), (...

c# - Performing ForEach -

i need increase performance of foreach. //pseudocode foreach (item item in items) { //call service open db conn , data } within loop make call service opens session sqlserver, gets data database , closes session, each iteration. can do?. thanks. well sound use of parallel.foreach - have tried it? parallel.foreach(queries, query => { // perform query }); you may want specify options around level of parallelism etc - , make sure connection pool supports many connections want. , of course, measure performance before , after make sure it's helping.

javascript - How to clear all videos if one video are watched and one click button function -

i have video buttons control playback. if presses play button while video playing, video restart beginning. need disable play button after first click, , re-enable when user requests video. additionally, when user requests video, want current video stop playing , cleared player. currently, when requests video in browsers (such ie), audio first video keeps playing. here code far: <html> <head> <script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $(".buttons").click(function () { var divname= this.value; if (divname == "video") { // add iframe div#video $("#video").append('<h2>youtube<\/h2><iframe title="youtube video player" width="480" height="390...

ios - Change size of showCamera overlay -

i trying add additional interface elements showcamera display in ios app. i know can add overlay code below. problem: overlay always have size of entire screen. problem camera's default control elements (flash, hdr, camera switcher) not accessible anymore. setting touchenabled: false in createview() makes events passed through. makes original control elements work, @ expense of new elements not being accessible @ all. so idea make view smaller not obstruct original elements @ top. own controls positioned on middle/right, no conflict there. however, no such luck. setting height / width attributes in createview nothing. setting these properties later on (either directly or through animate() has no effect. my simplified code: var myoverlay = titanium.ui.createview({ backgroundcolor: '#0f0', // see happening height: 200 // not work // touchenabled: false // touchenabled apparently can't re-enabled objects contained within view. }); var...

actionscript 3 - SwiftSuspenders not working like it should? -

i'm getting feet wet trying use swift suspenders as3 project injections null when try access them. works when use injector.injectinto() explicitly inject object should have reference. can't optimal approach swiftsuspenders, right? aren't change accessing injected properties in class constructor? if so, use postconstruct meta. public class example { [inject] public var foo:bar; public function example() { foo.barme(); // throws null reference error } [postconstruct] public function _postconstruct():void { foo.barme(); // ok } } postconstruct: automatically invoking methods on injection completion instances of classes depend on automatic di ready used after di has completed. annotating methods in injectee class [postconstruct] metadata causes them invoked directly after injections have completed , safe use instance. multiple methods can invoked in defined order using order paramet...

android - How to block outgoing calls and texts to contacts (Prevent drunk dialing) -

i making android app class prevents users calling or texting while drunk. basically, before start drinking, start app block outgoing calls , texts contacts until answer math problem prove sobriety. i've hit snag while trying block calls , texts because can't seem broadcastreceivers accomplish this. when user hits "start" button, i'd broadcastreceiver start listening , blocking outgoing calls until user passes sobriety test (inputs correct answer math problem). there way accomplish this? thanks ton! matt here main activity: public class mainactivity extends activity { int answer; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final edittext userinput = (edittext) findviewbyid(r.id.answerinput); userinput.setenabled(false); //this creates button object "start drinking...

javascript - Increment the name of variable -

basically want increment name of variable. correct syntax this? for (i=0; i<5; i++) { eval("var slider_" + i); var slider_+i = function(){ //some code } dojo.addonload(slider_+i); why not use array? var slider = []; (i=0; i<5; i++) { slider[i] = function(){ //some code } dojo.addonload(slider[i]); } alternatively, access them based on object contained within. assuming global variables (hopefully not): for (i=0; i<5; i++) { window["slider_"+i] = function(){ //some code } dojo.addonload(window["slider_"+i]); } window["something"] way access global variable named something .

WCF jQuery or ScriptManager -

i have asp.net 3.5 web application i have firefox browser plugin use connect , communicate scanner attached client computer. i need send data client computer (retrieved form scanner) remote sql database through wcf web service far have tested following. i able create wcf service (restful) , using json wire data , on client side. i created prototype using jquery , serializied object using json2.js stringify() , sent remote server. similarly, can (retrieve) custom object in client code (javascript) questions a) correct approach? think instead of using jquery/json ( ajax() post) advisable use scriptmanager along ajax enabled wcf. b) currently, plugin sends data javascript object have reformat can wired web service. wcf service accept 1 input object , browser plugin(add-on) data returned javascript object has different property names have recreate object can stringified in format web service accept it can pass object retrieved scanner (inside javascript) directly ,...

database - problem minus in mysql in subtratcting group data -

i have 3 table member ( memberid ,m_name,statusid,address,dob,phone) booking ( bookingid , memberid ,sessionid, cost) session( sessionid , activity,location) (fk memberid, fk sessionid )booking link ( member pk )and (session pk) session activity football,swimming,badminton,tennis want run following query find name of member have booked session 'football', not session 'swimming' during december 2009 sql select distinct event1.m_name ,event1.activity ( select mm.m_name,ss.activity,ss.sessionid,ss.s_date member mm inner join booking bb on bb.memberid = mm.memberid inner join session ss on ss.sessionid = bb.sessionid activity = 'football' )as event1 inner join ( select mm.m_name ,ss.activity,ss.sessionid,ss.s_date member mm inner join booking bb on bb.memberid = mm.memberid inner join sessi...

ruby on rails - Creating a method that given a string (fname lname) returns the two -

given string "james bond" or "roger r burns" i'd create method takes input , returns first , last name: for cases above: input: james bond returns: fname: james lname: bond input: roger r burns returns fname: roger r lname: burns input: roger returns fname: roger lname: input: returns fname: lname: where empty input not error returns empty values. how can make method takes single input , returns 2 variables? thanks how this: def explode_name(str) !str.nil? && str.respond_to?(:split) ? ((2 - (a = str.split(' ', 2)).length).times { << nil };a) : [nil,nil] end explode_name "mr james bond" #=> ["mr", "james bond"] explode_name "mr bond" #=> ["mr", "bond"] explode_name "mr" #=> ["mr", nil] explode_name "" #=> [nil, nil] explode_name nil #=> [nil, ni...

windows - How do you get the string length in a batch file? -

there doesn't appear easy way length of string in batch file. e.g., set my_string=abcdefg set /a my_string_len=??? how find string length of my_string ? bonus points if string length function handles possible characters in strings including escape characters, this: !%^^()^! . as there no built in function string length, can write own function so: @echo off setlocal set "mystring=abcdef!%%^^()^!" call :strlen result mystring echo %result% goto :eof :strlen <resultvar> <stringvar> ( setlocal enabledelayedexpansion set "s=!%~2!#" set "len=0" %%p in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) ( if "!s:~%%p,1!" neq "" ( set /a "len+=%%p" set "s=!s:~%%p!" ) ) ) ( endlocal set "%~1=%len%" exit /b ) this function needs 13 loops, instead of simple strlen function needs strlen-loops. handles charac...

javascript or jquery code to obtain entire text content of web page within an iframe (including/excluding links on that page) -

i know how obtain content of div within iframe using jquery-- iframe content: <div id="mycontent"></div> jquery: $("#myiframe").find("#mycontent") what want is, obtain entire text content of iframe, both text of links within iframe, text content excluding link texts within iframe. i want ideally using jquery, pure js or jquery+ js fine me. you can use .contents() <iframe src="your_url.com" id='myiframe'></iframe> to whole content iframe $("#framedemo").contents() to data specific element. $("#myiframe").contents().find("#mycontent")

android - Shuffle Class Instances -

my program quiz asks questions states create 3 instances of class state state st1 = new state(); state st2 = new state(); state st3 = new state(); like asks question state capital of st1.name , line below gives 3 option string builder sb; sb.append("what capital of "+st1.name+"\n"); sb.append("\n"+st1.capital); sb.append("\n"+st2.capital); sb.append("\n"+st3.capital); maintext.settext(sb.tostring); now problem every time comes correct answer in first line... how avoid ? put correct answer in random spot using java's random class random.nextint(3) give random number between 0 , 2. put correct answer array of size 3 @ location , put 2 wrong answers in remaining locations. loop through array , sb.append(array[i]); (i between 0 , 2) random ordering of state capitals.

java - Performing a JNDI lookup in a JAXB XmlAdapter -

my project java enterprise project , consists of 3 modules: assembly (ear) ejb (jar) web (war) my domain model resides in ejb. includes manufacturer class , model class. one-to-many relationship exists between two. expose instances of these manufacturers , models through rest interface resides in web project. whenever access 1 of these manufacturers, following xml-code generated: <manufacturer id=1> <name>ford</name> <models> <model id=1> <name>fiesta</name> </model> <model id=2> <name>focus</name> </model> </models> </manufacturer> however, want this: <manufacturer id=1> <name>ford</name> <models> <model>1</model> <model>2</model> </models> </manufacturer> i have achieved desired effect writing specialized xmladapter , model...

c# - Amazon Marketplace API -

i expecting amazon marketplace web service simple other web service not.... there seems tiny bit of information marketplace product feeds, , 1 me on how start uploading new product(step step-as new this),and updating quantity or price in future onto amazon in c#.net if can give short summary, i'd grateful. want have web site displays list of products. need send list onto amazon display through 1 of api using c#.net. after digging felt marketplace web service appropriate dont see wsdl url upload product info.please help. use amazon c# client library here: https://developer.amazonservices.com/gp/mws/api.html/180-1400280-4320051?ie=utf8&section=feeds&group=bde&version=latest

sql - How to get the current effective date in Oracle? -

i have table following: tid tname effectivedate 1 2011-7-1 2 2011-8-1 3 2011-9-1 4 2011-10-1 5 b 2011-8-1 6 b 2011-9-1 7 b 2011-10-1 8 c 2011-9-1 etc... if today 2011-9-10, wish query result this: tid tname effectivedate status 1 2011-7-1 invalid 2 2011-8-1 invalid 3 2011-9-1 valid 4 2011-10-1 inactive 5 b 2011-8-1 invalid 6 b 2011-9-1 valid 7 b 2011-10-1 inactive 8 c 2011-9-1 valid if today 2011-10-2, query result this: tid tname effectivedate status 1 2011-7-1 invalid 2 2011-8-1 invalid 3 2011-9-1 invalid 4 2011-10-1 valid 5 b 2011-8-1 invalid 6 b 2011-9-1 invalid 7 b 2011-10-1 valid 8 c 2011-9-1 ...

python - What is the best way to end this thread when a function is called? -

i'm having bit of trouble queue: import queue import threading class test(threading.thread): def __init__(self): threading.thread.__init__(self) self.request_queue = queue.queue() def addtoqueue(self, item): self.request_queue.put(item) def run(self): while true: item = self.request_queue.get(true) print item this simple class implements threaded queue. calling test::addtoqueue append item queue. thread waits item added queue - , prints , waits next thing. my problem application shutdown. best way terminate thread? use condition, how wait either notification condition or new item in queue? you can send poison thread kill it: poison = none # wouldn't put in queue class test(threading.thread): def __init__(self): threading.thread.__init__(self) self.request_queue = queue.queue() def kill(self): self.addtoqueue(poison) def addtoqueue(self, item): ...

php - wordpress - proper foreach in array syntax -

i'm still novice @ php appreciated. i'm using custom menu display 4 posts, , each post i'd post thumbnail. code below, gives me invalid argument supplied error. <div id="stampnav"> <?php $pages = wp_nav_menu( array( 'container_class' => 'menu-header','theme_location' => 'stamp-menu' ) ); foreach($pages $pagg) { echo get_the_post_thumbnail($pagg->id, 'thumbnail'); } ?> </div> you need call global $post , make query post thumbnail menu not return meta associated page, queries built in "menu" custom post type. your other option create custom walker class nav menu.

php - PDO::FETCH_CLASS with multiple classes -

i trying turn query result classes. $result->setfetchmode(pdo::fetch_class, 'myclass', array()); this works quite class name myclass depends on column values. is possible fetch each row , turn different class depending on rows values? user example: id # name # age 1 # jon # 12 2 # sue # 23 3 # tom # 24 i want have users age less 21 instances of class child . rows age of 21 , above should instances of class adult . so "jon" should instance of child . "sue" , "tom" should instances of adult . as not know type (classname) of returned objects before query, can not specify it. however, encapsulate logic inside type use return type can return specific return type: /** * should not have private, public or protected members in it's definition. * * work public properties. */ class returnobject { public function getconcrete() { /* decide here class */ $classname = 'child'; // ...

c++ - Can we use a lambda-expression as the default value for a function argument? -

refering c++11 specification (5.1.2.13): a lambda-expression appearing in default argument shall not implicitly or explicitly capture entity. [ example: void f2() { int = 1; void g1(int = ([i]{ return i; })()); // ill-formed void g2(int = ([i]{ return 0; })()); // ill-formed void g3(int = ([=]{ return i; })()); // ill-formed void g4(int = ([=]{ return 0; })()); // ok void g5(int = ([]{ return sizeof i; })()); // ok } —end example ] however, can use lambda-expression default value function argument? e.g. template<typename functor> void foo(functor const& f = [](int x){ return x; }) { } yes. in respect lambda expressions no different other expressions (like, say, 0 ). note deduction not used defaulted parameters. in other words, if declare template<typename t> void foo(t = 0); then foo(0); call foo<int> foo() ill-formed. you'd need call foo<int>() explicitly. since in case you're u...

asp.net mvc 3 - bits , sharpBits.net -

i using in project bits - background intelligent transfer service send file larg size. using sharpbits.net in c# code. want upload file server client. note sides. -------------client side--------------- static void main(string[] args) { string local = @"i:\a.mp3"; string destination = "http://192.168.56.128/bitstest/home/fileupload"; string remotefile = @destination; string localfile = local; if (!string.isnullorempty(localfile) && system.io.file.exists(localfile)) { var bitsmanager = new bitsmanager(); var job = bitsmanager.createjob("uploading file", jobtype.upload); job.notificationflags = notificationflags.joberroroccured | notificationflags.jobmodified | notificationflags.jobtransferred; job.addfile(remotefile, localfile); job.resume(); job.onjoberror += new event...

Setting a background image while loading an Android app -

how add background android app @ loading time? shows white page. public class splashscreen extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.splashscreen); thread splashthread = new thread() { @override public void run() { try { int waited = 0; while (waited < 1000) { sleep(100); waited += 100; } } catch (interruptedexception e) { // nothing } { intent = new intent(splashscreen.this,party_tablayout.class); startactivity(i); finish(); } } }; splashthread.start(); } } hope helps you..:-)

php - Magento : Problem in Importing the csv file -

Image
i have csv file 2 records. when try upload file through magento upload module it's uploading more 196 records. crossed check in file 2 records there. what's problem? it's related cache or index something?? reference attached screenshot of page also. you have records stuck in dataflow_batch_import reimporting. it's common problem have stuff stuck in dataflow_batch_(import|export) , nexcess has nice cleanout tool here. dataflow batch table cleanout you can monitor various log tables bloat , @ dataflow table contents script see if have stuck items before doing import. log table monitor dataflow import keeps each import file you've uploaded (var/import littered these unless manually delete them). make sure choosing latest file you've uploaded when go run profile. numbers @ front of file names in dropdown list date/time stamps.

python - Is Pro Django book still relevant? -

i want dig deeper django's internals , official online documentation goes far toward end. the reviews marty alchin's pro django fantastic (i've read pro python , enjoyed it). however, book 2008 , based on django v1.0. company builds off v1.3. is book still worthwhile? how can best learn django's meta-programming (beyond looking through source code, doing)? thanks yes, it's still relevant. although lot has changed in django since version 1, internal parts , concepts pro django deals same. i'd have no hesitation in recommending book - it's useful insight how django works , teaches useful methods well.

android - How to safely read from a database that another process may be using? -

i read data webview.db database created when app uses webview. however, database managed classes package level or not provide in way of access through apis. since can't share database objects or locks, how can safely read content database without getting "database locked" errors or similar exceptions? i need read, not need write. if there no way safely aquire sql queries/cursors on it, there way safely copy actual webview.db file in thread safe manner? there danger of getting corrupt copy? thanks much i think locks @ sqlite level, not in java code, should able away opening db , reading without confusing webview. however, same reason should prepared lock errors , retry queries until lock gone. db locked when webview data altering statements. webview doesn't put exclusive lock on db whole time it's running, don't see reason that.

build - Building along with Project Dependencies in Ant -

i have java project dependent on other java projects siblings , there chain of dependencies. each individual project has build script written in ant. clarity find below sample of same. earproject depends on webproject , ejbproject : war file generated webproject build , jar file generated ejbproject needed build earproject . webproject depends on componentoneproject : jar file generated componentoneproject build needed build webproject . ejbproject depends on componenttwoproject : jar file generated componenttwoproject build needed build ejbproject . so, when build earproject build, if dependent war , jar have not been built yet, should kick-off webproject build , ejbproject build , if componentoneproject yet built, build of componentoneproject needs kicked-off , on. can suggest clean method can accomplish this? facing same problem @ our company wrote custom groovy script explores full dependency tree ant generates ant build scripts based on .p...

asp.net - How to retrieve PID(Process ID) of a com application created by net assembly -

i calling third party com object asp.net invoke executable follows b = new mybw.baan4class(); at given time there muliple instances invoked asp processes. how can pid of b can 'kill' without disturbing(killing) others.. without knowing more details com object using don't think there's great way associate exe launches , object creating. with said delegate responsibility of creating these objects centralized location (wcf service running in singleinstance mode maybe) can associate object created exe instantiating new object , waiting exe launched. when exe has been launched can associate object created exe launched. use wmi detect when new exe has been launched. it's going pretty impossible in asp.net since multiple users instantiating these objects @ same time. running race conditions if tried here. here similar question: how determine association between vb6 app , exe instanced createobject()

setcookie does not work (PHP) -

what's wrong code? setcookie("password",$wachtwoord,0, "/", ".thedomainname.com"); echo $_cookie['password']; //shows nothing i attempting set cookie , display value? are waiting next request before examine $_cookie ?

c# - From Silverlight to MVC CslaModelBinding child collections -

background: a while ago developed business application silverlight using csla framework. wish create mvc alternative people unable use silverlight 1 reason or another. the problem: now problem wish re-use existing business library mvc application. wish save parent , children batch cslamodelbinder not bind child objects. there way of binding these child collections? if not, , have save each child seperate though parent easiest way? (bearing in mind child objects have child data portal methods) i've tried looking around forums , have managed find small handfull of posts regarding problem , these little old, wondering if has found solution since then? thanks bunch! to close loop on question, thread in csla forums seems provide answers: http://forums.lhotka.net/forums/t/10770.aspx

Encrypt password custom rule in DataMapper and Codeigniter -

i using codeigniter 2.0.3 datamapper orm 1.6.0. integration datamapper in ci has been implemented , works fine, except password encryption. i have model called users.php class users . have set validation rules: var $validation = array( array( 'field' => 'password', 'label' => 'password', 'rules' => array('required', 'trim', 'unique', 'min_length' => 5, 'encrypt'), ), array( 'field' => 'email', 'label' => 'email address', 'rules' => array('required', 'trim', 'valid_email') ) ); my encrypt function in validation rule: function _encrypt($field) { // don't encrypt empty string if (!empty($this->{$field})) { // generate random salt if empty if (empty($this->salt)) { $this->salt = md5(uniqid(ra...

virtualbox - Create and modify the contents of a VDI disk image in Linux -

is there way can create virtual box disk image (.vdi) ntfs formatted , copy set of files prior attaching configured instance second disk using vboxmanage? yes, have to: "aattch" vdi file disk device "mount" ntfs partitions in vdi file ways of doing described in post: https://serverfault.com/questions/210684/how-do-you-mount-a-vdi-image-on-linux

workflow - Any advice for working (almost) entirely in Terminal, or command line? -

i'm front-end developer working way towards back-end. i've been learning ror , have become quite comfortable performing simple command line tasks in terminal (osx), i'm looking expand knowledge. i know it's possible answer emails, use ftp, open folders, create directories, , in command line. i'm trying simplify workflow , i'd learn how these things in terminal. there resources or starter guides this, or should learn each task 1 @ time? i've tried google ninja skills , have been unsuccessful. terms terminal, streamlining, , workflow tend bring bunch of irrelevant results. learn basics bash. using pipes, stdin, stdout, etc learn commonly used commands , applications. mkdir, cp, cd, chown, chmod, git learn write bash scripts can optimize workflow. example setting development envirnoments, backing data, tar:ing , archiving it. some background info shell some commands learn started i found writing utility scripts helped me lot understan...