Posts

Showing posts from January, 2013

c# - Publish/Subscribe pattern using OperationContext.Current.GetCallbackChannel<T>() -

i have wcf service implements callback pattern shown in msdn documentation . binding: wsdualhttpbinding . works fine. as can see in example paragraph, "callback channel" (so, server client) using code: operationcontext.current.getcallbackchannel<t>() i used callback pattern implement publish/subscribe mechanism. this, store every "callback channel" list , use contact subscribers when publish event fires. clients can subscribe service, calling specific procedure. after tests, seems work fine. however, have questions: right way , use "callback channels"? there expiration time of channels? there limits in implementation? getcallbackchannel method have limits (i.e. how works, exactly)? subscribers dynamic clients, server have when subscriber breaks down? i work first time callback , publish/subscribe model, need guidelines.

CSS dropdown menu fading in improperly -

having bit of strange problem setting fade in drop down menu - here's css it: .main-navigation li ul li { opacity:0; transition:opacity 0.3s linear; -webkit-transition:opacity 0.3s linear; -moz-transition:opacity 0.3s linear; -o-transition:opacity 0.3s linear; } .main-navigation li:hover > ul li { opacity:1; } and html (as generated through wp): <nav id="site-navigation" class="main-navigation" role="navigation"> <h3 class="menu-toggle">menu</h3> <a class="assistive-text" href="#content" title="skip content">skip content</a> <div class="menu-nav-container"><ul id="menu-nav" class="nav-menu"><li id="menu-item-23" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-10 current_page_item menu-item-23"><

Prevent duplicate record entry in text file Java -

