Posts

Showing posts from April, 2013

java - How to Autowire Bean of generic type <T> in Spring? -

i have bean item<t> required autowired in @configuration class. @configuration public class appconfig { @bean public item<string> stringitem() { return new stringitem(); } @bean public item<integer> integeritem() { return new integeritem(); } } but when try @autowire item<string> , following exception. "no qualifying bean of type [item] defined: expected single matching bean found 2: stringitem, integeritem" how should autowire generic type item<t> in spring? simple solution upgrade spring 4.0 automatically consider generics form of @qualifier , below: @autowired private item<string> stritem; // injects stringitem bean @autowired private item<integer> intitem; // injects integeritem bean infact, can autowire nested generics when injecting list, below: // inject item beans long have <integer> generic // item<string> beans not appear in list @autowire...

c# - Parsing emails and attachments -

i have requirement parse email messages , upload email db based on filters. have experience writing outlook add-in , possible in client side. but here think need write plugin in exchange server , parse email messages there itself. assumption right? if please point me tutorial writing exchange server plugins. you use mimekit library parse messages.

java - Problems with NativeDecodeByteArray in Android Bitmap.class -

i decoding base 64 encoded images on android(java). works of images, of image binaries returns null. if use online decoder, binary in question works fine, tells me format correct. the piece of code on base64.class file messes if (!decoder.process(input, offset, len, true)) { throw new illegalargumentexception("bad base-64"); } // maybe got lucky , allocated enough output space. if (decoder.op == decoder.output.length) { return decoder.output; } // need shorten array, allocate new 1 of // right size , copy. byte[] temp = new byte[decoder.op]; system.arraycopy(decoder.output, 0, temp, 0, decoder.op); return temp; for images fail, goes through the maybe got lucky check, , returns decoder.output , directly jumps return temp, inturn returns null . images work not enter if , returns non null temp variable. there known issue this? update invoking code //this decodedstring null byte[] decodedstring = base64.decode( data...

c# - Match all words from given string where words does not have only lower case letters or only upper case letters -

i retrieve words given string not caps , lower or first letter upper for example in below sentence should extracted except first 4 words: a abcd hello ajp string str = "a abcd hello ajp lbl_description mhz assignexistinguseroptiontext _bthaudclassdrv_keyword a_dd actelismetaloop audenginestream_beginstreamswitch_enter audenginestream_begineos bo_th btnchange c_hange cds check_and_change_access_masks checkbox1 cimobjectpath ciscoislvlan comboemailaccounts d_elete csvfs_refs d_hcp dadornudreply decnet ipv4 kj kpa lalt ml n_o tabpage11 uapsd vlans ycbcr" you can using split method , linq: var result = str.split(new[] {' '}, stringsplitoptions.removeemptyentries) .where(x => !x.all(char.isupper) && !x.all(char.islower) && !(char.isupper(x[0]) && x.skip(1).all(char.islower))) .toarray();

visual studio - In which version of Windows did each VC++ re-distributable become standard? -

my understanding vc++ redists updates core windows files, , on time ms "catches up" incorporating past versions new versions/updates windows. instance i'd expect built vc++ 2005 wouldn't need me install redist on target pcs these days. can provide definitive reference versions of windows include vc++ redist versions? also, redist approach ms still employ in newest versions of vc++ e.g. 2012 , later? none of files distributed modern versions of visual studio updates files ship windows. windows ship c runtime, used internally , (for reasons of backwards compatibility) applications built visual studio 6 or earlier versions. later versions of visual studio each have own runtime, none of shipped windows.

jquery - jQueryMobile horizontal align grid-elements -

i have jquery mobile grid system 5 cells. i'd have content of these cells aligned middle of cells. i tried add: <div style="vertical-align:middle;">text</div> but didn't work. also: <div style="top:50%;">text</div> didn't work. i created fiddle check out. ideas i'm doing wrong? display blocks table display: table; , wrap contents inside each block in p . <div class="ui-grid-d grids"> <div class="ui-block-a"> <p>a</p> </div> <div class="ui-block-b"> <p>b</p> </div> <div class="ui-block-c"> <p>c</p> </div> <div class="ui-block-d"> <p>d</p> </div> <div class="ui-block-e"> <p><a data-role="button" class="ui-link ui-btn ui-shadow ui-corner-all" role="button...

How to convert a python regexp to java -

