Posts

Showing posts from June, 2013

ios - Custom UIButton subclass not displaying title -

let me start off saying aware asked question, can't seem find same scenario/problem me. i writing music application, , came ui liked. required button special functionality (past can achieved custom button type) decided make uibutton subclass. used following code in subclass: required init(coder adecoder: nscoder) { self.activestate = false self.activeaccidental = uiimageview() super.init(coder: adecoder) self.layer.bordercolor = uicolor(white:221/255, alpha: 1.0).cgcolor self.layer.borderwidth = 2.0 self.backgroundcolor = uicolor.blackcolor() self.settitlecolor(uicolor.whitecolor(), forstate: .normal) self.settitle("hello", forstate: .normal) } override func layoutsubviews() { println(self.frame.origin.x) self.activeaccidental = uiimageview(frame: cgrectmake(self.bounds.origin.x, self.bounds.origin.y, 20, 20)) self.activeaccidental.image = uiimage(named: "bmicalcicon.png") self.addsubview(activeaccidental...

python - A recursive function to sort a list of ints -

i want define recursive function can sort list of ints: def sort_l(l): if l==[]: return [] else: if len(l)==1: return [l[-1]] elif l[0]<l[1]: return [l[0]]+sort_l(l[1:]) else: return sort_l(l[1:])+[l[0]] calling function on list [3, 1, 2,4,7,5,6,9,8] should give me: [1,2,3,4,5,6,7,8,9] but get: print(sort_l([3, 1, 2,4,7,5,6,9,8]))--> [1, 2, 4, 5, 6, 8, 9, 7, 3] please me fix problem, actual code appreciated. thanks! the quick sort recursive , easy implement in python: def quick_sort(l): if len(l) <= 1: return l else: return quick_sort([e e in l[1:] if e <= l[0]]) + [l[0]] +\ quick_sort([e e in l[1:] if e > l[0]]) will give: >>> quick_sort([3, 1, 2, 4, 7, 5, 6, 9, 8]) [1, 2, 3, 4, 5, 6, 7, 8, 9]

ios - Xcode IOS7 ALAssetsLibrary Code not executed -

