Posts

Showing posts from July, 2012

wpf - Border IsMouseOver Trigger not working -

Image
i have problem trigger , property ismouseover in following snippet <border name="part_logo" background="{dynamicresource accent}" width="36" height="36" horizontalalignment="right" verticalalignment="top" margin="0,0,76,0"> <border.inputbindings> <mousebinding command="presentation:commands.logoclickcommand" gesture="leftclick" /> </border.inputbindings> <border.style> <style targettype="border"> <style.triggers> <trigger property="ismouseover" value="true"> <setter property="bitmapeffect"> <setter.value> <blurbitmapeffect radius="3" kerneltype="gaussian"/> </setter.value> </setter> ...

java - Trying to persist an entity with @ManyToOne mapping -

i'm trying persist user has mapping @manytoone userstatus but when code below, hibernate throws propertyvalueexception user.setstatus(new userstatus(1)); em.persist(user); // ou session.saveandupdate(user); to work have way: user.setstatus(em.getreference(userstatus.class, 1)); em.persist(user); // ou session.saveandupdate(user); i know first way possible, don't know whether need configure or call method (i've tried saveandupdate session , still same) does have idea? the error message is: not-null property references null or transient value the mapping @manytoone(optional = false) @joincolumn(name = "user_status_id", nullable = false) public userstatus getstatus() { return status; } this error means " you referencing null (not persisted) object " , have choice: remove nullable or set @cascade userstatus per persisted when em.persist(user) @manytoone(optional = false) @joincolumn(name = "user_status_id"...

java.util.ServiceLoader not loading my provider class -

i trying put basic spi-based registry of handlers, lookup handlerregistry. when use serviceloader.load(handler.class) initialize providers, , iterate list lazily load them, not seeing instances of class. keeping simple possible, handlerregistry class is: public class handlerregistry { private static handlerregistry registry; private serviceloader<handler> handlerloader; private handlerregistry() { handlerloader = serviceloader.load(handler.class); } public static synchronized handlerregistry getregistry() { if (registry == null) { registry = new handlerregistry(); registry.init(); } return registry; } private void init() { system.out.println("handlerregistry.init()"); } public handler lookup(string item) { system.out.println("lookup("+item+")"); try { iterator<handler> = handlerloader.iterator(); while (it.hasnext()) { handler handler = it.next(); system...

javascript - Add jquery listener to dynamically created element -

i need add jquery listener dynamically created elements. cannot life of me work. tag_options not dynamic, children are. have tried 3 ways: http://jsfiddle.net/nfe2f/ <div id = "tag_options"> <div class = "tag_option">hover me</div> </div> the js: // never works $('#tag_options').delegate('.tag_option', 'hover', function(event){ alert(); }); // never works $("#tag_options").on("hover", "[class='tag_option']", function(event) { alert(); }); // works if not dynamically created $('#tag_options .tag_option').hover( function(){ alert(); }); there no hover event anymore , delegate being phased out in favor of on . you'd want use mouseenter , mouseleave . believe you're shooting this: $('#tag_options') .on('mouseenter', '.tag_option', function(e){ /* wax on */ }) .on('mouseleave', '...

validation - PHP WideImage check if valid image -

i using wideimage manage images uploaded application. however, no validity checking on documents application assumes gets uploaded valid image document. how can use wideimage check if file image , not word document renamed .jpg example. have checked wideimage docs couldnt find anything.. detective skills lacking maybe thats why... here code use wideimage: $image = \wideimage::loadfromfile($new_file); $splash = $image->resize('600', '600', 'outside'); $splash->savetofile($dir . '/' . $media_id . '.logo.jpg'); the function loadfromfile returns image object , can validate variable $image instance of wideimage_paletteimage or wideimage_truecolorimage class. if that's valid instance, uploaded file should valid image file. http://wideimage.sourceforge.net/wp-content/current/doc/wideimage/wideimage.html#methodloadfromfile

html - iframe does not show in IE8 -

i have hotel reservation system inside iframe not show in ie8. i'm thinking doctype issue? you can view http://bit.ly/15nhlav this doctype website. iframe not have doctype declared. <!doctype html> <!--[if ie 8]> <html class="no-js lt-ie9" <?php language_attributes(); ?>> <![endif]--> <!--[if gt ie 8]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--< [endif]--> i've found it'll show iframe if inner width of browser ( document.documentelement.clientwidth ) 1095px or larger. lower , gets pushed underneath (this happens other browsers tested with, too). however, in ie8 iframe covered element (i couldn't find which), fixed adding following css style: .iframe-home-res { z-index:10000; } this forces iframe render on top of other elements (unless have z-index greater 10,000, have manually set). you might want @ iframe 's code separately thoug...

c# - How to use a Variable Name which was Obtained at Run-Time -

all, provide on-the-fly mechanism debugging application in different languages using required resource string (in foreign language) display english equivalent @ run-time should user require it. done using public static string getmessage(string messagekey) { cultureinfo culture = thread.currentthread.currentculture; if (!culture.displayname.contains("english")) { string filename = "messagestrings.resx"; string appdir = path.getdirectoryname(application.executablepath); filename = path.combine(appdir, filename); if (file.exists(filename)) { // english error message. using (resxresourcereader resxreader = new resxresourcereader(filename)) { foreach (dictionaryentry e in resxreader) if (e.key.tostring().comparenocase(messagekey) == 0) return e.value.tostring(); } } } return null; } where g...

lua - Attempt to index local 'star1' (a nil value) -- I've researched everywhere and don't get it -

i've been stuck on while , need help. i'm trying have these objects spawn on screen , allow player drag them around want. at moment random objects flow onto screen, when try click on 'star1' error : attempt index local 'star1' (a nil value) how should properly? here code: display.setstatusbar(display.hiddenstatusbar) local physics = require('physics') physics.start() --physics.setgravity(0, 0) _w = display.contentwidth; --returns screen width _h = display.contentheight; --returns screen height local bg = display.newimage('bg1.png') local startable = {} ship = display.newimage("head.png") ship.name = "ship" ship.x = -80 ship.y = 100 physics.addbody(ship, { issensor = true }) ship.bodytype = 'dynamic' shipintro = transition.to(ship,{time=4000, x=200}) ship.width = 40 ship.height = 40 ship.gravityscale = 0 local star1 = display.newimage("acorn") star1....

django - Python 2.6 on MacOSX - ImportError: No module named _collections -

i'm little bit baffled error i'm getting when try runserver or syncdb - server running fine other night when last logged on, have no idea why of sudden it's not working. google gave me following page doesn't address issue. let me know if need more if console information below isn't enough. not efficient django yet, complete beginner really, , i'm not sure why isn't working. pythoness-410:auth gfleche$ python manage.py runserver traceback (most recent call last): file "manage.py", line 8, in <module> django.core.management import execute_from_command_line file "/library/frameworks/python.framework/versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 1, in <module> import collections file "/library/frameworks/python.framework/versions/2.6/lib/python2.6/collections.py", line 8, in <module> _collections import deque, defaultdict importerror: no module named...

ios - How to accomplish a "90% slide" between two UIViews -

Image
i have particular scenario i'm trying emulate and, being new cocoa touch, i'm not sure of best way accomplish it. pardon lacking tactical knowledge; clear exposition help. what i'd emulate: the app i'm looking @ (in particular) beat . below example of 1 of uiviews - in particular, notice gear icon settings @ bottom. when gear touched or swiped up, 2 primary uiview changes occur: the original uiview slid screen 90% of way (the key point being not slide all way up). a new uiview slid fill newly vacated 90% space. this basic functionality accomplish. implementation idea #1: single uiviewcontroller w/ multiple uiviews at first, considered having single uiviewcontroller manage both "main" , "settings" views. in case, simple thing transition these views in appropriate manner. that said, seems bit cluttered me. depending on how robust 2 sets of functionality are, that's recipe overload single uiviewcontroller. might tell me ...

c# - Return ComboBox as Boolean -

i know not best practice use boolean combobox application returns data yes/no thats required. i'm trying return whether yes or no getting warning 'possible unintended reference' cleaning code appreciated. public bool playdatatoend { { return this.playdatatoend.selectedvalue == "yes"; } set { this.playdatatoend.selectedvalue = true; } } suppose internal combobox named playdatatoendcombo : public bool playdatatoend { { return playdatatoendcombo.selectedvalue.tostring() == "yes"; } set { playdatatoendcombo.selectedvalue = value ? "yes" : "no"; } } i think should use index convention: 0 yes , 1 no : public bool playdatatoend { { return playdatatoendcombo.selectedindex == 0; } set { playdatatoendcombo.selectedindex = value ? 0 : 1; } }

asp.net mvc - Unit Tests - Referencing 3.0.0.0 MVC, version actually 4.0.0.0 -

i've googled, answers haven't been helpful me personally. i testing sendemail using unit tests (nunit) // arrange var mockdbcontext = new mock<dbcontext>(); iservice service = new service(mockdbcontext.object); // act var result = service.sendemail(string.empty,1,1); //assert assert.that(result, is.not.null); assert.that(result, is.instanceof<bool>()); assert.areequal(result, false); public bool sendemail(string emailaddress, int mid, int deadline) { try { dynamic email = new email("circulationemail"); email.to = emailaddress; email.mid = mid; email.deadline = deadline; email.send(); return true; } catch (exception ex) { elmah.errorsignal.fromcurrentcontext().raise(ex); return false; } } sendemail uses postal. i following error when run test. when debug throws error before hitting fir...

Filtering MySQL data by rails session parameter -

i've got rails application, backed mysql. it's using row-level permissions model. i.e. have few columns (permission1, permission2, permission3) on table called projects , need check if user has details of permissions can access in session can see data queried projects table , filter out if don't. i on case case basis, i'm looking generic (i) works other tables might add permissions model later , (ii) if run projects.all somewhere , forget add appropriate clause don't accidentally show data user doesn't have permission view it. previously i've used modified jdbc driver in java webapp, don't know equivalent solution should rails + mysql. just discovered default_scope, should sufficient on per-model basis. that's close enough.

javascript - How to detect a keypress AND a mouseover at the same time -

okay can detect mouseover using .on('mouseover') and can detect keypresses using $(document).keypress(function(e) { console.log(e.which); } but how detect image mouse hovering on when press button? the idea able delete image pressing d while hovering on it. ideas ? you can toggle class or data-attribute shows 1 being hovered $('img').hover(function(){ $(this).toggleclass('active'); // if hovered has class active }); $(document).keypress(function(e) { if(e.which == 100){ $('.active').remove(); // if d pressed remove active image } }); fiddle

php - How do you intentionally cause a SoapFault for testing? -

i implemented soapclient interface handling rate requests federal express rate request web services. last night @ around 1 system returning soap fault conditions code handled it's response checking (it skips on , sends generic message if doesn't find valid rate response) isn't handled specifically. when service down, show more useful message customers such faults when remote services down perhaps cut down calls our tech support. (the generic message says 'try again later', if know it's problem fedex services being down, can 'fedex rate service temporarily unavailable' people know it's not our site, theirs) i've implemented code handle soapfault condition, have problem of 'how test it' fedex rate service down briefly last night. is there way intentionally trigger soap condition, perhaps specific soap fault testing purposes? i suggest using soapui mock service. can indicate response service return. point appliation mock...

bash - sh variable not working if blank -

need eyes one... dns_lookup() { ip_set if [ `ip_ping ${ip_address}` -eq 0 ] host="" dig +short -x ${ip_address} | sed 's/\.$//g' | while read host if [ -z "${host}" ] host="unknown" fi echo "${ip_address},${host}" done fi } i desired results if ip pingable , has dns name. not results if ip pingable not have dns name. ip_set() { ip_address="${a}.${b}.${c}.${d}" } ip_ping() { timeout ${delay} ping -q -c 1 -i 1 -w 1 -w 4 $1 > /dev/null 2>&1 ; echo $? } perhaps need. tell me if need revisions. dns_lookup() { ip_set if [ `ip_ping ${ip_address}` -eq 0 ] host="" dig +short -x ${ip_address} | sed 's/\.$//g' | { hashosts=false while read host ...

html - Vertically align stubborn paragraphs -

i have been trying 'about us' section vertically align paragraph below it. reason, when try resize viewing area or @ smaller screen, , on 2 different lines, , if keep making area smaller 'about us' drop down below , left of entire paragraph. my first question pondering how make 'about us' text stays on 1 line, rather folding in 2 or more lines. second how can make scalable without dropping 'about us' text below paragraph? attached code in jsfiddle. thanks guys!! http://jsfiddle.net/2l9qu/ here troubling html: <div class="maincontentcontainer"> <div class="maincontent1"> <h1> </h1> </div></div> here accompanying css: .maincontentcontainer { width: 85% } .maincontent1 h1 { font-family:verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; co...

silverlight : Checkbox checked/unchecked with another checkbox checked/unchecked -

i have few checkbox's (8 of them) 1 of enable/disable other 7 checkbox's. for have written as, isenabled="{binding elementname=controlchkenable, path=ischecked, mode=oneway}" ischecked="{binding elementname=controlchkenable, path=ischecked, mode=oneway}" in every dependent cb's. enable/disable working fine, if master checkbox unchecked, other checkbox's not getting unchecked , getting disabled. any idea went wrong? when checkbox disabled cannot change value. to in mvvm, have change values before disabled main checkbox : c# /// <summary> /// bind ischecked of "controlchkenable" element (twoway) /// , bind isenabled of each of other 7 checkbox's (oneway) /// </summary> public bool controlchkenable { { return _controlchkenable; } set { if (value == _controlchkenable) return; _controlchkenable = value; // before informing checkboxes disabled, // pass values ...

Open a new JavaFX window on a second monitor -

i trying open new window javafx application , set coordinates be inside application doing following: secondstage.setx(application.getprimarystage().getx() + application.getprimarystage().getwidth()/3); secondstage.sety(application.getprimarystage().gety() + application.getprimarystage().getheight()/3); it works fine when primary stage on first monitor. when on second monitor, new application opens right left border of second monitor, not inside app. if x coordinate gets rounded 0 respect second monitor when exceeds primary screen's x bounds. please let me know how can have same functionality/behavior on second monitor on primary 1 using same logic described code.

osx - dnsmasq & multiple addresses -

i'm using dnsmasq local development environment want use multiple tlds, dnsmasq.conf file looks this address=/.dev/127.0.0.1 & apache http-vhosts.conf looks this <virtualhost *:80> usecanonicalname off virtualdocumentroot "/users/<username>/sites/dev/%1" serveralias *.gabri logformat "%v %h %l %u %t \"%r\" %s %b" vcommon errorlog "/users/<username>/sites/dev/vhosts-error_log" </virtualhost> and configuration works, create new folder called 'client' example can access client.dev. now want add tld let's .test how can done? guess in apache it's same replacing dev test, dnsmasq? in dnsmasq.conf add: address=/.test/127.0.0.1 in http-vhosts.conf add: <virtualhost *:80> usecanonicalname off virtualdocumentroot "/users/<username>/sites/test/%1" serveralias *.test </virtualhost> create file "/etc/resolvers/test" content: n...

My current testcases are not working with new selenium 2.34.0 and php (edit added code and log file from selenium) -

i using selenium 2.34.0 + phpunit , cant recognize "code". using $this->url('blqblq') , error cant recognize command url. have same problem? when "revert" 2.33 tests working flawlessly :). phpunit version 3.7.21 , phpunit_selenium latest 1.3.1. thank you. "code" <?php //require_once 'setupfile.php'; class testtestest extends phpunit_extensions_selenium2testcase //extends setupfile { public function setup() { $this->setbrowser('firefox'); $this->setbrowserurl('http://www.stackoverflow.com'); } public function testexample() { $this->url('http://www.stackoverflow.com'); $this->assertequals('example www page', $this->title()); } } ?> my debug log file selenium 2.34.0 located here -> http://fikata.ivo.so/test234.txt edit 2 :) i went responce.php in phpunit_selenium...

Cassandra CQL3 Import CSV -

background: i have created schema called availabledomains (simple strategy, 1 node). in keyspace have created 1 table/ column family called domains columns (id, urn, timestamp, flag). of type text except timestamp type timestamp. i startup cassandra, launch cqlsh -3, use availabledomains, and issue following command pull in csv: copy domains (id, urn, timestamp, flag) 'test.csv' header= true; i error saying: improper copy command question: doing wrong? details: csv- id,url,timestamp,flag 1,google.com,1375891081,1 2,facebook.com,1375891081,1 3,youtube.com,1375891081,1 4,yahoo.com,1375891081,1 5,baidu.com,1375891081,1 6,wikipedia.org,1375891081,1 7,amazon.com,1375891081,1 8,qq.com,1375891081,1 9,live.com,1375891081,1 10,linkedin.com,1375891081,1 location of csv in cassandra/bin (same dir cqlsh located). os: centos 6.4 64bit this fixed me cql 3: copy domains 'test.csv' header = true ; the reason using header = true first line ...

asp.net - How css menu list can be genrated for a repeater with in repeater bounded by database? -

Image
i want menu list this even more beautiful currently have coded bind repeater database , fetch menu it <div id="main" class="shell"> <!-- sidebar --> <div id="sidebar"> <ul class="categories" id="categoryheader"> <li id="categoryitem"> <h4>categories</h4> <ul class="categories" id="categorylist"> <asp:repeater id="repcategories" runat="server" onitemdatabound="itembound"> <headertemplate> <ul> </headertemplate> <itemtemplate> <li> <asp:hyperlink id="hypercategories" runat="server"><%#eval("categoryname")%></asp:hyperlink> ...

c# - semi complex string replace? -

i have text 'random text', 'a\nb\\c\'d\\', 'ok' i want become 'random text', 'a\nb\c''d\', 'ok' the issue escaping. instead of escaping \ escape ' '' . 3rd party program can't change needing change 1 escaping method another. the issue \\' . if string replace become \'' rather \' . \n not newline actual text \n shouldn't modified. tried using regex couldn't think of way if ' replace '' else if \\ replace \ . doing in 2 step creates problem. how replace string properly? if understand question correctly, issue lies in replacing \\ \ , can cause another replacement if occurs right before ' . 1 technique replace intermediary string first you're sure not occur anywhere else, replace after you're done. var str = @"'random text', 'a\nb\\c\'d\\', 'ok'"; str.replace(@"\\", "non_occurri...

for loop - Java ":" operator in a For expression -

i ran across interesting use of ":" operator while writing unit tests else's code. looks this: for(class classinstance : instanceofotherclass){ //do irrelevant stuff } i have never seen ":" operator used without "?", when writing ternary statement. i've done fair amount of googling, , can't seem find sensible answers regarding how should read this... am over-complicating this? has seen before? for future reference, had typed: java 7 loop : into google, second result have helped you. defense, if don't put "7" there, have been more difficult find solution (not because introduced in java 7, in java 5, because if it's supported, putting 7 gives higher probability of finding up-to-date documentation). example of enhanced loop or for-each loop . in short: enhancedforstatement: for ( formalparameter : expression ) statement where expression must iterable or array type. in simpler te...

r - extracting from dataset based on value -

i bit of newbie in r. if have dataset , extract based on value in dataset: data<- read.csv(...) data name date id 1 2 3 4 if filter data based on value in date date = "05/31/2000". how do this? data[data$date == as.date("05/31/2000"),] , assuming data$date date .

c - gcc wont find sqrt even with -lm parameter -

this question has answer here: c math linker problems on ubuntu 11.10 5 answers why getting “undefined reference sqrt” error though include math.h header? 6 answers i using sqrt in .c file , including math.h this. when compiling -lm flag still prompts me "undefined reference `sqrt'" how supposed solved?

How to create reusable AngularJs directives that copy existing directives -

i in process of creating few reusable directives common controls in our application. for example have snip-it of html amount text boxes <div class='amount'> <input type='text' ng-model='dollars'/> </div> from there started create directive: app.directive("amount", function(){ return { restrict: "e", template: "<div class='amount'><input type='text'/></div>", replace: true } }); which renders following <html/> <div class="amount ng-pristine ng-valid" ng-model="dollars"> <input type="text"> </div> now ng-model on <div/> not want, need create scope , attach ngmodel , things happy again. app.directive("amount", function(){ return { restrict: "e", scope:{ ngmodel: "=" }, template: "...

jquery - jqgrid - populate dropdown values for filtering -

Image
i wish populate dropdown filters in jqgrid. as can see want action status populate values come other database table or other json. can 1 pls? i got working using filtertoolbar jqgrid .

ios - Managing multiple ViewConrollers -

i having view next buttons ( example) "new game" , "share friends" , want if user clicks on "new game" running "newgameviewcontroller",and when clicks "share" shareviewcontroller running. 've read docs on developer.apple (tabbar , navbar) didn't find solution newgameviewcontroller *ngvc = [[newgameviewcontroller alloc] initwithnibname:@"somenib" bundle:nil]; [self.navigationcontroller pushviewcontroller:ngvc animated:yes]; same thing in principle other one.

Symfony: one entity class with multiple instances each with its own form all on one page -

Image
use case: a user makes public and/or private notes expertise record. these notes displayed in sidebar of page shows expertise record. notes grouped 2 sets: current user's notes (both public , private) , public notes other users. current user's notes editable , deletable. each delete icon link route. each edit icon javascript toggle display form particular note (the edit form looks add form except it's populated). 1 note should added/edited or deleted per submit action. submission not through ajax. page looks this: problem how can display , process independent form both 'new note' , each of notes in 'my notes' section? if embed collection of notetype forms in expertisetype form, processing correct cannot seem group forms 'add note', 'my notes' , 'public notes' sections. , worse, public notes editable. i've abandoned approach since there not easy way filter notes have forms. if subset notes in controller , create f...

Cakephp habtm relation unable to correctly filter by tag -

i have habtm relation between users , tags. however, works such our list of tags maintained separately users. such there 12 tags , n users. new users added, tagged different tags , deleted, number of tags not change, records in taggings_users table increase accurately reflect everyone's tags. part works. additionally, there interface allows users filter tagged users tags. interface designed such if user a has tags monday , tuesday show in search either. additionally, if user b has tags monday , wednesday , search preformed search users include tag monday , exclude tag wednesday user b should not show (exclusions trump inclusions). cake able manage requiring included tags in search, , separately, cake able manage requiring tags excluded. trouble making cakephp "know" when user c has tags x , z , search preformed requested users including tag x , excluding tag z user c should not appear. presently user c appear in results. i realize result of join...

html - PHP Contact form, True/False in Email if CheckBox is Checked -

i have file called send_form_email.php , i'm trying send e-mail me trues/falses or way of signifying checkboxes checked. think there's wrong way i've tried expand found on internet - right sends form okay, not information items checked. these ones checkboxes on web form: $farmscale = $_post['farmscale']; // not required $nutrients = $_post['nutrients']; // not required $smallscale = $_post['smallscale']; // not required $plantdesign = $_post['plantdesign']; // not required $industrialscale = $_post['industrialscale']; // not required $engineering = $_post['engineering']; // not required $stgs = $_post['stgs']; // not required $compsupply = $_post['compsupply']; // not required but main file, , i'm not sure how true/fales value spit out in email sends. please gentle... still kinda new stuff. <?php if(isset($_post['email'])) { // edit 2 lines below required $ema...

Does the TCP connection created by requests persist when using Celery workers? -

i plan have celery workers sending notifications mobile devices (e.g. through gcm) , wish avoid opening needlessly many tcp connections i have celery task defined this: @task() def send_push_notification( requests.post(...) ) suppose task executed worker on single machine. each subprocess open 1 tcp connection? or new connection created each time task executed? if want reuse same tcp connection each subprocess, how go doing that? thanks!

javascript - Search an observable array using Knockout, Breeze, Durandal -

i have following observable array, gets data webapi using breeze when view activated (at activate() function on durandal) var prices = ko.observablearray(); the price class has 3 attributes: id, name , price. i have following array: var services = [{ active: true, name: 'service1', price: getprice('service1') }, { active: true, name: 'service2', price: getprice('service2') }]; what getprice(name) function should object has name passed parameter... i want able following on view: <div class="services"> <ul data-bind="foreach: services"> <li data-bind="visible: active, text: name + ' ($' + price.price + ')'"></li> </ul> </div> i've searched lot on stackoverflow , tried in many ways, haven't been able make work. i'm not sure if should use ko.utils.arrayfirst(), ko.computed(), or should do.. i've tried m...

cordova - asp.net web api file upload without saving -

ok, writing service recieve file uploads iphone application through phonegap. send me file , trying grab actual file without saving type of file system. have [httppost] public string processrequest() { string ext = "entered"; request.content.readasmultipartasync<multipartmemorystreamprovider>(new multipartmemorystreamprovider()).continuewith((tsk) => { ext = "request"; multipartmemorystreamprovider prvdr = tsk.result; foreach (httpcontent ctnt in prvdr.contents) { ext = "foreach"; // hold of inner memory stream here stream stream = ctnt.readasstreamasync().result; if (stream == null) { ext = "null stream"; } image img = image.fromstream(stream); if (imageformat.jpeg.equals(img.rawformat)) { ext = "jpeg"; } else if ...

c# - read text file chunks by chunks by scrollbar -

hi have read question : reading large text files, should incorporating async? i diged net stack overflow ! the results 14 method none of them not complete ! in 2 last days , working on , tested , benchmarked 14 methods. for example : private void method() { filestream fs = new filestream(path, filemode.open, fileaccess.readwrite); int fsbytes = (int) fs.length; int chunksize = 24; byte[] b = new byte[chunksize]; int pos; (pos = 0; pos < (fsbytes - chunksize); pos += chunksize) { fs.read(b,0 , chunksize); string content = system.text.encoding.default.getstring(b); richtextbox1.text=content=; } b = new byte[fsbytes - pos]; fs.read(b,0, fsbytes - pos); string content2 = system.text.encoding.default.getstring(b); richtextbox1text=content2; fs.close(); fs.dispose(); } for 5mb text file , takes lo...

c# - SelectedIndex with OneWayToSource binding does not trigger -

Image
i have problem particular xaml databinding. have 2 listboxes (master-details, listboxes have issynchronizedwithcurrentitem set true). want viewmodel know when selected item on details listbox changes: created int property on viewmodel class (i.e. can call property selind)and on details viewmodel bind way: selectedindex="{binding mode=onewaytosource, path=selind}" i no errors/exceptions @ runtime, binding not trigger: viewmodel's property not updated when selected item changes. if change binding mode twoway works fine, that's not need. need work onewaytosource (btw same non-working behaviour applies if bind selecteditem selectedvalue properties). why bindings not trigger onewaytosource? here's more complete code example, things clearer: edit: can't show real code (nda) i'll show here simpler , similar enough (the page's datacontext instance of pageviewmodel class explained later) need viewmodel class's selind property should refle...

python - pexpect parse a string -

i have expected string "version 0.0.9999.0" i spawn correctly e.expect('version 0.0.9999.0') and works fine, however, want make dynamic accept version (any 4 numbers separated dots). possible or have specific string? if yes, how? thanks. the method using expects pattern , not fixed string, per the documentation : expect(self, pattern, timeout=-1, searchwindowsize=none) this seeks through stream until pattern matched. pattern overloaded , may take several types. pattern can stringtype, eof, compiled re, or list of of types. strings compiled re types. from say, regular expression "version \d.\d.\d{4}.\d", depends on possible values version. fixed strings there expect_exact.

java - Close connection and statement finally -

which better block: finally { try { con.close(); stat.close(); } catch (sqlexception sqlee) { sqlee.printstacktrace(); } } or: finally { try { if (con != null) { con.close(); } if (stat != null) { stat.close(); } } catch (sqlexception sqlee) { sqlee.printstacktrace(); } } better way use 2nd one, because if exception thrown while initializing con or stat , won't initialized, , might left initialized null . in case, using 1st code throw nullpointerexception . also, if on java 7 , should consider using try-with-resources , automatically closes resources. linked tutorial: the try-with-resources statement ensures each resource closed @ end of statement. object implements java.lang.autocloseable, includes objects implement java.io.closeable, can used resource.

jquery - JqueryGrid plugin getting selected row id -

i using jquerygrid plugin. want implement easy edit function. user click jquery grid column edit button. redirect edit view. want that. must selected column's id value. code shown below: <script type="text/javascript"> jquery(document).ready(function () { $('#list').width(200); jquery("#list").jqgrid({ url: '/credential/jquerygriddata/', datatype: 'json', mtype: 'get', colnames: ['id', 'sıra', 'resim', 'İsim', 'başlık', 'açıklama', 'boyut', 'oluşturulma tarihi', 'güncellenme tarihi'], colmodel: [ { name: 'id', index: 'id', width: 10, align: 'left' }, { name: 'order', index: 'order', width: 10, align: 'center' }, { name: 'image', index: 'image', width: 50, he...