i need convert following python regexp java regexp: regexp = re.compile(r"^(?p<prefix>(%s)(%s)?)\s?\b(?p<name>.+)" % ("|".join(array1), "|".join(array2)), re.ignorecase | re.unicode) where array1 , 2 arrays of strings. what did is: string regexp = string.format("^(?<prefix>(%s)(%s)?)\\s?\\b(?<name>.+)", array1, array2); regexppattern = pattern.compile(regexp, pattern.case_insensitive); but patternsyntaxexception: "unknown look-behind group near" in question mark of (%s)(%s) ? i don't understand question mark. any suggestion on how translate java 1.6? tons of things go wrong you. the (?< positive look-behind expression in java. (?p<prefix> named group in python, there no named groups in java. string.format %s , array not produce | joined st...

xml - Creating dynamic bookmarks -

i have xml chapters can @ level in xml: <?xml> <chapter> <long-name>chapter 1</long-name> <!-- 1--> <chapter> <long-name>chapter a</long-name> <!-- 1.1 --> <chapter> <long-name>chapter b</long-name> <!-- 1.1.1 --> </chapter> </chapter> <chapter> <long-name>chapter c</long-name> <!-- 1.2--> </chapter> </chapter> <chapter> <long-name>chapter 2</long-name> <!-- 2 --> <chapter> <long-name>chapter d</long-name> <!-- 2.1--> </chapter> <chapter> <long-name>chapter e</long-name> <!-- 2.2--> </chapter> </chapter> </xml> 1. chapter 1 1.1 chapter 1.1.1 chapter b 1.2 chapter c 2.chapter 2 2.1 chapter d 2.2 chapter e ...

c# - How to validate password and redirect admin to admin page and user to user page using roles? -