i have assignment write gui , have information written text file when evaluate button pressed read in data text file sum required fields , if total equal or greater 8000 write records new file creates. have working pretty have hit wall when comes preventing duplicate entries. program not allow duplicate entries. can see there duplicates can't seem printwriter not fire. i've tried boolean if duplicate records exist blocks conditional part writing empty file. appreciated. package reprecord; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class dataentry extends jframe { private jtextfield repidfield; private jtextfield repfirstfield; private jtextfield replastfield; private jtextfield suppliesfield; private jtextfield booksfield; private jtextfield paperfield; private jradiobutton northradiobutton; private jradiobutton southradiobutton; private jradiobutton eastradiobutton; p

How to add a constraints in OptaPlanner for vehicle routing -

i working on vehicle routing problem have implement constraint ensures specific location/s shouldn't 1st or last location traversed. idea how can addressed ? there couple of ways can this: the easy way: if (customer.getpreviousstandstill instanceof vehicle) // first visit if (customer.getnextcustomer == null) // last visit the hard way (in case need single out 37th visit etc): in planning entity customer , add shadow variable visitnumber , in vehicle , add shadow variable visitnumbertotal . use variablelisteners keep in sync.

excel - If equals error in VBA -

so i've been having issue script , wondering if point me in right direction fix it. i'm trying scan cell range , find value of "x", has align array (which seems working) finds value in range of columns greater 7. option explicit private sub worksheet_activate() dim ws worksheet dim lrow long dim rng range dim checks variant dim riskname variant dim level integer dim threatagent variant dim vulns variant dim x integer dim y integer dim impactrange range dim impactcell range dim checksrange range dim checkscell range me.usedrange.offset(17).clearcontents x = 2 y = 1 sheets("ta & vul combinations") .autofiltermode = false set impactrange = .range("r3:r50") each impactcell in impactrange.cells if impactcell.cells > 7 , not isempty(impactcell.cells) impactcell.copy sheets("temp").range("b" & x).pastespecial xlpastevalues x = x + 1 else

dictionary - Android - What data structure to store video subtitles to get them in O(1) time -

i playing video in application , have show subtitles on top of that. subtitles in separate smi file sort of xml markup provides subtitle information. subtitle file looks this: . . . <sync start=104600> <p class=gbr><i></i><span id=style1_0><i>born of cold , winter air</i> </span><br><i></i><span id=style1_0><i>and mountain rain combining.</i> </span></p> </sync> <sync start=107080> <p class=mys>&nbsp;<br></p> </sync> <sync start=107200> <p class=mys><i></i><span id=style2_0><i>...serta hujan di pergunungan.</i> </span></p> </sync> <sync start=110840> <p class=mys>&nbsp;<br></p> <p class=gbr>&nbsp;<br></p> </sync>

textbox - Trying to understand a JQuery routine -

i had fantastic david on post how reset css before repeating sequence there wasn't enough room in comments ask questions. david set jquery right , rewrote of because heading in wrong direction have want, text appears on right, slides on left, pauses , fades. new line of text same thing , can have many lines want. i understand happening here, i'm complete noob jquery. here jsfiddle of working - http://jsfiddle.net/bf49z/13/ - have rearranged lines make more sense me. here questions wouldn't fit in comments - what hard understand why animation stopped, before it’s started. $elements.eq(index).stop() .animate({ i assume stops animation @ second, third, fourth etc repeats? then .animate({"opacity": "1", //animate opacity opaque "left": "6px" //animate left 6px }, 1000, makes visible , moves left, taking 1 second? i understand $(this).delay(3000) .animate({ //wait 3000ms then next line way of

ios - How to create SPTrack with the help of spotifyURL? -

so far have done this. return nil in sptrack. nsurl *trackurl = [nsurl urlwithstring:msg]; // spotify:track:489k1qunrvbm2ops4xglnd [[spsession sharedsession] trackforurl:trackurl callback:^(sptrack *track) { self.currenttrack = track; nslog(@"sptrack : %@",self.currenttrack); if (track != nil) { [spasyncloading waituntilloaded:track timeout:kspasyncloadingdefaulttimeout then:^(nsarray *tracks, nsarray *notloadedtracks) { self.currenttrack = track; nslog(@"sptrack : %@",self.currenttrack); }]; } }]; your code looks fine, double check that: 1) url correct. 2) cocoalibspotify logged in valid user. practically nothing works unless you're logged in.

python - Matplotlib equivalent of Matlab's cellplot() -

Image
there cellplot() function in matlab visualizes contents of cellarray. visualize contents of python tuple in similar manner. there function in matplotlib or other python library achieve ? thanks. for example, cell array in matlab be a = {['1st element'] [2 3] [8 9 7; 1 2 3] ['a' 'b']}; the output of cellplot(a) :

knockout.js - How to deal with many templates in knockout? -

while working knockout use templates lot. because working on single page application, amount of templates using becoming bigger , bigger. my main html started this: <!-- id's knockout binding --> <span id='...'>...</span> <span id='...'>...</span> .... <span id='...'>...</span> <!-- templates --> <script type="text/html" id="template_1">...</script> <script type="text/html" id="template_2">...</script> ... <script type="text/html" id="template_100">...</script> nonetheless works expected, intimidated huge amount of templates, being loaded in beginning. so there best-practice regarding issue, or how people experience knockout dealing it? external templates better instead of having templates in 1 file.by having external templates can call them on demand rather loading @ time.so there many options

winforms - Get source of event in C# Windows Forms -

i have list of string want create menu of toolstripitem (neither list size nor content know @ debug) , want each item execute same event, go through list code: foreach (string in items) { toolstripitem item = (toolstripitem)toolstripmenuitem1.dropdownitems.add(i); item.click += new eventhandler(item_click); } the problem in item_click method need know of above items triggered event. if in wpf, have used routedeventargs , .source proprety since in regular windows forms app, i'm not quite sure how it. there simple way it? thank you. use sender parameter in click event var item = sender toolstripitem; if(item != null) { ... }

java - Cannot list the data in my android application from Mysql -

new in android development. trying database crud operation in android application. can insert data mysql.am using php , json parsing it.when data inserted database, next activity should listing data.the problem no data coming listing activity. activity coming without data. kindly me . java code listing products public class allproductsactivity extends listactivity { // progress dialog private progressdialog pdialog; // creating json parser object jsonparser jparser = new jsonparser(); arraylist<hashmap<string, string>> productslist; // url products list private static string url_all_products = "http://10.0.2.2/get_all_products.php"; // json node names private static final string tag_success = "success&q

Multiple Java and Ant -

i advise on following issue. need have both java 6 , java 7 run on machine. @ same time, need have ant installed. therefore, understand need edit environment variables. have setup accoirdinly accordinly shown below when type ant or java -version on cmd both commands indicating not reconised. please advice on issue. environtment variables (system variables) ant_home = c:\apache\ant java_6 = c:\progra~2\java\jre6 java_7 = c:\progra~1\java\jdk1.7.0_25\jre java_home = %java_6% (or java_home=%java_7%) path = %java_home%\bin;%path%;%ant_home%\bin after setting following amendments in environment varibales, both ant -version, java -version commands give me "java.exe" not recongined after restarted pc, worked properly.

group by list on same field with different case classes scala -

how can grouped 2 list contains different case classes, on both classes have same field: case class x(a:long, b:long, c:long, d:long) case class y(a:long, e:long, f :long) val = list(x(10,10,8,8)) val j = list(y(10,10,8)) val joined = a++b joined.groupby(_.a) error: value not member of product serializable thanks fearing not pattern match: scala> val joined = (i++j) groupby { case x: x => x.a case y: y => y.a } joined: scala.collection.immutable.map[long,list[product serializable]] = map(10 -> list(x(10,10,8,8), y(10,10,8))) crudely requested: scala> val joined = ((i++j).asinstanceof[list[{ def a: long }]]) groupby(_.a) warning: there 1 feature warning(s); re-run -feature details joined: scala.collection.immutable.map[long,list[anyref{def a: long}]] = map(10 -> list(x(10,10,8,8), y(10,10,8))) or scala> val joined = (i++j) groupby { case x => x.asinstanceof[{ def a: long }].a } warning: there 1 feature warning(s); re-run -feature de

Visual C# Programming a Login form connected to a Access Db that gives only tries to log into -

i developing login form in c#. form connects database match username , password , find duplicate. trying implement loop accept 3 tries close. code is: namespace royalcollegeapp { public partial class login : form { public login() { initializecomponent(); } private void login_load(object sender, eventargs e) { } private void btn_login_click(object sender, eventargs e) { if (string.isnullorempty(txt_user.text)) { messagebox.show("please type username"); txt_user.focus(); return; } if (string.isnullorempty(txt_pass.text)) { messagebox.show("please type password"); txt_pass.focus(); return; } try { string constring = @"provider=microsoft.ace.oledb.12.0;

php - Regex blocking special characters -

i'm using php version 5.3.27 i'm trying regex match whitespace, , special characters such ♦◘•♠♥☻, other known special characters %$#&*@ matched, somehow ones mentioned before not matched.. current regex preg_match('/^[a-za-z0-9[:space:]]+$/', $login) my apology asking 2 questions on same subject. hope 1 clear enough you. use this [\w]+ will match non-word character.

c# - Find strings in string based on condition -

working on migration project legacy intranet new one i need cleanse html , it's going pretty stuck on 1 thing have string (dynamic html): armenu1 = new array( "management team","href="http://sites/get?&p131" ) armenu2 = new array( "ipads","href="http://sites/get?&page391" "remote access services","href="http://sites/get?&p375" ) armenu2_1 = new array( "tips , bits","href="http://sites/get?&p395 ) armenu2_3 = new array( "worldmate blackberry","href="http://sites/get?&p265" ) armenu3 = new array( "overview","href="http://sites/get?&p434" "outlook 2010","href="http://sites/get?p430" ) armenu3_3 = new array( "excel 2010","href="http://sites/get?&p451" ) i have variable navnodepopupid + "_" , need to menu items in array containing armenu2_*

android - Why do my objects become null on returning to my previous Activity -

i have 2 activities suppose , b; activity a has several objects of view [ textview , tabview , listview etc]: i fire intent using startactivityforresult , go activity b then computation required in activity b , return activity a setruslt , finish(); on returning onactivityresult work according result sent activity b ; everything above works fine.[during testing] but when have deployed application facing crashes [unexpected nullpointer exception] -> in cases listview inside onresume method null; -> in cases tabview null; -> in cases database object instance null; am missing important step of activity lifecycle. works fine while in testing. please note: have map views on both activities please help. thank in advance. here's stack trace java.lang.nullpointerexception @ in.abmulani.thisway.mainactivity.onkeydown(mainactivity.java:511) @ android.view.keyevent.dispatch(keyevent.java:2719) @ android.app.activity.dispatchkeyevent(activity.jav

html - How to make fit size only for Image in UIWebView? -

i loaded html uiwebview including both text , images . text fit uiwebview , images not fit uiwebview . it's large in uiwebview . it's showing scroll bar @ end of uiwebview . i want adjust image fit size in uwebview. tested following codes. self.mywebview.scalespagetofit = yes; however it's fixed including text , text small read , images fixed. i want set text , want fit size image in uiweview . how can it? use viewport meta tag used uiwebview on iphone/ipad determine how display web page. <meta name="viewport" content="width=device-width, maximum-scale=1.0" /> refer below link more details: https://developer.apple.com/library/ios/documentation/appleapplications/reference/safariwebcontent/usingtheviewport/usingtheviewport.html

Ruby/openssl: convert Elliptic Curve point octet string into OpenSSL::PKey::EC::Point -

i trying write ruby code check elliptic curve digital signature algorithm (ecdsa) signature on particular message found here . the problem don't know how convert octet string public key openssl::pkey::ec::point object. if writing in c, pass octet string openssl's o2i_ecpublickey , close want , in fact used reference implementation . however, searched source code of ruby (mri) , contains no calls o2i_ecpublickey don't know how use function ruby without writing c extension. here octet string, in hex. 0x04 byte followed 2 32-byte integers represent x , y coordinates of point on elliptic curve: 04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284 so know how convert string in openssl::pkey::ec::point in ruby? once point object, use in following code believe verify signature: key = openssl::pkey::ec.new('secp256k1') key.public_key = point result = key.dsa_verify_asn1(diges

lua - auto adjust screen when native.textfield is clicked using corona sdk -

i'm using corona sdk project , have native text field in page. when clicked native textfield, the keyboard appears , keyboard blocking textfield. there way beside scrollview can use? i'm hoping can when texting, screen auto adjust textfield cannot blocked. in advance guys! here code in textfield: function scene:enterscene( event ) local group = self.view local bg_x = display.contentwidth local bg_y = display.contentheight search_field = native.newtextfield( 40, 85, 240, 23) search_field:settextcolor( 204,204,204 ) search_field.x = bg_x*0.5 search_field.y = bg_y*0.65 -- search_field.size = 17 search_field.width = bg_y*0.4 search_field.height = bg_y*0.07 search_field.font = native.newfont( "ptsans-regular", 17 ) search_field.align = "center" end there's no way have screen auto-adjust. have program in yourself. can searching on google around topic of 'corona sdk textfields' , @ of blog , forums posts it.

ios - Give section index without any section in table view in objective C for sorting single NSArray? -

means want records nsarray starts 'j' when tapped on 'j' section title in right side. below give code in code don't want section have 1 plist in store states in india don't want section , when tap on alphabet @ time sorting perform , rows starts tapped alphabet want. give example above , code below -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { nslog(@"enter in numberofrowsinsection method."); nslog(@"returning number of rows in plist.==%d ",test.count); return test.count; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { nslog(@"enter cellforrowatindexpath method."); nslog(@"creating cell.."); //create cell uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cell"]; //the above line used reuse memory in tableview allocate memory di

javascript - how to make date and time picker in angularjs ? date and time should be in same interface? -

i want date , time picker in angular js file, in when clicked in textbox date , time picker poped up. in popup need date selection , time selection simultaneously. yes can use angularjs datetimepicker... follow https://github.com/g00fy-/angular-datepicker , place in website...

Ruby installation missing psych, suggests reinstall of libyaml and ruby, and still have image not found? RailsTutorial -

when using command in middle of railstutorial ( on laptop setup) : rvm use 2.0.0@railstutorial_rails_4_0 --create --default i receive following errors: laptop:rubygems-1.8.25 user_name$ rvm use 2.0.0@railstutorial_rails_4_0 --create --default using /users/user_name/.rvm/gems/ruby-2.0.0-p451 gemset railstutorial_rails_4_0 /users/user_name/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/yaml.rb:4:in `<top (required)>': seems ruby installation missing psych (for yaml output). eliminate warning, please install libyaml , reinstall ruby. /users/user_name/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/users/user_name/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/x86_64-darwin13.1.0/psych.bundle, 9): library not loaded: /usr/local/lib/libyaml-0.2.dylib (loaderror) referenced from: /users/user_name/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/x86_64-darwin13.1.0/psych.bundle reason: image not found - /users/user_name/.rv

objective c - Static float with initializer possible? -

i want in obj-c. example: extern float transition_time = 0.5f; or better: static float transition_time = 0.5f; so automatically imported headers! however, both give kind of warning: 'extern' variable has initializer try separate declaration this extern float transition_time; float transition_time = 0.5f; although situation different, there's nice explanation in this link .

javascript - usage of external css in ui binder to greyout the particular div at time of submitting the form -

i want grey out particular portion of div during button click event. if have passed value in 2 textboxes , clicked button submitting value database @ time screen should grey out widgets in disable mode. i want done in ui binder of css,javascript try this $("#divid1").click(function(event){ $("#someportiondivid2").css("background-color",'#ccc'); }); in case: $("#submitid").click(function(event){ $("#textbox1").prop('disabled', true); $("#textbox2").prop('disabled', true); });

java - How to set JLabel in a specific area in JFrame? -

Image
i trying make desktop application in java swing. trying create image slider in frame , got it. problem in want set specific area imagelabel in frame. how can this? want set imagelabel in left side. posting snapshot getting after running program. here code public class imageslider extends jpanel implements actionlistener { private static final int max = 20; private static final font sans = new font("sansserif", font.plain, 16); private static final border border = borderfactory.creatematteborder(4, 16, 4, 16, color.blue); private list<string> list = new arraylist<string>(max); private list<imageicon> cache = new arraylist<imageicon>(max); private jlabel imagelabel = new jlabel(); //label = new jlabel( image, swingconstants.center); private jbutton prevbutton = new jbutton(); private jbutton nextbutton = new jbutton(); private jcombobox favorites; public imageslider() { this.

objective c - ios UIPickerView scrolling too fast -

Image
i using uipickerview in conjunction uitextfield input values textfield. pickerview displays range of numbers each number equivalent row in picker view. - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview { return 1; } - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent: nsinteger)component { return self.max + 1; } - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { return [nsstring stringwithformat:@"%d", row]; } when user selects value in picker text field should reflect value: - (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent: (nsinteger)component { self.quantityfield.text = [nsstring stringwithformat:@"%d", row]; } however, noticing if spin picker quickly, row passed didselectrow not match row settled upon in picker. thoughts on why happening , how prevent this? the field 6 in repres

c# - Catching exceptions from Application.Run() -

this question has answer here: how can make catches 'unhandled' exceptions in winforms application? 4 answers i have standard code in project: try { myform = new myform(); application.run(myform); } catch (exception e) { // handle uncaught exceptions } but, when there unhandled exception somewhere in program, still shows "default" exception handler , catch never hit. want handle fatal errors known fatal errors (connection lost, example). one possibility appdomain.unhandledexception . here more details: http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception%28v=vs.110%29.aspx also, here older - still excellent - article: http://www.codeproject.com/articles/7482/user-friendly-exception-handling

python - how to get a few items from the set? -

please 2 of 3 li. use following script: import lxml.html doc = lxml.html.document_fromstring(""" <ul> <li>111</li> <li>222</li> <li>333</li> </ul> """) lis = doc.xpath('//li') = 0 result = [] elem in lis: result.append(elem) = + 1 if > 1: break print(result) but need sample made ​​no xpath-expression , cycle, xpath-expression. you can use position() reduce xpath result set, eg: result = doc.xpath('//li[position() <= 2]') # [<element li @ 0x7f7728684530>, <element li @ 0x7f7728684590>]

C Program - Another nested loop issue -

just started learn nested loop logic in c programming, , don't know how achieve in c programming, length , row should follow input number, , use '-' separate data enter number: 2 -1-3 ---- enter number: 7 -1-3-5-7-9-1-3 -------------- -1-3-5-7-9-1-3 -------------- -1-3-5-7-9-1-3 -------------- -1-3-5-7-9-1-3 anyone knows how achieve it? help. #include <stdio.h> int main(){ int i,j,n; printf("enter number: "); scanf("%d", &n); for(i=0;i<n;++i){ for(j=0;j<2*n;++j){ if(i%2==0 && j%2==1) printf("%d", j % 10); else printf("-"); } printf("\n"); } return 0; }

apache - Extensions shown in phpinfo() don't match with those enabled in loaded php.ini -

i use enterprisedb apachephp on windows xp (32 bit). tried enable extensions in php.ini in directory apachephp, nothing changed. found phpinfo() not doesn't show extensions uncommented in php.ini, shows others didn't uncomment. have several other php.ini files on computer, phpinfo() shows correct path php.ini file "loaded configuration file" ( d:\programy\edb_apache\php\php.ini - path php.ini file use; plus shows copy in c:\windows in "configuration file (php.ini) path"). the configuration must overriden in apachephp - pgsql , pdo_pgsql among commented shown libraries, while other php.ini instances have mysql , sqlite enabled. on other hand, extensions contained in d:\programy\edb_apache\php\sdk\include\ext ( d:\programy\edb_apache apachephp root) don't match shown in phpinfo(), might more difficult. so how find , edit configuration shown in phpinfo(), or how solve bug causing not correspond loaded php.ini file? please don't tell me resta