i using alassetslibrary save images download online server. each image imageobject image details. save photo album (to save , retrieve url , url converted uuid of image). once uuid added imageobject, imageobject added realm database. the problem code save photo album not executed. ignored. hope question clear, should make code (block) executable? [self writeimagessuccessively:[[nsmutablearray alloc] initwitharray:temposarray] completion:^(id result) { nsstring *res = (nsstring *)result; if ([res isequaltostring:@"finished"]) { //add realm } else { nslog(@"unable finish writing images"); } }]; the above code call method call addimagetoassetlibrary save photos album , return unique uuid each individual image. - (void) writeimagessuccessively:(nsmutablearray*)imgarr completion:(void(^)(id result))completionhandler { if ([imgarr count] == 0) { if (completionhandler) { // signal completion of writing images in imgar...

android - Fragment being created again -

i using fragment implement viewpager,the viewpager fragment,i implementing button , clicking on fragment goes previous fragment, on pressing button previous fragment again loading , getting response again. how can prevent that. have added code below. photo fragment:- public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.layout_photo, container, false); butterknife.inject(this, view); sharedpref = getactivity().getpreferences(context.mode_private); editor = sharedpref.edit(); if (sharedpref.contains("isviewpagerstarted")) { isviewpagerstarted = sharedpref.getboolean("isviewpagerstarted",false); } log.e("pagerstart", "" + isviewpagerstarted); if (isviewpagerstarted) { backbutton.setvisibility(view.visible); animation rightswipe = animationutils.loadanimation(getactivity(), ...

ios - Static property for type in Swift -

this question has answer here: static properties in swift 3 answers i want declare static property unknown on type gpslocation class gpslocation: nsobject { var lat: nsdecimalnumber = 0 var lng: nsdecimalnumber = 0 class var unknown:gpslocation = gpslocation(lat: 0, lng: 0) init(lat:nsdecimalnumber, lng: nsdecimalnumber){ self.lat = lat self.lng = lng } } i "class variables not yet supported" how can declare static property in swift? i'm not sure you're trying do, naming, you'd better off using optional gpslocation indicate unknown position rather comparing illegal value (which actually, in case, legitimate gps location) this intended usage of optionals, indicate has invalid or unknown value, without trying come otherwise invalid value stuff them with. in case, you're trying done can done impleme...

How access Text of a textbox in class of stimulsoft file -

i have function wrote on stimulsoft report code : public static changetextboxvalue(string s) { return s + " s.t "; } and in textbox in designer wrote expression : {changetextboxvalue(text1.text)} but @ preview return " s.t " . i try too, didn't work too: public static changetextboxvalue() { return text1.text + " s.t "; } by expression on textbox: {changetextboxvalue()} it's impossible use text1.text expression in other component. because after rendering there many text1 componnents on report pages , have different values. 1 should used? you should use same expression use in text1 component. expression calculated component.

node.js - Debug CoffeeScript sources with node-inspector -

i'm using coffeescript while write node.js programs. it's ok debug node-inspector if compile sources source maps . however, when try create mixed javascript/coffeescript app using coffee-script/register : #!/usr/bin/env node require('coffee-script/register'); require('../src/client'); then, node-inspector shows compiled javascript. is there how see actual *.coffee sources in node-inspector when i'm not explicity compiling it? disclaimer: maintainer of node inspector in order see actual *.coffee file in node inspector, need provide source-map file describing how map transpiled javascript loaded inside node/v8 runtime coffee-script source. additionally, filename of transpiled javascript must different original script name (afaik). this trouble require('coffee-script/register') : converts coffee-script source javascript source while keeping same file name. in other words, runtime (and node inspector) see *.coffee contain tr...

Configurable significance for numbers in java's String.format()? -

i'm tasked writing function format set (coordinate) of doubles configurable significance. have: public string dpath(int sign) { return string.format ("%s %." + sign + "f %." + sign + "f", prefix, this.x, this.y); } which works: movement m = new movement(3.14159265, 2.7654321); assert.assertequals("m 3.142 2.765", m.dpath(3)); is possible without string concatenation? current implementation looks bit unnatural, may attributed unnatural use case? just measure. return string.format(string.format("%%s %%.%df %%.%df", sign, sign), prefix, this.x, this.y);

Array parameter in a powershell function does not load the first element -

i have function takes 1 string parameter, , 1 array of string parameter function w { param([string]$format, [string[]]$args) write-host $format write-host $args } then execute function in following way: w "formatparam" "args1" "args2" w "formatparam" "args1" "args2" "args3" w "formatparam" "args1" "args2" "args3" "args4" w "formatparam" "args1" "args2" "args3" "args4" "args5" as can seen in output, string array not seem load first parameter, meant go array: formatparam args2 formatparam args2 args3 formatparam args2 args3 args4 formatparam args2 args3 args4 args5 any ideas? $args special $args special variable in powershell; shouldn't declaring parameter because you're overriding it. let's name else, $remaining . arrays use commas the way you're pass...

powershell - Azure Automation: Parallel Job Handling (start-job) -

i'm trying convert azure powershell script azure automation runbook, i've run issue when using "start-job" command. after inline scripts called, jobs fail shortly after starting. seems me parameters not passing through properly. is there i'm missing pass parameters within azure automation? the commands failing: $createvnetgateway = { param($vnetname) new-azurevnetgateway -vnetname $vnetname -gatewaytype dynamicrouting } <#start jobs#> start-job $createvnetgateway -argumentlist $vnetname1 start-job $createvnetgateway -argumentlist $vnetname2 wait-job * in powershell workflow, when pass value inlinescript block, need add $using front of value. ex: workflow foo { $message = "hi" inlinescript { write-output -inputobject $using:message } } in addition, starting other jobs within azure automation sandbox not supported. looks trying run 2 tasks in parallel , after both complete. powershell workflow (the ...

html - Creating post form with form name as holder -

how can create form form name container form posts. this got: array ( [sendername] => gsdfg [receiveraddress] => asdf [receiveremail] => asd@asd [xsize] => 2 [ysize] => 3 [zsize] => 4 [units] => cm [weight] => 22 ) but want is: array ( [form] => array([sendername] => gsdfg [receiveraddress] => asdf [receiveremail] => asd@asd [xsize] => 2 [ysize] => 3 [zsize] => 4 [units] => cm [weight] => 22 )) (giving form name attribute doesnt resolve problem) this html: <form action="http://dev.playgroundwp.lv/?page_id=24" id="productform" method="post"> <table> <tbody><tr> <td> <label for="sender-name-input">your name*:</label> </td> <td> <input type="text" name="sendername" value=...

algorithm - Find the most similar subsequence in another sequence -

i need write algorithm, finds similar substring in s1 string s2 (substring in s1 has minimum hamming distance s2, in other words) in n log(n), n = len(s1) + len(s2), len(s2)<=len(s1). for instance: s1 = agtcagtc s2 = gtc answer: gtc (distance 0) s1 = aaggttcc s2 = tcaa answer: ttcc (distance 3) time complexity may not exceed o(n log(n)). space complexity doesn't matter. lcs (longest common subsequence) doesn't work in case. example: s1 = gaatccagtctgtct s2 = aatatatat lcs answer: aatccagtc gaatccagtctgtct ||| aatatatat right answer: agtctgtct gaatccagtctgtct | | | | | aatatatat i think trying solve longest common subsequence problem . problem deals trying find least amount of modifications necessary transform 1 string another. you said trying write algorithm this. take @ lcs problem , try googling if want roll own algorithm or take advantage of command line utility diff. just longes...

c# - Retrieve user's Outlook status -

i found vbscript code retrieve user's outlook status , display in list box. need c# , there no conversion tools online: set objoutlook = createobject("outlook.application") set objnamespace = objoutlook.getnamespace("mapi") set objrecipient = objnamespace.createrecipient("kenmyer") strfreebusydata = objrecipient.freebusy(#11/11/2014#, 60) dtmstartdate = #11/11/2014# = 1 len(strfreebusydata) step 24 wscript.echo dtmstartdate strday = mid(strfreebusydata, i, 24) x = 1 12 if x = 1 strtime = "12 am: " else strtime = x - 1 & " am: " end if intfreebusy = mid(strday, x, 1) if intfreebusy = 1 strfreebusy = "busy" else strfreebusy = "free" end if wscript.echo strtime & strfreebusy next x = 13 24 if x = 13 strtime = "12 pm: " else ...

java - How to read messages for web sphere mq and spring -

i trying find tutorials on how use jms template , spring read messages queue. want let user show me last x number of messages on queue all can find examples of how send messages using jms , spring. possible read last x messages queue (webspehere) using jms / spring , if able post code example or point me website demonstrates such functionality? thanks show me last x number of messages on queue that's not how it. mq not database. read message, process read next message process it, etc...

php - how to get in url with value.html -

this form submits url that http://www.website.com/page/search.php?search=demo&submit=search <form action="search.php?search=" method="get" id="search-form"> <input id="search-text" name="search" type="text" maxlength="30" placeholder="type keyword"/> <button type="submit" name="submit" value="search" id="search-button">search</button> </form> where want post form that: http://www.website.com/page/search/demo.html how can this? know small thing me.. thanks i unclear question is. if mean want able process input client-side, not possible unless override behavior javascript. example jquery $( "search-form" ).on( "submit", function( event ) { // stuff here form data event.preventdefault(); }); if mean don't want .php show , want hide underlying server technology, c...

Mapping in Spark Scala -

i new spark , scala , kind of programming in general. what want accomplish following: i have rdd org.apache.spark.rdd.rdd**[(double, iterable[string])]** so possible content be: <1 , (a,b,c)> <42, (a) > <0 , (c,d) > i need transform new rdd in such way similar output to: <1, a> <1, b> <1, c> <42, a> <0, c> <0, d> this has simple, tried many different ways , couldn't right. you can use flatmapvalues : import org.apache.spark.sparkcontext._ val r : rdd[(double, iterable[string])] = ... r.flatmapvalues(x => x)

python - "No matching records found" when using bootstrap-table in Flask -

Image
i'm developing website based on flask, , want load data.json using bootstrap-table. got table without data. the directory structure displays below: index.py templates/ new.html data.json data1.json static/ css/ bootstrap-table.css bootstrap-theme.css bootstrap-theme.min.css bootstrap.css.map base.css bootstrap-table.min.css bootstrap-theme.css.map bootstrap.css bootstrap.min.css js/ bootstrap-table.js bootstrap.js bower_components/ jquery.min.js bootstrap-table.min.js bootstrap.min.js index.js npm.js and index.py looks this: 62 @app.route("/") 63 def new(): 64 return render_template('new.html') the 'new .html' looks this: <!doctype html> {% extends 'base.html' %} {% block title %}config{% endbl...

javascript - Transition on axis -- losing grid lines (ticksize), how to transition in correct order? -

Image
i've got horizontal bar graph transition on x-axis. looks how want, almost. sadly, red gridlines (ticksize(-h)) in back. need bring them front. code here: http://bl.ocks.org/greencracker/1cb506e7375a2d825e24 i'm new transitions , suspect i'm calling in wrong order. any suggestions on gridlines front and/or suggestions how dry code? not dry, i'm starting easy baby steps. key parts: d3.csv("georgia_counties_vmt.csv", function(input) { data = input; data.foreach(function(d) { d.value = +d.value; }); data.foreach(function (d) {d.n1 = +d.n1; }) data.sort(function(a, b) { return b.value - a.value; }); x.domain([0, d3.max(data, function(d) { return d.value; })]); y.domain(data.map(function(d) { return d.name; })); initaxes(); // draws tiny axes transition proper size change(); // calls redraw() // skip some, then: function redraw() { // unrelated bar drawing stuff here: //calls regular-size axes svg.s...

ms word - How can I perform a VBA script on click? -

Image
i'm using checkbox legacy form field in word document. , want perform vba script each time change status of checkbox. thought have perform vba script on event (no. 1 in picture). if chose either no. 1 or no. 2, performs vba script if i'm changing next field. my questions: now, how can perform vba script on each click? , difference between no. 2 , no. 3 in picture above? word has no on event triggers checkboxes if remember correctly. a possible workaround kind of validation button checks value of checkbox , executes appropriate commands.

python - Adjust widths of QHBoxLayout -

Image
here code: #!/usr/bin/env python3 import sys, time pyside import qtcore, qtgui import base64 # usage: toast('message') class toast(qtgui.qdialog): def __init__(self, title, msg, duration=2): qtgui.qdialog.__init__(self) self.duration = duration self.title_label = qtgui.qlabel(title) self.title_label.setalignment(qtcore.qt.alignleft) self.msg_label = qtgui.qlabel(msg) self.icon_button = qlabelbutton() img_b64 = "ivborw0kggoaaaansuheugaaabgaaaaycayaaadgdz34aaaabhncsvqicagifahkiaaaaalwsflzaaaitgaace4bjdea7aaaabl0rvh0u29mdhdhcmuad3d3lmlua3njyxbllm9yz5vupboaaabjdevydenvchlyawdodabqdwjsawmgrg9tywluigh0dha6ly9jcmvhdgl2zwnvbw1vbnmub3jnl2xpy2vuc2vzl3b1ymxpy2rvbwfpbi9zw/7kaaab2eleqvriibwvpw/tubifz7mjtbfsggnuqmabrgpmuyi53pck1iwxuxd2bgyk/godazuq+afilehizuuq/acpryrkgsjpdhkpqx3uok7tjokd7guf57nxh++ljfrvr9e70el03plcbnanh/4t6szlsvdpml5u5duvdabhgdllsj6ajsvd9wfshwhiujzrvgbcrqlb7b6u9aoash6atqdf62ypak6wdibn0wszo52dm9lpezhqs4lh...

c# - How to add a result tolerance to a NUnit TestCase -

i have algorithm converts value between celsius , farhrenheit. test works wide range of values i'm using nunit's testcases so: [testcase( 0, result = -17.778 )] [testcase( 50, result = 10 )] public double fahrenheittocelsius(double val) { return (val - 32) / 1.8; } the problem first testcase fails because tests exact match. 1 solution have found this: [testcase( 0, -17.778 )] [testcase( 50, 10 )] public void fahrenheittocelsius2(double val, double expected) { double result = (val - 32) / 1.8; assert.areequal( expected, result, 0.005 ); } but i'm not happy it. question is: can tolerance result defined in testcase? update: clarify, i'm looking along lines of: [testcase( 0, result = 1.1, tolerance = 0.05 )] add parameter test case: [testcase(0, -17.778, .005)] [testcase(50, 10, 0)] public void fahrenheittocelsius2(double fahrenheit, double expected, double tolerance) { double result = (fahrenheit - 32) / 1.8; assert.aree...

unit testing - c# - Assert Expressions -

i have 'example' class , create unit test it. take on classes below: public class example { private readonly calculator _calculator; public example(icalculator calculator) { _calculator = calculator; } public void calculate() { _calculator.execute(operation => operation.subtract()); } } public interface ioperation { void sum(); void subtract(); } public inferface icalculator { void execute(action<ioperation> action); } public class calculator { public void execute(action<ioperation> action){} } what want create unit test class verify method example class calculate calls _calculator.execute passing parameter operation.subtract() . possible? i know how mock icalculator , verify execute being called once, have no idea how validade if execute method called using operation.subtract() parameter instead of operation.sum() . i using nunit create unit tests. here can see how unit test cl...

Regex doesn't match in Perl, does on Sublime Text 3 -

i have regular expression trying match on strings containing: <script type="text/javascript"> var debug = new debugger(); </script> i have determined suffices use word "debug" match on. if execute command: find . -name 'test.html' -exec perl -ne '/<script type="text\/javascript">[\s\s]*?(debug)[\s\s]*?<\/script>/ && print' '{}' \; i expect regex match, regex string <script type="text\/javascript">[\s\s]*?(debug)[\s\s]*?<\/script> matches on sublime text. i have had trouble using [\s\s] perl. there missing here? thanks you want use perl's paragraph mode ( -0 ) when calling it. using this, regex work: find . -name 'test.html' -exec perl -n0e '/<script type="text\/javascript">[\s\s]*?(debug)[\s\s]*?<\/script>/ && print' '{}' \; (not?) surprisingly @sputnick gets gold medal answer here ...

python - BeautifulSoup doesn't find correctly parsed elements -

i using beautifulsoup parse bunch of possibly dirty html documents. stumbled upon bizarre thing. the html comes page: http://www.wvdnr.gov/ it contains multiple errors, multiple <html></html> , <title> outside <head> , etc... however, html5lib works in these cases. in fact, when do: soup = beautifulsoup(document, "html5lib") and pretti-print soup , see following output: http://pastebin.com/8bkapx88 which contains lot of <a> tags. however, when soup.find_all("a") empty list. lxml same. so: has stumbled on problem before? going on? how links html5lib found isn't returning find_all ? when comes parsing not well-formed , tricky html, the parser choice important: there differences between html parsers. if give beautiful soup perfectly-formed html document, these differences won’t matter. 1 parser faster another, they’ll give data structure looks original html document. but if document...

oracle - Passing multiple values on 'IN' where clause -

i tyring figure out solution issue in concurrent program passes in multiple values free text field parameter. on rdbms : 11.2.0.3.0 , oracle applications : 12.1.3 .the concurrent program calls custom plsql procedure produces xml output based on parameters passed in. i've tried create clause dynamically in efforts make sys_refcursor work shown below. i've tried regexp_substr create list of values once parameter string passed in , did not work either. i've tried fails error below. can take , let me know how can make work? this error receiving: pl/sql: numeric or value error: invalid lob locator specified: ora-22275. here example of problem. declare ctx dbms_xmlgen.ctxhandle; ref_cur sys_refcursor; xmldoc clob; v_company varchar2(25); v_major_acct varchar2(150); v_major_acct_free varchar2(150); l_length number; l_offset number := 1; l_amount number:=16383; l_rpt_data varchar2(32767); v_where varchar(32000); begin dbms_lob.createtemporary(xmldoc,true); v_company ...

linear programming - Ford-Falkerson's algorithm for undirected graphs (What am I missing?) -

i "found" algorithm finding maximum flow in undirected graph think isn't correct, can't find mistake. here algorithm: construct new directed graph in following way: every edge ${u,v}$ create edges $(u,v)$ , $(v,u)$ $c((u,v))=c((v,u))=c({u,v})$. apply ford-falkerson's algorithm on new graph. make flow in our first graph in following way: let's $f((u,v))\ge f((v,u))$, direct edge ${u,v}$ $u$ $v$ , take $f'((u,v))=f((u,v))-f((v,u))$. maximum flow our undirected graph, because otherwise construct flow corresponding directed graph, contradiction. reason think have missed there article on internet problem , don't think wrote article such trivial problem. and article: http://www.inf.ufpr.br/pos/techreport/rt_dinf003_2004.pdf thanks! ford-fulkerson not best algorithm find maximum flow in directed graph, , in undirected case possible better (close linear-time if recall correctly). you don't cite article talking about, describe alg...

java - HttpURLConnection show progress -

i use httpurlconnection connect server.i want show update proress. url url = new url(requesturl); httpurlconnection conn = (httpurlconnection) url.openconnection(); conn.set...// many params. dataoutputstream dos = new dataoutputstream(conn.getoutputstream()); dos.write("http string"); // eg content-disposition: form-data...... inputstream = new fileinputstream(file); // take file stream. while(){ dos.write(filestring);// take file strean memory.this place can take prograss,but in momory,not post server proress. } dos.flush(); inputstream input = conn.getinputstream(); // place post data server,but donot how progress. please me ,thanks. you use asynctask that.

taskkill - Batch script to kill a process if not responding in a for loop -

i trying install windows standalone update files , need use wusu.exe. every , again wusu.exe hang. have created batch file called prereqs.bat , in file have calls wusu.exe. need code kill wusu.exe if hangs, , retry again. this code stands now: :prereqs32 taskkill /im prereqs32.bat /f taskkill /im wusa.exe /f when loops back, kills both batch file , wusa.exe start cmd /k c:\windows\temp\prereqs.bat an outside process can kill wusu.exe if things go awry. timeout /t 240 /nobreak this timeout wait until install complete not enough. taskkill /im "[wusa.exe]" /fi "status eq not responding" if "%errorlevel%"=="1" goto prereqs32 is there way sort of loop, logic exit if status not "not responding"? also, bonus, there way forgo timeout , "wait" prereqs.bat complete before moving on, assuming wusu.exe has not hung?

jquery - How can i prevent onclick button from multiple click until it's confirmation from javascript if(confirm ) condition -

<input type="button" onclick="return savevalues();" value="<?php echo "values" ?>" class="silver_button_big"> on above stop multiclick have tried this. my_toggle_var = 0; // global variable u can use play function savevalues() { if (my_toggle_var == 0) { ic.do.something(); my_toggle_var = 1; // can move down based on need.... } }, : function(){ //some code //these code lead run jar file // data insertion db(using mysql) } but unable solve problem in above case, can there may sort of browser cache problem. can me out. just set disabled="disabled" , readonly="readonly" attributes: // attach click handler $(".silver_button_big").on("click", function() { var $this = $(this); // disable button $this.attr({"disabled": "disabled", "readonly": "readonly"}); // async settimeout(function...

linux - pmap result shows many file are mapped from virtual address zero -

for init process, pid 1, , other processes, when use pmap show mmapped file, results show this: 0000000000000000 0k r-x-- /sbin/init 0000000000000000 0k r---- /sbin/init 0000000000000000 0k rw--- /sbin/init 0000000000000000 0k ----- [ stack ] 0000000000000000 0k rw--- [ stack ] 0000000000000000 0k r-x-- /lib/libc-2.12.2.so 0000000000000000 0k ----- /lib/libc-2.12.2.so 0000000000000000 0k r---- /lib/libc-2.12.2.so 0000000000000000 0k rw--- /lib/libc-2.12.2.so 0000000000000000 0k rw--- [ stack ] 0000000000000000 0k r-x-- /lib/ld-2.12.2.so 0000000000000000 0k rw--- [ stack ] 0000000000000000 0k rw--- [ stack ] 0000000000000000 0k r-x-- [ stack ] 0000000000000000 0k rw--- /lib/ld-2.12.2.so 0000000000000000 0k rw--- [ stack ] 0000000000000000 0k rw--- [ stack ] ffffffffff600000 4k r---- [ anon ] total 4k why happens? virtual address except las...

spring - how to inject springbean to a struts intercepter..is it possible -

i having used defined intercepter,from intercepter want make db call through dao layer, how can inject spring bean struts intercepter.is possible inject spring bean struts intercepter can 1 suggest idea on this. edit since there no need declare interceptor spring bean, striked unnecessary parts. @aleksandrm testing it. exactly way actions , (if remember well) exception of declaring in beans.xml because interceptors don't extend actionsupport (that autowired default) . web.xml <listener> <listener-class> org.springframework.web.context.contextloaderlistener </listener-class> </listener> applicationcontext.xml <bean id="daoservicebean" class="org.foo.bar.business.dao.daoservice"/> <bean id="myinterceptorbean" class="org.foo.bar.presentation.interceptors.myinterceptor"/> struts.xml <constant name="struts.objectfactory" value="...

set - Searching in Hashcode doesn't work in Java -

i have set tablica = new hashset(); and want search wrote this: public void searchstudentbysurname() { int = tablica.size(); if (0 >= a) { joptionpane.showmessagedialog(null, "no data"); } else { string s = joptionpane.showinputdialog(null, "give me surname"); iterator itr = tablica.iterator(); while (itr.hasnext()) { string str = (string) itr.next(); if(tablica.equals(s)) { // if doesn't work (1) joptionpane.showmessagedialog(null, str); } } } } } i want know why (1) doesn't work. you comparing string set, it's can't return true. you meant compare str - str.equals(s) , not necessary. can replace entire while loop tablica.contains(s) . that's set s for.

android activity - Binary XML file line #11: Error inflating class fragment -

i getting 2 errors in code. caused by: java.lang.illegalstateexception: fragment com.example.dfoley.write_to_file.topfragment did not create view. caused by: android.view.inflateexception: binary xml file line #11: error inflating class fragment both pointing line mainactivity.java:21 following setcontentview(r.layout.activity_main); bottomfragment package com.example.dfoley.write_to_file; import android.app.listfragment; import android.os.bundle; import android.widget.arrayadapter; import java.util.arraylist; public class bottomfragment extends listfragment { private arrayadapter<stateuser> adapter; @override public void onactivitycreated(bundle saveinstancestate){ arraylist<stateuser> flight = maincontoller.getinstance().getflights(); this.adapter = new arrayadapter<stateuser>(getactivity(), android.r.layout.simple_list_item_1, flight); setlistadapter(this.adapter); super.onactivitycreated(saveinstancestate...

Extjs 5: Grid Search Plugin -

i using search plugin grid in extjs 4 , works ,when upgrade application extjs 5 it's not work. is there compatible free version of grid search plugin extjs 5 ? thanks. no, there no free version ext 4 , 5 - if plugin works in 4 must unofficial version latest free version ext 3. you can purchase commercial version ext 4 & 5 here: http://extjs.eu/software/ext-grid-search-plugin/ i'm author of plugin.

email - PHP e-mail displaying special chars as � -

i have searched , forth through here , google. no luck. trying send e-mails php have following: header("content-type: text/html; charset=utf-8"); $empfaenger = "mail@someone.com"; $mailbetreff = "subject"; $header = "mime-version: 1.0\n"; $header .= "content-type: text/html; charset=utf-8\n"; $header .= "from: "; $header .= $sender; $header .= "\n"; $header .= "straße: blabla"; mail($empfaenger, $mailbetreff, "", $header); characters "ß" , "ä" , arrive �. contents of e-mail generated form , not know, chars uses won't replace 1 "ß" &szlig", obviously. i have tried iso-8859-1 , encoding strings htmlentities(), switches outcome � Ã special chars. in case, relevant: server runs php 5.2.7 this row should not in $header : $header .= "straße: blabla"; you need create $body variable body, , add 3rd parame...

database - How many users is enough to crash the online mysql DB(http://www.db4free.net/)? -

i have approx 10 000 users, 1 user requesting whole db information (appr 10 000 rows) once second. enough mysql db crash?? thanks this depends on many things, such as the specs of server (e.g. how fast disk / memory is) the setup of mysql (e.g. how memory allocated) the engine used in mysql (e.g. myisam locks whole table when wants use row) the structure of query (e.g. sorting on non-indexed row slow) how information in each row (the more information, longer takes read it) either way, situation not sound ideal. better of caching result of query on disk somehow, reading disk faster reading database. hope helps!

c# - Timeout occurs while executing MySqlDataReader::Read() -

i following exception while calling read() on mysqldatareader object. using (mysqlconnection con = new mysqlconnection(myconnectionstring)) { con.open(); using (mysqlcommand command = con.createcommand()) { command.commandtext = string.format("select id mytable id in ({0})", idlist.tostring()); mysqldatareader reader = command.executereader(); while (reader.read()) { int id = int32.parse(reader["id"].tostring()); if (!idhashset.contains(id)) { idhashset.add(id); } } } } the program seems freeze 8 hours, , spits out following exception , stack trace. timeout can set 'system.threading.timeout.infinite' or value > 0. parameter name: value system.net.sockets.networkstream.set_readtimeout(int32 value) mysql.data.mysqlclient.timedstream.starttimer(iokind op) mysql.data.mysqlclient.timeds...

Ruby array into an object instance -

i've made array generator fake individuals populate apartments: ["53 york street", 7995, true, 123, 2, 1, "tommy gough"] ["53 york street", 18070, true, 278, 2, 1, "sarah stewart"] but want turn each instance object instance , i'm trying figure out .each loop (or other) method so. haven't found way write method doesn't use string output... i'm going wrong. say class want instances of looks this: apartment = struct.new(:street, :code, :field3, :field4, :field5, :field6, :name) (i don't know other fields stand for.) and input looks this: input = [ ["53 york street", 7995, true, 123, 2, 1, "tommy gough"], ["53 york street", 18070, true, 278, 2, 1, "sarah stewart"] ] then can create array of instances this: output = input.map { |entry| apartment.new(*entry) } note splat ( * ) expands (inner) array list of method arguments can pass constructor. more verb...

How to convert from Date(10-Oct-2014 00:00:00) to String in Java -

this question has answer here: how compare dates in java? 11 answers converting date-string different format 5 answers i want compare 2 date values in java date date1=10-oct-2014 00:00:00(value fetched db) date date2=10-oct-2014 00:00:00(value fetched db) how convert date values string format in java cant compare them or else there way can compare these dates. i compare long values of both dates this: if dates nullable dont forgett nullcheck! if (date1!=null && date2 != null){ if (date1.gettime() == date2.gettime()){ system.out.println("dates equal"); } } there no need cast date objects string objects.

android - My messages are getting downgraded by MQTT-broker, so what? -

as far understand, if subscribed topic specific qos , subscriber see messages under topic provided mqtt broker qos level equal or lower qos specified @ publishing topic. in other words,the client subscribe, exampe, the topic = news , qos = 1 , able see published messages under topic = news with qos = 1 or 0 i subscribed topic = news qos = 0 , topic published qos = 2 , when connected broker , received te published message qos = 0 , , second time, published same topic qos = 1 , , when subscribed qos = 0 , received message qos = 0 . so, since whatever qos level receive message but, qos "downgraded", what?what risk? can explain?!! when make subscription saying broker "the maximum qos wish receive messages @ x". means if message comes in on topic subscribed @ higher qos, downgraded you. other clients not affected. table below clears you. subscription qos | message qos | delivered qos =================|=============|============== ...

javascript - Passing id element to database using ajax -

i have following code, works: <script> function showuser(str) { if (str=="") { document.getelementbyid("txthint").innerhtml=""; return; } if (window.xmlhttprequest) { // code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else { // code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("txthint").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","getuser.php?q="+str,true); xmlhttp.send(); } </script> <body> <?php include 'db_connector.php'; $result = mysqli_query($con,"select * scope"); while($row = mysqli_fetch_array($result)) { $row['name']; echo "<div class='toggle-btn-grp cssonly'> <div><input type='radio' name='os' value=".$row['name']....

java - Cache using ConcurrentHashMap -

i have following code: public class cache { private final map map = new concurrenthashmap(); public object get(object key) { object value = map.get(key); if (value == null) { value = new someobject(); map.put(key, value); } return value; } } my question is: put , get methods of map thread safe, since whole block in not synchronized - multiple threads add same key twice? put , get thread safe in sense calling them different threads cannot corrupt data structure (as, e.g., possible normal java.util.hashmap ). however, since block not synchronized, may still have multiple threads adding same key: both threads may pass null check, 1 adds key , returns value, , second override value new 1 , returns it.

actionscript 3 - AS3: Post to Facebook Wall - Error #2032 -

i developing app visitors of event can take pictures using webcam , upload them facebook using as3-application. know can connect facebook, because can log user out using api , can information. problem can't post wall reason. keep getting following error: error #2032: stream error. url: https://graph.facebook.com/********/feed i use following code post facebook: private function postfb(e:event=null):void { var _params:object = new object(); _params.uid = facebook.getauthresponse().uid; _params.access_token = facebook.getauthresponse().accesstoken; _params.message = "i @ thanksgiving day event."; //_params.picture = _bitmap; facebook.api("/me/feed", postcomplete, _params, "post"); } as i've said before, know connected facebook because if change "post" "get" in api-call, information of account. have correct permissions far know (read_stream, publish_stream, user_photos). use graphapi_web_1_8_1...

regex for multiple strings -

i have 2 strings i'm trying match in file , return line. the first string match i'm looking not completely. example: i might looking matcht in matchthisstring match not entire string. string 1 might come before or after string 2 , might start uppercase or lower case letter. example: i might looking have actually. but , have things matchthisstring.actually or actually.matchthisstring or matchthisstring.someotherjunkidon'tcareabout.actually other combinations that. i'm having problems using 2 search strings , getting reggae work. here's example of code works: @matches; while (<$in_fh>) { #push @matches, $_ if / \q$wanted\e .* \q$prefix\e /x; #push @matches, $_ if / \q^*(.*)$wanted\s*(.*)\e .* \q^*(.*)$prefix\s*(.*)\e /x; push @matches, $_ if / \q$wanted\e /x; } what want work 1 of other options that's commented out. don't think i'm joining 2 searches 1 string properly. thanks in advance assistance. ...

android - Activity closed in middle of work and redirect it to previous activity -

i created app loan survey. in each survey 80 90 questions have been displayed. questions displayed 1 one when press next button. views r created programatically , after submitting each question have removed views , create views. it works fine, problem is, when in 30 40 th question activity closes , redirect previous activity. not executing onpause method also. dont know problem. there no app crash also. don't no whether caused due memory error or other. please suggest me how solve it. thanks in advance here how close reach using combination of answer of rotation of image around itself , this post of moving image in circular path //i imageview here // method rotate globe private void applyrotation(float start, float end) { //first animation circular path final animation rotation = new myanimation(i, 2000); rotation.setduration(10000); rotation.setrepeatcount(0); //rotation of iamge final animation rotation2 = new rotateanimation(30, 360...