this code: protected void loginbtn_click(object sender, eventargs e) { if (ispostback) { sqlconnection conn = new sqlconnection(configurationmanager.connectionstrings["userdatabaseconnectionstring1"].connectionstring); conn.open(); dataset ds = new dataset(); sqlcommand cmd = new sqlcommand("select role accounts", conn); sqldataadapter da = new sqldataadapter(); cmd.commandtype = commandtype.text; da.selectcommand = cmd; da.fill(ds); if (ds.tables[0].rows.count > 0) { string role = convert.tostring(ds.tables[0].rows[0]["role"]); if (role == "a") { response.redirect("adminpage/adminaccount.aspx"); } if (role == "u") { response.redirect("userpage/useraccount.aspx"); } } else { ...

crosstab - R table (xtab?) -

my data in below format: out reg. task date task state name task state time a6ere 01-03-2014 manual 23:09:48 a6ere 01-03-2014 manual 23:10:05 a6ere 01-03-2014 assign 23:24:44 a6ere 01-03-2014 confrm 23:25:15 a6ere 01-03-2014 arr 23:45:07 a6ere 01-03-2014 started 00:20:00 a6ere 01-03-2014 finish 00:39:00 a6eed 01-03-2014 free 22:42:28 a6eed 01-03-2014 manual 23:37:37 a6eed 01-03-2014 assign 23:37:41 a6eed 01-03-2014 confrm 23:37:58 a6eed 01-03-2014 arr 00:34:26 a6eed 01-03-2014 started 01:04:00 i want summarize below: out reg.task date arr assign confrm finish free manual started a6ere 01-03-2014 23:45:07 23:24:44 23:25:15 00:39:00 23:10:05 00:20:00 a6eed 01-03-2014 00:34:26 23:37:41 23:37:58 01:41:00 22:42:28 23:37:37 01:04:00 i used pivot in excel , dcast in r ( creating pivot table ). both output count of timestamps instead o...

osx - Is it possible to get // to work locally? -

i lot of small-scale front-end projects don't want spend time setting dev enviroments. when develop locally, write html , open files in browser. works fine. @ times wish use // instead of protocol when referencing file, like: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> this cause work both http , https , if protocol file:// won't work. there way solve this? prefer not having run local server , setting domains each project.

php - 5.3.3-7+squeeze18 and Zend Framework 2 not working -

issue zend fw2 requirements 5.3.3 php interpreter version, while trying installed composer generates error: your requirements not resolved installable set of packages. problem 1 - zendframework/zendframework 2.3.0 requires php >=5.3.23 -> no matching package found. - zendframework/zendframework 2.3.0 requires php >=5.3.23 -> no matching package found. - installation request zendframework/zendframework 2.3.* -> satisfiable zendframework/zendframework[2.3.0]. potential causes: - typo in package name - package not available in stable-enough version according minimum-stability setting see https://groups.google.com/d/topic/composer-dev/_g3aseiflrc/discussion more details. read http://getcomposer.org/doc/articles/troubleshooting.md further common problems. what solution, except php version update(not suitable, because on server have project not run after update). thank time , help! the solution have ...

solr does not search with dot character -

i have problem dot searching in solr. example. have product code like: 01.023.0001 01.234.0012 and solr not return result. what's wrong schema ?. here field: <fieldtype name="text_general" class="solr.textfield" positionincrementgap="100"> <analyzer type="index"> <tokenizer class="solr.whitespacetokenizerfactory"/> <filter class="solr.worddelimiterfilterfactory" generatewordparts="1" generatenumberparts="1" catenatewords="1" catenatenumbers="1" catenateall="0" splitoncasechange="1" splitonnumerics="1" preserveoriginal="1" /> <filter class="solr.morfologikfilterfactory" dictionary="morfologik"/> <filter class="solr.stopfilterfactory" ignorecase="true" words="stopwords.txt" /> <filter class="solr.sh...

Error list plot with Errors on both variables in Mathematica -

i analysing data in mathematica lab report , having trouble finding way plot error bars (uncertainties) on both vertical , horizontal axes. have imported errorbarplots function it. have data arranged like: {{{x data point 1, errorbar[x error 1]},{y data point 1, errorbar[y error 1]}}, {{x data point 2, errorbar[x error 2]},{y data point 2, errorbar[y error 2]}}, etc.} i can call element of 3d array using data[[1,1,1]] etc, whenever try use errorlistplot function won't it. have used function before plot errors on x-axis, yet successful when plotting both. any tips? possible in mathematica? can't seem find useful elsewhere on net.

how can i rewrite url with this char ~ -

i want rewrite simple url that test.com/test.php?code=12345 to test.com/12345 when user enter link go shortened link , when user enter character ~ in last of url show link info that test.com/12345~ can 1 me writing code using .htaccess ? i want make bit.ly when write shortened it's go url when add + end of url in bit.ly gives info of shortened link

objective c - UISegmentedControll not setting correct image -

Image
i'm trying set custom image each segment control index in uisegmentedcontroll i setting image so: uiimage *selectall = [uiimage imagenamed:@"select active"]; [selectall imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; [self.segmentedcontrol setimage:selectall forsegmentatindex:0]; however white space in segment index , image doesn't show correctly. is there different way this? i building app ios7 only. edit here looks image set in ib or code: sounds image not exists, sure named 'select active.png'? suggest rename test.png first see if works.

why use http.route() method use type="json" in openerp -

above code website_mail module controller file email_designer.py file class websiteemaildesigner(http.controller): @http.route('/website_mail/email_designer/<model("email.template"):template>/', type='http', auth="user", website=true, multilang=true) def index(self, template, **kw): values = { 'template': template, } return request.website.render("website_mail.designer_index", values) @http.route(['/website_mail/snippets'], type='json', auth="user", website=true) def snippets(self): return request.website._render('website_mail.email_designer_snippets') which situation using type="json" , type="http" , why..?? both of them communication between client , server. httprequest communicates trough known , post methods. means following: the client send request encoded in url (get method) or in http body (post method) the server ...

c# - How to read an xml and write it back when you understand only part of its structuer -

i have xml may contains several types of nodes, interested in specific node types. want change nodes interested in , save result, when other nodes should unchanged. for example xml follow: <?xml version="1.0" encoding="utf-8"?> <unknown> ... <unknown/> <companyname> <attrcontainer> <attr type="string"> <name value="'name'" /> <value value="'attrcontainer'" /> </attr> <unknown> ... <unknown/> <subcontainer> <attrcontainer value="'wssmetadata'" /> <attrcontainer> <attr type="string"> <name value="'name'" /> <value value="'attrcontain...

joomla - Format (to currency) php syntax in K2 STORE -

i customizing k2 store front end , need currency formatting. my code is: <span>tax: <?php echo $item->tax ?></span> <span>price without tax: <?php echo $item->price; ?></span> don't know why code outputs: tax: 11 price without tax: 50.00000 i output: tax: 11,00 eur price without tax: 50,00 eur i found hints formatting values in php not able implement in case. have poor php knowledge. how using php's money_format function? in case similar so post seems have answer setlocale(lc_monetary, 'nl_nl.utf-8'); $amount = money_format('%(#1n', $amount); echo $amount; you put function like function to_euro($input){ setlocale(lc_monetary, 'nl_nl.utf-8'); return money_format('%(#1n', $input); } then use like echo to_euro($item->tax);

python - ladon throwing an AttributeError -

i'm trying ladon working, however, don't seem able define service properly. specifically, minimal test case, it's throwing traceback (most recent call last): file "c:\python33\lib\site-packages\ladon\server\wsgi_application.py", line 332, in __call__ self.import_services(self.service_list) file "c:\python33\lib\site-packages\ladon\server\wsgi_application.py", line 288, in import_services __import__(service) file "d:\workspaces\python\soapmanager.py", line 20, in <module> @ladonize(portable_string, portable_string, rtype=portable_string) file "c:\python33\lib\site-packages\ladon\ladonizer\decorator.py", line 118, in decorator injector.__doc__ = ladon_method_info._doc attributeerror: 'nonetype' object has no attribute '_doc' my run.py contains: from ladon.server.wsgi import ladonwsgiapplication os.path import abspath, dirname wsgiref.simple_server import make_server application...

sql server - SQL to calculate number of tasks open at a given time -

i have nice query calculates how many tasks have been opened , closed in given week works charm, i'm having difficulties extending can show me how many tasks we're still open @ end of week. in mind, sql need count total number of issues have been opened beginning of time, week , same number of closed , subtract 2 each other limited knowledge of sql, i'm struggling how write falls outside of group clause. this sql have: select isnull(a.[year],b.[year]) [year], isnull(a.[week],b.[week]) [week], isnull(a.opened,0) opened, isnull(b.closed,0) closed, a.totresponse, a.totcompletion ( select year(insert_time) [year], datepart(week,insert_time) [week], count(id) opened, sum(timer2) totresponse, sum(timer3) totcompletion service_req [insert_time] not null , sr_type=1 group year(insert_time), datepart(week,insert_time)) full join ( select year(close_time) [year], datepart...

iphone - unknown argument: '-stdc++' [-Wunused-command-line-argument-hard-error-in-future] during build in XCODE 5.1 -

i error when build project in xcode 5.1. followed link , downloaded new command line tools apple.but facing same issue. please guide me. thanks have 3 steps u should fix it: - remove -stdc++ in other linker flags - add -lstdc++ other linker flags - add libstdc++6.09.dylib link binary libraries. good luck.

Identify IDE by seeing the application in smalltalk -

how identify smalltalk ide/implementation used seeing desktop application developed in smalltalk? the icons , lines in shown widget point towards visualage smalltalk ibm, nowadays va smalltalk instantiations. program generated replacement window icon, cannot tell window, container icon tree displayed here makes me 100% sure visualage. do happen have access runtime directory on windows computer? if so, there program called abt.exe or nodialog.exe? or better: there 1 or more of these subdirectories in runtime directory: \bin \nls \bmp? if so: va.

c# - How to await a byte[] -

i have mvc 4 app. 1 of things send email calling service using webclient so: var serializer = new javascriptserializer(); string requestdata = serializer.serialize(new { eventid = 1, subscriberid = studentid, tolist = loginmodel.emailaddress, templateparamvals = strstudentdetails, }); using (var client = new webclient()) { client.headers[httprequestheader.contenttype] = "application/json"; var result = await client.uploaddata(uri, encoding.utf8.getbytes(requestdata)); } i wanted make use of uploaddataasync got error: an asynchronous operation cannot started @ time. asynchronous operations may started within asynchronous handler or module or during events in page lifecycle. so thought of creating wrapper function & making asynchronous while still using uploaddataasync . private async task<bool> sendemailasync(long studentid, loginmodel loginmodel) { try { string uri = configurationmanager.appsettings["...

asp.net - Convert VB code after framework update -

the framework has been updated on computer , i've updated visual studio 2008 2010, there part of code won't work. public property itemcount() integer dim val object = viewstate("itemcount") return if(val isnot nothing, cint(val), 0) end set(byval value integer) viewstate("itemcount") = value end set end property the "return if(val isnot nothing, cint(val), 0)" part of code not work error: description: error occurred during compilation of resource required service request. please review following specific error details , modify source code appropriately. compiler error message: bc30201: expression expected. source error: line 21: line 22: dim val object = viewstate("itemcount") line 23: return if(val isnot nothing, cint(val), 0) line 24: end line 25: set(byval value integer is there converter can use b...

php - mysql_select_db() expects parameter 2 to be resource -

i making photo gallery part of learning php. directory structure looks this: includes logs public within includes directory have following files: config.php database.php functions.php inside files: config.php : // setup mysql database connection <?php defined('db_server') ? null : define("db_server", "localhost"); // db server (usually localhost) defined('db_user') ? null : define("db_user", "root"); // db user defined('db_pass') ? null : define("db_pass", "usbw"); // db pass defined('db_name') ? null : define("db_name", "photo_gallery"); // db name ?> database.php : <?php require_once("config.php"); class mysqldatabase { private $connection; function __construct() { $this->open_connection(); } public function open_connection() { $this->connection = mysqli_connect(db_server, db_user, db_pass...

oracle - Type table null value check -

i have type of following in plsql block type table_type table of varchar2(200); v_tab_1 table_type; values initialized if (prod_amnt > inv_amnt) v_tab_1 := table_type(prod_amnt, 'curr'); ...... sometimes above condition not true , there null values in v_tab_1 what best approach check values exist in v_tab_1 ? i have tried if not(v_tab_1.exists(v_tab_1.first)) however above resulted in no_data_found exception how deal this? force single error value table type? , check value. if (prod_amnt > inv_amnt) v_tab_1 := table_type(prod_amnt, 'curr'); else v_tab_1 := table_type(0, 'err'); end if;

Android: Alert dialog throws exception inside socket thread -

i having following android code, where-in android app contacts socket program , result "success" in thread model. after that, trying show alert dialog, android program gets exception thread exiting uncaught exception couldn't what's wrong here. can't show alert inside thread? please advise. public class randomidactivity extends activity { ............. clientthread = new clientthread(); button connectbtn = (button) findviewbyid(r.id.button2); connectbtn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub thread t = new thread(new clientthread()); t.start(); } }); } class clientthread implements runnable { @override public void run() { // got ip servlet , stored temporarily, retr...

php - Member's Title and Description -

i have made advertising website allows people sign , display details , descriptions of job. question is, have make page each member’s description separately? ask because if receive thousands of members time-consuming , difficult make each page separately. take on php , mysql. can create dynamic pages php , store info in mysql. php serverside language, , run on server, sourcecode won't sent client.

jquery - How to update compatibility mode settings at runtime -

one of custom datatable view needs ie 8 standard view render on web browser, have <meta http-equiv="x-ua-compatible" content="ie=7; ie=8" /> insert piece of code in site.master make work. but override whole site compatibility settings. there way insert in application head section @ run time & on launching control add meta tag html page.

How to get a number of Google Plus +1 for a URL of post -

i want number of google+ +1 url of article post. for example want number of g+ of beautydea magazine. there way add url post specific url of google api? such facebook or twitter. here examples of facebook , twitter same url post. facebook: https://graph.facebook.com/fql?q=select%20total_count%20from%20link_stat%20where%20url=%27http://www.beautydea.it/orly-baked-collezione-smalti-estate-2014/%27 twitter: http://urls.api.twitter.com/1/urls/count.json?url=http://www.beautydea.it/orly-baked-collezione-smalti-estate-2014/ well if doing on server side, load url referred iframe of button https://apis.google.com/u/0/_/+1/fastbutton?usegapi=1&url=http%3a%2f%2fwww.beautydea.it%2forly-baked-collezione-smalti-estate-2014%2f and read count div id "aggregatecount". you're out of luck on client-side approach, since can't load external html page.

html - Browser support for @import -

whenever use css property check browser support @ www.caniuse.com , nice website though haven't included opera mini 8 yet, still nice website. now project have multiple css files using conditionally, must use @import rule, don't know browser support, checked @ www.caniuse.com not there, googled it, every website , blog discussing support @media rule, not @import, discuss either @import better or minifying css using grunt etc better. can tell me browser support @import, , can use or not ? of course can use @import. asked why not discussed @ different webdesign blogs etc, think reason because supported there no need discuss support anymore. ie 4.x has support @import rule, later versions (even ie 5 considered older browser , nobody use anymore) have support @import rule. so go , use being fearless, said in question, of course there better ways grunt if you're using node.js.

c# - Implementing IEnumerator/ IEnumerable with IDispose error -

i've been trying build in ienumorator allow use foreach statement insert large number of rows extracted json formatted string these nested objects. applines class consists exclusively of string get/set statements. for reason i'm getting 3 errors pointing class header. can't understand a) why , how need implement idisposable b) why dose compiler disagree return types. 'appannieimport' not implement interface member 'system.collections.ienumerable.getenumerator()'. 'appannieimport.getenumerator()' cannot implement 'system.collections.ienumerable.getenumerator()' because not have matching return type of 'system.collections.ienumerator'. 'appannieimport' not implement interface member 'system.idisposable.dispose()' 'appannieimport' not implement interface member 'system.collections.generic.ienumerator.current'. 'appannieimport.current' cannot implement 'system.collection...

c# - Conversion of date time in jQuery -

i have ajax request date time database. example, date time 3/24/2014 10:15:35 am , , want show date time razor view page . code :: view code :: $.ajax({ url: "/home/checklatestticket", type: "post", success: function (data) { var date = date(data); $("#latestticket").html("<p style='font-size: 15px;'>" + date + "</p>"); } }); controller ajax request: public actionresult checklatestticket() { datetime result = (from t in db.imsticket t.viewticketclient == 0 && t.organizationid == 1 orderby t.createticket descending select t.createticket ).firstordefault(); return json(result); } using code current date time following format:: this actual result ajax request /date(1395634535793)/ this result, showed in page: (which current date time) mon mar 24 2014 17:50:26 gmt+0600 (bangladesh sta...

python - in NetworkX draw the graph dividing the plot area in 3 -

Image
i have graph in networkx different info inside. graph nodes this: g = nx.digraph() g.add_node(shape1, level=1) g.add_node(shape2, level=2) g.add_node(shape3, level=2) g.add_node(shape4, level=3) ... i want draw graph in order have shapes @ level 1 @ top of plot, shapes in level 3 positioned in lower part of plot , shapes @ level 2 in middle. there maximum 3 levels. i have been reading documentations networkx, till used random positioning of nodes: pos = nx.spring_layout(g) nx.draw(g, pos) . do know smarter way position nodes of graph want? p.s.: desired output this: i don't need draw lines dividing levels, put them make clear need. the layout "dot" provided interface graphviz seems looking for. while works simple graph you've provided, may need tweak output larger more complicated graphs. import networkx nx g = nx.digraph() g.add_node(1,level=1) g.add_node(2,level=2) g.add_node(3,level=2) g.add_node(4,level=3) g.add_edge(1,2) g.add_edg...

javascript - Making the HTML code shown via Ajax appear without snapping to the beginning of the site -

first of all, hope question above clear. didn't know how formulate otherwise, i'll try explain little more. i'm using magnific popup on customizable site has sick timeline using perfect slider. added hrefs portions of text , mp works fine. it's html code appears snaps beginning of site , therefor, navigation bar @ top kinda on popup. wanted know if can make popup appear right originates, aka link clickable make appear, without snapping top. i hope made myself clear, :) edit : forgot code, how typical of me. here url site, i'm still trying stuff out on it. click here go site try clicking on text in timeline has background it, , you'll see mean. here's javascript initializing action <script type="text/javascript"> $(document).ready(function() { $('.simple-ajax-popup-align-top').magnificpopup({ type: 'ajax', overflowy: 'scroll' // know popup content tall set scroll overflow default avoi...

java - invalidate refreshed entry in Guava CacheLoader -

i have guava cache cacheloader . there external condition track in thread, , if happens want refresh() entries asynchronously. reason not use invalidateall() since next get() have wait load succeed. instead iterate on keys contained in cache , refresh(k) of them, not find refreshall() method. here code (but not related question): set<resourceloaderkey> keys = resourceloadercache.asmap().keyset(); for(resourceloaderkey k : keys) { resourceloadercache.refresh(k); } my problem now, reload() in cacheloader might detect, resource not longer available. reload() throws resourcenotfound exception works get() case. not work refresh() case, old value served long reload() fails. i can trap not-found exception in load/reload methods , invalidate entry somehow, wonder if there official way (returning null or null future logged warning , ignored)? able remove key/absent-value instead of keeping placeholder object around. a supported way doe...

perl - (Bash) Evaluate text between tokens with command output in the file -

i have text file, example text text <%any_command "$(another_command)" parameter %> text text text * text <%any_command "$(another_command)" parameter %> text text i need evaluata text inside <% %> , replace it(including these tokens result that) result of evaluation. how e done using akw or sed or perl? i've tried use sed without success: sed "s/<%\(.*\)%>/$(eval \1)/g" -bash: 1: command not found update: two additional requirements 1) several commands replace on same line: text * text <%any_command "$(another_command)" parameter %> text<%any_command "$(another_command)" parameter %>text 2) function placed inside <%%> tags, example have any.sh file following content: #/bin/bash function any_function { echo $1 } and line processed: text * text <% any_function 1 %> text text don't believe possible single sed command. stor...

mfc - Messagebox in CMainFrame OnCreate -

i have old mfc application oncreate function spans upwards of 200 lines. cmainframe::oncreate(lpcreatestruct lpcreatestruct) { ... postmessage(load_images,0,0); ... validatepermissions(); ... } the load_images user message handler tries load images had been unsaved last session.. tries create new cdocument... the validatepermissions function pops modal messagebox if finds permissions missing.. i notice if have modal message box pop up, crash when load_images handler fires (since cannot create cdocument, think because cmainframe has not yet created). how should handling such case. there documentation suggests not have modal messageboxes in oncreate? try moving call validatepermissions message handler load_images. should let window creating complete before let message box pump messages.

c++ - Derive class A from a template class Base<A> so that Base<A> can use A::B? -

template <typename t> class base { private: typename t::b c; }; class : public base<a> { public: class b; }; is possible? vc++ 2013 says b not member of a. i go ( live example ): template<typename t> struct impl; template<typename t> struct nested; template <typename t> class base { private: typename nested<t>::type c; }; struct a; template<> struct impl<a> { class b { }; }; template<> struct nested<a> { using type = typename impl<a>::b; }; struct : base<a>, impl<a> { //... }; here, class impl contains part of a not depend on base , is, nested class b . hence a derives both base<a> , impl<a> . class nested contains alias specifying type of above nested class. base reads type nested , defines data member, of type. we need declare a before specialize impl , nested it. , need specializations before defining a because @ point base<a> inst...

jquery - Slide up and slide down div, while not doing multiple ajax request -

i have div can expand, down , up. when expand div, ajax-request made. problem that, when want hide div, ajax-request called again. have tried solve problem variable expanded: var expanded; $('body').on('click', '#responds .expand_button', function(e) { e.preventdefault(); var clickedid = this.id.split("-") var dbnumberid = clickedid[1]; //get number array var mydata = dbnumberid; if(expanded != 1) { $.ajax({ type: 'post', url: 'process.php', datatype: 'html', data: {recordtoexpand: mydata}, success: function(response) { $('#fish_'+dbnumberid).slidetoggle("slow").append(response); expanded = 1; }, error: function(xhr, ajaxoptions, thrownerror) { alert(thrownerror); } }); } if(expanded == 1) { $('#fish:visible').slideup(); expanded = 0; } }); but don't wor...

c# - Unhandled exception while doing SqlBulkCopy -

i have configured console application in task scheduler. the console application uses sqlbulkcopy insert data sql table reading same csv file. the problem job randomly throws exception not able catch using try catch. however gets logged event viewer as: application: applicationname.exe framework version: v4.0.30319 description: process terminated due unhandled exception. exception info: system.data.entity.infrastructure.dbupdateexception stack: @ system.data.entity.internal.internalcontext.savechanges() @ system.data.entity.internal.lazyinternalcontext.savechanges() @ system.data.entity.dbcontext.savechanges() @ sdo.repository.repository`1[[system.__canon, mscorlib, version=4.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089]].savechanges() @ sdo.business.solutiondb.solverprocess.processconsoleoutput(system.object, system.diagnostics.datareceivedeventargs) @ system.diagnostics.process.outputreadnotifyuser(system.string) @ system.diagnostics.async...

restrict the windows phone app for specific devices -

i want application should work on specific devices\os "lumia 650"\"windows phone 8", project requirement. is possible ? if yes should mention details ? it not problem restrict windows phone 8. need build targeting windows phone os 8.0. device model in app.xaml.cs private void application_launching(object sender, launchingeventargs e) { var devicename = deviceextendedproperties.getvalue("devicename").tostring(); if (!devicename.contains("lumia_650")) // please check phone's actual value application.current.terminate(); } if want show friendly message before exits can move code mainpage.xaml.cs add messagebox.show(message) part.

c++ - Open and show windows command prompt to user inside QT application -

how go opening windows command prompt sending command , showing user inside qt application? i know can send commands command prompt , output "behind scenes" without showing command prompt user, want user able interact command prompt window , send own commands. found needed: qprocess commandprompt; qstringlist arguments; arguments << "/k" << "echo" << "hello"; commandprompt.startdetached("cmd",arguments);

jquery - What is the correct way to select unique values for a single attribute out of a Javascript array of objects -

suppose have following javascript array of objects: var odata = [ {field1 : "root", field2: "qqqqq", field3: "aaaaa", field4: "zzzzz"}, {field1 : "root", field2: "qqqqq", field3: "aaaaa", field4: "xxxxx"}, {field1 : "root", field2: "qqqqq", field3: "sssss", field4: "ccccc"}, {field1 : "root", field2: "wwwww", field3: "sssss", field4: "vvvvv"}, {field1 : "root", field2: "wwwww", field3: "ddddd", field4: "bbbbb"}, {field1 : "root", field2: "wwwww", field3: "ddddd", field4: "nnnnn"}, {field1 : "root", field2: "wwwww", field3: "fffff", field4: "mmmmm"} ]; what best performing way copy single attribute ( field1 , field2 , field3 , etc.) of array new array, and this resulting a...

mongodb - Sharding is not happening for the second Shard -

i have setup sharding 2 nodes (two different hosts). have 650 mb table. have chosen year sharding key. data has years 2010 2014. have configured chunk size default (which 64 mb). result of db.collection.stats mongos> db.ctest.stats(1024 * 1024) { "sharded" : true, "ns" : "dbtest.ctest", "count" : 244000, "numextents" : 10, "size" : 93, "storagesize" : 123, "totalindexsize" : 7, "indexsizes" : { "_id_" : 7 }, "avgobjsize" : 0.0003811475409836066, "nindexes" : 1, "nchunks" : 1, "shards" : { "shard0001" : { "ns" : "dbtest.ctest", "count" : 244000, "size" : 93, "avgobjsize" ...

algorithm - Springs and Hooks -

Image
okay, i dealing problem, can't seem solve. little ? problem: given wooden line of length m has n hooks , positions of these hooks given array ( 0 < p < m ). there spring attached each hook , each spring has metal ball @ other end. balls of same radius, r , same mass m. springs have same stiffness coefficient. how find optimum position of balls such springs , system in equilibrium ? metal balls not allowed go before or after line. i.e ends of balls cannot < 0 or > m. possible have multiple hooks @ same position in array. assumptions : given array valid. you can ignore vertical stretch , consider stretch of spring in horizontal directions. problem can seen 1d in nature then. limits: o(nlogn) solution or better sought here. example: m = 10, array = [ 4, 4 ], r = 1 ( diameter 2 ), optimum ball position = [ 3, 5 ] what i've tried far: take 1 hook/ball @ time, create clustors if 2 balls hit each other. place them symmetrically @ centroid of hooks. ...

Drag a link onto OSX app dock icon -

when use safari, can drag url onto desktop save webpage .webloc file. can drag url safari onto chrome app, chrome app open link. when try drag url onto own app, nothing happens, app won't go - (void)application:(nsapplication *)sender openfiles:(nsarray *)filenames how this? chrome works i'm quite sure there way handle this.

ios7 - NSUserDefaults does not pick up setting -

i quite new coding in objective c , using settings bundle here coded. // set application defaults nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults]; nsdictionary *appdefaults = [nsdictionary dictionarywithobject:@"yes" forkey:@"gamesave"]; [defaults registerdefaults:appdefaults]; [defaults synchronize]; // user preference gamesave = [defaults boolforkey:@"savegame"]; nslog(@"save game = %@", gamesave ? @"yes" : @"no"); this settings bundle: <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <dict> <key>preferencespecifiers</key> <array> <dict> <key>title</key> <stri...

keypress - Press a C# Application button from keyboard -

Image
i have sample c# application have 4 buttons this: i want when press button respective others pressed correspondent button c# application (when window focused) , keeps being pressed simultaneously keyboard. how this? i've tried keyeventargs , keypress think i'm little bit confused. le: , have possibility press 2 buttons simultaneously: ====================================================== edit later: can't understand. i've created new project. whole code is: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace test3 { public partial class form1 : form { public form1() { initializecomponent(); this.keydown += form1_keydown; } private void form1_keydown(object sender, keyeventargs e) { if (e.keycode ==...

Android Tesseract App crashes -

i beginner tesseract andoid. making application extracts text image, application crashes @ tesseract code. can 1 please, don;t know error. tessbaseapi baseapi = new tessbaseapi(); string data_path = environment.getexternalstoragedirectory().getpath()+"//tesseract//tessdata//eng.traineddata"; string lang = "eng"; baseapi.init( data_path,lang); baseapi.setimage(img); string recognizedtext = baseapi.getutf8text(); baseapi.end(); textview out = ( textview ) findviewbyid( r.id.textview1 ); out.settext(recognizedtext); do compiled tess-two android ndk?

xml - Jackson: using builder with nondefault constructor -

i have following class: @jsondeserialize(builder = transaction.builder.class) public final class transaction { @jacksonxmltext private final transactiontype transactiontype; @jacksonxmlproperty(isattribute = true) private final boolean transactionallowed; private transaction(builder builder) { transactiontype = builder.transactiontype; transactionallowed = builder.transactionallowed; } public static final class builder { private final transactiontype transactiontype; private boolean transactionallowed; public builder(transactiontype transactiontype) { this.transactiontype = transactiontype; } public builder withtransactionallowed() { transactionallowed = true; return this; } public transaction build() { return new transaction(this); } } } transactiontype simple enum: public enum transactiontype { pu,...