Posts

Showing posts from 2012

java - Stream file from URL to File without storing it in the memory -

i want download file url , store file system. have memory limitation , don't want store in memory before. not java expert , bit lost class inputstream, bufferedreader, fileoutputstream, etc. me please ? for have: urlconnection ucon = url.openconnection(); ucon.connect(); inputstream = ucon.getinputstream(); // create reader input stream. bufferedreader br = new bufferedreader(isr); // ? fileoutputstream fos = context.openfileoutput(filename, context.mode_private); // here content can big memory... fos.write(content.getbytes()); fos.close(); please, give me clue ? thinking read chunk chunk, not sure easiest java... you can use apache commons org.apache.commons.io.fileutils.copyurltofile(url, file) i guess may not work on android use code inputstream input = connection.getinputstream(); byte[] buffer = new byte[4096]; int cnt = - 1; outputstream output = new fileoutputstream(file); while ( (cnt = input.read(buffer)) != -1) { output.write(buffer, 0, cnt);

objective c - iOS: Don't return from function until multiple background threads complete -

this seems should simple i'm having lot of trouble. have function fires off bunch of other functions run in background , have completion blocks. want function wait until of completion blocks have been called before returns. i not have control of function calling executes in background. otherwise modify use dispatch_async own queue , wait on queue finish. example of situation looks like: - (void)functionthatshouldbesynchronous { (int = 0; < 10; i++) { [self dosomethinginbackground:^{ nslog(@"completed!"); }]; } // how wait until 10 threads have completed before returning? } - (void)dosomethinginbackground:(void(^)())completion { dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0), ^{ [nsthread sleepfortimeinterval:1.0f]; // stuff completion(); // execute completion block }); } thanks in advance. use dispatch group this: - (void)functionthatshouldbesynchro

html5 - Why is my PHP/HTML Header color/border not showing in OLD IE Browsers/ And it's not the CSS -

the below header: following cookie in php <header> <div id="first"> <?php if ($visits > 1) { echo "thanks coming more laughs!!!"; } else { // first visit echo 'welcome website!'; } ?> </div> this h1, h2, images, link, , image <h1>the clean jokes , riddles website!</h1> <h2>add & search jokes or riddles</h2> <div> <img id ="funny" img src="images/funny.jpg" alt="funny"/> <img id ="dog" img src="images/pet.jpg" alt="dog"/> </div> <div id="a"> <a href="?add" >add new joke or riddle</a> <img id="bell" img src="images/bell1-c.gif" alt="bell"> </div> </header> older versions of ie not apply css rules elements don

pug - What are the pros and cons of both Jade and EJS for Node.js templating? -

jade versus ejs, pros , cons of each , purposes each designed for? are there any other express-compatible template engines , why? i used jade before. nice thing jade have shorter syntax means can type faster. block in jade pretty powerful can me lot when dealing complex html code. on other hand, hard simple stuff in jade, thing adding classes div based on simple if condition. need put - if (isadmin) div.admin.user - else div.user jade don't differentiate between tags , variables make code confusing (at least me) a(href='/user/' + user.id)= user.name jade not designer-friendly. designer friends give me html , css (they switched less still want use html), , reason if use jade need convert html jade. in jade, need use indentations, if html structure gets complicated, code horrible (especially tables). sometimes, don't know level at table thead tr td img tr td tbody tr td recently, made

How to use android media player play radio streaming in asx format -

i want play streaming url: http://www.mediacorpradio.sg/radioliveplayer/asx/class95/fm950.asx what tried: public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); ... // player player = new mediaplayer(); player.setaudiostreamtype(audiomanager.stream_music); player.setonpreparedlistener(new onpreparedlistener() { public void onprepared(mediaplayer mp) { mp.start(); button.setimageresource(r.drawable.pause); } }); try { player.setdatasource(radio_url); } catch (exception e) { toast("unable play radio. please email if see constantly."); return; } player.prepareasync(); } private void togglestate(){ if (player.isplaying()) { player.pause(); button.setimageresource(r.drawable.play); }else{ player.prepareasync(); } } @override public void ondestroy() { super.ondestroy(); player.r

javascript - Entering values into a jquery-select2 that are not in the select list -

i have use case allow people type values text box of select2 plugin not appear in select list. in 1 case providing validation , not submit unless user has valid item selected until do not want clear values. select box might contain 1.00, 1.50, 1.75, na, abs , user has typed 1.80. invalid value don't want lose changes, flag box invalid , allow them fix changes. not want add 1.80 select box invalid value, don't want clear either. how possible achieve this? if you're validating in js, select2 has example dynamic loading/generating data overrides query() repeats user's input. see: http://ivaynberg.github.io/select2/ 'loading data' i solved similar problem (server-side) jquery ui 'autocomplete'. here, took approach of returning objects wrapping both label possible explanatory message, text value without decoration, , combined id value & status flag . overrode select store text & id hidden fields. in case, distinguishing b

keyboard - How to catch global keyPress events in Ember -

i'm sure i'm missing obvious, but: how respond keypress event anywhere on page? for example, had video player , wanted pause if user pressed spacebar @ point. or, i'm writing game , want arrow keys direct character, without regard specific views or subviews. defining app.applicationview = ember.view.create({ keypress: whatever }) doesn't seem work. have thought keypress events bubble that. i guess want is: $(document).keypress(function(e) { alert('you pressed key!'); }); except through ember. if looking global keypress code example above best solution. ember application attached body (or root element you've defined) , require sort of focus on view. example do: app.applicationview = em.view.extend({ keyup: function(){ alert(1); } }); this work, application view or child need have focus. useful, example, if wanted capture key event of input fields.

android - Scaling GCM Push. How often can you perform GCM Push? -

everybody tells me polling server new data stupid if server yours , should implement push gcm instead. well, agree , have done but, wondering, how can or should perform push? i have simple app people post stuff server , have feed of else's posts. method on server saving database triggers gcm push @ end, google sends out push notifications , requeries server new posts, containing post weve made. but, if have, lets milion users , new post created lets every minute. mean app connect server every minutes , kill battery. question is, how perform push? wouldnt in case polling every 10 minutes better battery, right? i know example kind of crazy, having milion people in feed, make point, because cant imagine how scale. figure google handle sending million gcm messages @ once no problem. so question is, there limit after push contraproductive? guess kind of first world problem :d cant imagine facebook handles stuff this. thanks! push notifications welcome when serve

Bash array and loop won't work together -

i pretty new in bash script , can't figure out why piece of code doesn't work (yes i've googled around). here's code: if [ $usertype = normal ] commands[0]="hi" ; descriptions[0]="get greeted" commands[1]="test" ; descriptions[1] = "test" elif [ $usertype = hacker ] commands[0]="hi" ; descriptions[0]="get greeted" commands[1]="test" ; descriptions[1] = "test" fi alias fhelp=' ((i=0; i<=${commands[@]}; i++)) printf '%s %s\n' "${commands[i]}" "${descriptions[i]}" done' any ideas? thanks in advance. you can't use single quotes inside single quotes. this, treats "'" string of single quote , concatenate them. alias fhelp=' ((i=0; i<=${commands[@]}; i++)) printf '"'"'%s %s\n'"'"' "${commands[i]}" "${descriptions[i]}" done'

MySql Two subrequest count call -

hello guys have trouble code: select (select count( * ) _mark_as value =2) bad, (select count( * ) _mark_as value =1) `_mark_as` what does, count "good" , "bad" values but, call on every entry in _mark_as , it's not right. want make single call return 1 entry with: # # bad # ############## # 2 # 2 # ############## help please. ps: group not way out. because first done selection (for entries) , applied group by. select sum(case when value = 2 1 else 0 end) bad, sum(case when value = 1 1 else 0 end) _mark_as

jquery - How can I position these divs horizontally? -

i cannot figure out how place lists horizontal, have played appreciate if someones gives me advice. http://jsfiddle.net/py3de/74/ <div class="source"> <div class="item"><span class="closer"></span>s1</div> <div class="item"><span class="closer"></spanhow>s2</div> <div class="item"><span class="closer"></span>s3</div> </div> <div class="target"> <div class="empty"></div> <div class="empty"></div> <div class="empty"></div> <div class="empty"></div> <div class="empty"></div> </div> for sort of stuff need add width source. see http://jsfiddle.net/harendra/2phuw/1/ you need change css in following way. .source{ display:block; overflow:auto; width:200px; } .item{ float:left;

Rails - how to sort the results of a cascading collection select form -

i've gotten cascading collection_select form working want, want figure out how can sort updated results of children fields alphabetically. my custom actions in controller: def update_areas city_id = (params[:city_id].nil? || params[:city_id].empty?) ? 0 : params[:city_id].to_i # updates artists , songs based on genre selected if city_id == 0 @areas = [] @neighborhoods = [] else city = city.find(params[:city_id]) # map name , id use in our options_for_select @areas = city.areas.map{|a| [a.name, a.id]} @neighborhoods = neighborhood.where(:area_id => city.areas.each{|a| a.id}).map{|s| [s.name, s.id]} end @areas.insert(0, "select area") @neighborhoods.insert(0, "select neighborhood") end def update_neighborhoods # updates songs based on artist selected area = area.find(params[:area_id]) @neighborhoods = area.neighborhoods.map{|s| [s.name, s.id]}.insert(0, "select neighborhood")

android - PHP base64 how to turn into image for insertion into database -

okay i've got android app image php web service. i have decoded base64 string using base64_decode() . when execute sql query insert data database script inserts string \x5265736f75726365206964202333 . what want know how can modify code turn string image , insert postgresql database has utf8 encoding , bytea data column type store image. php script header('content-type: text/plain; charset=utf-8'); $conn = pg_connect("database_string"); /* data */ $name = $_post['name']; $s_name = pg_escape_string($name); $description = $_post['desc']; $s_desc = pg_escape_string($description); $latitude = $_post['lat']; $longitude = $_post['lng']; $project = $_post['project']; $encoded_photo = $_post['snap']; $photo = base64_decode($encoded_photo); header('content-type: image/jpeg; charset=utf-8'); $file = fopen('uploaded_image.jpg', 'wb'); fwrite($file, $photo); fclose($file); /* insert da

java - Fix Protocol Error : Field [5232] was not found in message -

i using quickfix , stunnel connect server rsa private key. when sending market data request(msgtype=v), getting following error 8=fix.4.49=14735=y34=55349=abcd52=20130513-03:23:23.24356=abcdefghi58=field [5232] not found in message.262=85ee75f8-ab5d-4aff-b87d-108b74d3281=010=53 i searched , found this link 5232 currency field so passed currency value 5232 below message message = new message(); ................ message.setfield(5232, new quickfix.field.currency("eur")); ................ session.sendtotarget(message, sessid); but when checked code of outgoing message, found field 5232 automatically converted '15=eur', , again giving error 'field [5232] not found in message' can point out missing here ? i bit confused field number regardless error making request must have group , currency field must in group. here example: marketdatarequest marketdatarequest = new marketdatarequest(); string reqid = symbol+new date().ge

php - SQL INSERT query being executed twice -

i'm @ wit's end here. i've tried in different browsers , still same trigger error message notice: duplicate entry key 'primary' however, it's still inserting database. think page simultaneously executing twice. code never reaches block stores session data. insight appreciated! <?php if($_post[submit]) { $username = ""; $password = ""; $hostname = ""; $dbname = ""; //connection database: $db = mysqli_connect($hostname, $username, $password, $dbname, '3306') or die("unable connect mysql"); $id = !empty($_post[id]) ? "'$_post[id]'" : "null"; $fname = !empty($_post[fname]) ? "'$_post[fname]'" : &quo

Error reporting tool for SQL Server database -

i looking open-source web reporting tool tsqlt errors on sql server database. when run unit tests tsqlt generates below mentioned information on table. want generate , display on web page graphical format. [testcase] [name] [tranname] [result] [msg] are there open-source tools plugin application , display results in graphical format. thanks viki i'm not aware of pre-built, however, tsqlt framework can output results table in xml using xmlresultformatter (i covered how in step 5 of this article database ci processes). output close xunit format, suggest @ adapting xsl nunit format display in web page. hope helps, dave.

c# - How to require custom attribute from base class? -

i have base class derived classes put attribute on top of class this: [myattribute("abc 123")] public class someclass : mybaseclass { public someclass() : base() { } } public class mybaseclass { public string propa { get; set; } public mybaseclass() { this.propa = //attribute value of derived } } how enforce derived classes need attribute, use attribute value in base constructor? maybe instead of using custom attribute use abstract class abstract property. using method ensure every non-abstract derived class implement property. simple example on msdn

wpf - Style breaks when x:Key is added -

under <window.resources> , have following style defined: <style targettype="textbox"> <setter property="height" value="22" /> <setter property="width" value="125" /> <setter property="horizontalalignment" value="left" /> <setter property="verticalalignment" value="top" /> <setter property="foreground" value="black" /> <setter property="background" value="whitesmoke" /> </style> it works fine until needed inherit style on style <style basedon="{staticresource textboxstyle}" targettype="{x:type passwordbox}"> which means need add x:key=textboxstyle text box style above. when this, styling text box breaks altogether. tried doing same button styling, , same thing happens, style break if add key it. the solution

Show Input Text After Choose Combobox -

i have question how show text field based on choose combobox. have code : <select name="comment"> <option value="">choose one</option> <option value="good">good</option> <option value="others">others</option> </select> if choose others, want text input show. how can ? can done without jquery ? using plain javascript , try this html portion <select name="comment" id="combo" onchange="check();"> <option value="">choose one</option> <option value="good">good</option> <option value="others">others</option> </select> <input type = "text" id ="dummytext" visible="false" style="visibility:hidden"/> javascript portion function check() { var el = document.getelementbyid("combo"); var str = el.options[el.select

Javascript: Using regEx to change more than one character or group of characters at a time -

i know how code simple regular expressions, question changing more 1 character or characters @ time - not more 1 instance of character or characters, more 1 match characters or characters separate values in 1 call replace. for instance, if want change newline characters <br> in text textarea, might code: var withoutnewlines = document.getelementbyid("tainput").value.replace(/\n/g, "<br>"); if want change spaces &nbsp;, i'd code: var withoutnewlines = document.getelementbyid("tainput").value.replace(/ /g, "&nbsp;"); if want change both in 1 statement, i'd code: var withoutnewlines = document.getelementbyid("tainput").value.replace(/\n/g, "<br>").replace(/ /g, "&nbsp;"); my question is: is there way code 1 regular expression used make both changes 1 call replace()? it's little unnecessary, try: var newstr = "some string".replace(/o|m/g,

Google Maps API v3 panning & compass control failure -

this map renders strange shred of white in place of panning/compass control (top left). disappears on mouse on , returns on mouse out. a screen shot available here: http://i.stack.imgur.com/52037.jpg any thoughts on why happening? grateful guidance. a.c. ( in context, http://www.whiskyfair.com.au/209/ ) i think it's street view control. put streetviewcontrol: false in config of map. see here more

delphi - Can't access printer Borland C++ 5 -

i've moved windows xp 32 bit windows 7 64 bit. can't access printer in borland c++ 5 ide. seems it's sort of privileges problem because if log in administrator problem goes away. have simple 1 line program shows issue printdialog1->execute() the dialog opens if press properties button nothing happens. if attempt change of printer properties, i.e. page orientation etc, message saying "operation not supported on selected printer" , several access violations. here's weird bit. if use program print , open printer properties, problem goes away in ide , doesn't return until restart ide. i've granted myself full access printers , have full access directory borland installed to, c:\borland. thanks in advance help. this happens when there no default printer assigned, or when there no printers installed. you've indicated works fine if print application first (which means current printer has been set), know have printer installed. seem

javascript - Is it possible to detect if 'capslock is on' in a click event in jquery? -

i know if possible detect state of caps lock key using jquery , without key press. let me more clear. have password field. when click on or when password field on focus, need display warning message if caps lock on (similar windows login). know method of comparing character codes, not need. this yii application. if have default function check caps lock state, please let me know. any highly appreciated..! thanks..! in javascript in browser, either have solution based on provided browser in standard api or don't. in case, there no direct access state of keyboard answer no : can't better displaying message when user hit key.

ruby - Source of the New and Create Methods in Rails ActiveRecord while using Associations -

i wondering source (i.e., defining class or module) of new , create methods while using associations in rails. for example, associations section of rails guides provides case: class customer < activerecord::base has_many :orders, :dependent => :destroy end class order < activerecord::base belongs_to :customer end and enters command in console: @order = @customer.orders.create(:order_date => time.now) (link rails guides section: http://guides.rubyonrails.org/association_basics.html ) but when type this: @customer.orders.method(:create) i error: undefined method `create' class `array' you should have @ collection_proxy.rb here - https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/collection_proxy.rb start seeing line 204 , adequately explains how rails magically comes out methods build , create in associations. they part of associations module , collectionproxy class. edit: of these d

logging - TTL elastic search not working -

i need put ttl each of logs exported logstash. i have created folder 'mappings' under config folder, under have folder _default, under have json file default .json, has: { "_default_" : { "_ttl" : { "enabled" : true, "default" : "10s" } } } i exporting logs elastic server logstash. config file is: input { stdin { type => "stdin-type" } } filter { grok { type => "stdin-type" pattern => "i %{username:username}" add_tag=>"{username}" } } output { stdout { debug => true debug_format => "json"} elasticsearch { } } i should expect logs deleted elastic search after 10 seconds, not case. logs persist. going wrong? totally stuck. need help. fine guys, got work. had change message %{data}err_system%{data} to message %{data}err_system.*

c# - Interaction between xaml and xaml.cs files within same namespace -

<window x:class="logf.circles" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="circles" height="426" width="581" name="cir"> <grid background="beige"> <grid.resources> <style x:key="myfirst"> <setter property="height" value="150" /> <setter property="horizontalalignment" value="left"/> <setter property="margin" value="1"/> <setter property="width" value="150" /> </style> </grid.resources> <ellipse style="{staticresource myfirst}" fill="red" name="ellipse1" stroke="black" verticalalignment="t

windows - How to add custom menu upon right click on file / folder programmatically in c++ / QT? -

Image
we have app syncs files , folder way dropbox does. c++ / qt based installer. we add custom menu in right click context menu of file or folder way dropbox in below screen shot. we targeting both windows & mac platforms. can suggest me how start it? on mac, you're going have problems adding general finder context menu has been deprecated. so, may thinking, if it's deprecated, how dropbox this? i've researched in past, believe use code injection inject running finder application's address space , objective-c feature known method swizzling change calling method 1 of own, located in injected code. this hardcore , low level, if you're going go on journey, can start looking library called mach_inject , googling it. source code can found here: - https://github.com/rentzsch/mach_inject however, aware there believe code-injection wrong , won't install dropbox or other software uses it. in addition, if you're planning on releasing product

java - How to get rid of wasted space in SWT ScrolledComposite when the scrollbars are not shown -

Image
i have horizontal scrolledcomposite holding 2 buttons (actually composite 2 buttons). space scroll bar allocated if scroll bars hidden. (they hidden, when horizontal space sufficient , scrolling not necessary.) how can rid of wasted space? in mean time have configured scrolled composite show scrollbars ( setalwaysshowscrollbars(true) ), rather prefer rid of wasted space. thank consideration. import org.eclipse.swt.swt; import org.eclipse.swt.custom.scrolledcomposite; import org.eclipse.swt.layout.filllayout; import org.eclipse.swt.layout.griddata; import org.eclipse.swt.layout.gridlayout; import org.eclipse.swt.widgets.button; import org.eclipse.swt.widgets.composite; import org.eclipse.swt.widgets.display; import org.eclipse.swt.widgets.shell; public class scrollbarspaceissue extends composite { public scrollbarspaceissue(final composite parent, final int style) { super(parent, style); setlayout(new gridlayout(1, false)); final scrol

iphone - How to remove bar chart's grayish flash effect in highcharts -

Image
i made bar charts using highcharts library. but when click graph anywhere, gray flash effect appears , goes away within fraction. want remove flash effect. ps : don't want disable interaction entire graph. please guide me same.

php - There are 3 tables users,winks and favourite -

there 3 table please @ structure users table ====================== id(users.id) |username | status ---------------------------------- 56 | mark | 1 ---------------------------------- 57 | john | 1 ---------------------------------- 58 | lina | 1 ---------------------------------- 59 | lara | 1 ---------------------------------- winks table ====================== wink_id | from_id(fk users.id) | to_id(fk user.id) | wink_flag -------------------------------------------------------------------------- 1 | 56 | 57 | 1 -------------------------------------------------------------------------- 2 | 56 | 58 | 1 -------------------------------------------------------------------------- favourite table ====================== fav_id | from_id(fk user.id) | to_id(fk user.id) | fav_flag -------------------------------------

memcached - Improving the performance of Jquery Autocomplete with Sphinx / Memcache....or? -

i have list of 43,000 uk locations in innodb table using populate jquery autocomplete box via remote json calls. at present i'm performing basic select * locations title 'lond%' query retrieve requests, while site still in development, results coming slow. i've implimented delay of 200ms between key presses , minimum of 4 chars before starts collecting results, may need re-think there 3 char uk locations , i'd quite display results immediately. an obvious improvement fulltext index 'title', rest of database innodb i'd rather not go backwards , convert table myisam. therefore i'm left other 2 tools @ disposal sphinx , memcached. sphinx - remember sphinx returns id's of matching results, i'd still need query mysql every user keypress triggers lookup. therefore i'm not sure how of improvement be? memcached - had considered loading 43,000 results memory , performing sort of array search (or memcache built-in search if has one?).

java - Upload file FTP server -

i stuck during connecting ftp server through apache ftp client. found lots of program out there not able connect ftp server through below code. ftpclient ftpclient = new ftpclient(); ftpclient.connect("169.144.76.33"); ftpclient.login("root", "re123set"); exception: java.net.connectexception: connection refused @ java.net.plainsocketimpl.socketconnect(native method) @ java.net.abstractplainsocketimpl.doconnect(abstractplainsocketimpl.java:327) @ java.net.abstractplainsocketimpl.connecttoaddress(abstractplainsocketimpl.java:193) @ java.net.abstractplainsocketimpl.connect(abstractplainsocketimpl.java:180) @ java.net.sockssocketimpl.connect(sockssocketimpl.java:384) @ java.net.socket.connect(socket.java:546) @ org.apache.commons.net.socketclient.connect(socketclient.java:176) @ org.apache.commons.net.socketclient.connect(socketclient.java:268) but whenever trying connect through file zilla ip,user name, password, port(w

R: How to add missing dates to a dataframe twofold and and give each a different value in other column? -

i have following dataframe part of larger one: [7080,] 20100303 3.669138e-01 0.000000000 [7081,] 20100303 4.347603e-01 0.000000000 [7082,] 20100305 4.252109e-01 0.000000000 [7083,] 20100306 3.865164e-01 0.000000000 [7084,] 20100307 2.799683e-01 0.000000000 [7085,] 20100307 3.478009e-01 0.000000000 [7086,] 20100309 3.381812e-01 0.000000000 as can see first column consists of dates of have 2 measurements , others have 1. dates missing. if date missing want create 2 different "measurements" particular date, 1 value "0" , 1 value "1" in second column (i want value "1" above "0"). value of third column has 99 (not na). result this: [7080,] 20100303 3.669138e-01 0.000000000 [7081,] 20100303 4.347603e-01 0.000000000 20100304 1 99 20100304 0 99 [7082,] 20100305 4.252109e-01 0.000000000 [7083,] 20100306 3.865164e-01 0.000000000 [7084,] 20100307 2.799683e-01 0.000000000 [7085,] 20100

plone - collective.data.examples custom field wont save data -

this continuation this question . have used collective.examples.userdata , added 'position' text field user registration form. problem when go /@@personal-information page, fill in field , hit 'save', shows field again , blank. don't appear able save information field. have tried running instance in foreground mode can't see outputted when trying save new information. i don't know if this'll when try make use of following tales statement: tal:define="membership context/portal_membership; info python:membership.getmemberinfo(user.getid());" and then: tal:replace="info/position" i following traceback: traceback (innermost last): module zpublisher.publish, line 126, in publish module zpublisher.mapply, line 77, in mapply module zpublisher.publish, line 46, in call_object module shared.dc.scripts.bindings, line 322, in __call__ module shared.dc.scripts.bindings, line 359, in _bindandexec module pro

objective c - Read from file.Plist Returns Null -

program creates multiple plist's paths different information. but 1 path not working. (i think "writetofile" problem) code: -(nsstring *) createpath:(nsstring *)withfilename { nsarray *paths =nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *path = [documentsdirectory stringbyappendingpathcomponent:withfilename]; return path; } path nslog = /var/mobile/applications/02cabc0a-6b5b-4097-a9d1-4336be8230b7/documents/messagesdb.plist & -(void) messagesdbflush { // save file persistency nsstring *messagesdb_path = [self createpath:_filemessagesdb]; [_messagesdb writetofile:messagesdb_path atomically:yes]; nsmutablearray *returnsinfo = [[nsmutablearray alloc ]initwithcontentsoffile:messagesdb_path]; nslog(@"returnsinfo : %@", returnsinfo); } "returnsinfo" array null :/ anyone please help? i once had

python - bottle gevent and threading: gevent is only usable from a single thread -

i have python bottle application, uses threads. due fact i'm using monkey.patch , threads blocking app execution (a dialog box fired thread blocking bottle routes responding client, until dismissed.) a little research here showed should use monkey patch without trying patch thread: # patch python's threads greenlets gevent import monkey monkey.patch_all(thread=false) this not block on minimal example wrote. but raises these errors on intensive use threads, methods threading.setevent() error get: c:\users\ieuser\downloadloft-localserver>python mainserver.py exception in thread thread-1: traceback (most recent call last): file "c:\program files\downloadloft\python27\lib\threading.py", line 551, in _ _bootstrap_inner self.run() file "c:\program files\downloadloft\python27\lib\threading.py", line 753, in r un self.finished.wait(self.interval) file "c:\program files\downloadloft\python27\lib\threading.py", line 403, in w ait sel

Hide/Unhide groups of cells in excel with Button -

i have group of cells b32 till r32 length , b32 b51 breadth. want keep block hidden @ start when sheet opened. have named block 'analysis'. there button in sheet. when button pressed, want unhide block. new excel vba. know syntax/code doing operation. thanks in advance. ananda you cant hide area mattcrum has mentioned. have 3 choices far concerned now, make sure have something(data - not empty cells) in range 32:51 , main sheet either called sheet1 or change sheet1 in code suit worksheets name 1) in vbe ( visual basic editor ) double click thisworkbook in project explorer , paste code private sub workbook_open() thisworkbook.sheets("sheet1").rows(32 & ":" & 51).hidden = true end sub right click on folder modules , insert new module , paste code sub unhide() thisworkbook.sheets("sheet1").rows(32 & ":" & 51).hidden = false end sub now, add button on spreadsheet, right click , as

Use of semantic vectors -

i want use semanticvectors api. new @ this. want make program takes documents , searches keywords , returns documents conceptually similar search keywords. want know if there document can function , functionality description , can learn or if there example so. i have checked https://code.google.com/p/semanticvectors/ , http://semanticvectors.googlecode.com/svn/javadoc/latest-stable/index.html couldn't understand anything. please me. thank you. it not clear want semanticvectors. here should start off with: https://code.google.com/p/semanticvectors/wiki/installationinstructions and specific questions, fruitful if ask on project's forum itself: https://groups.google.com/forum/?fromgroups#!forum/semanticvectors

php - passing data with cURL post, escaping characters? -

i have post data shown below, i'm trying send curl function, in turn sends data post form. but when run script, syntax error. believe it's being caused " . normally, escape these using \" or change them ' , think cause error when submitted form. how can handle this? {"potential":[{"id":"b-1_10732423478-6551232102-0-lm-0","marketid":"1.1012336578","selection":6350122,"size":2,"price":2.5,"asian":0,"categorytype":"e","version":2,"limit":0,"marketname":"drive 2013","markettype":"undifferentiated","eventid":"269256462","ordertype":"limit","fractional":{"numerator":null,"denominator":null},"runnerid":"1_105868-6552342-0","transactionid":null,"each":false,"runnerorder":1,"

ruby on rails - Complex slightly-nested form -

i'm trying make somewhat-complex somewhat-nest form. have (simplified) following: models/product.rb class product < activerecord::base attr_accessible :name has_many :colors end models/color.rb class color < activerecord::base attr_accessible :quantity belongs_to :product end views/admin/update_inventories.html.erb <% @products.each |p| %> <%= p.name %> <% p.colors.each |c| %> <%= c.name %>: <%= form_for :color, :url => color_update_path(:id => v.id) |f| %> <%= f.number_field :quantity, :value => c.quantity, :min => 0 %> <%= submit_tag "update" %> <% end %> <% end %> <% end %> the problem creates frightning amount of forms , have update 1 suit 1 suit. want view: view/admin/update_inventories_revised.html.erb <%= form_for :inventory, :url => custom_update_path |f| %> <% @products.each |p| %> <%= p.name %>

jQuery issue with chaining isNumeric -

i've got simple conditional checks if id equal , checks if number. i'm using isnumeric combination of .length. reason isnumeric part not working can enter string of letters , doesn't validate. ideas? var $this = $(this); if(this.id == "username" && $.isnumeric($this.val()).length < 10 ){ //do } the reason you're having problems this: $.isnumeric( $this.val() ) returns true or false , , checking length of boolean makes no sense, true or false never have length on 10, booleans does'nt have length, , returns "undefined" ? maybe meant : if ( this.id == "username" && $.isnumeric( $this.val() ) && $this.val().length < 10 ){ // if value numeric, , string length under 10 }

javascript - Line Breaks Inside Jade Templates -

i looking around solution include line break inside title. normal fixes include actual line break inside code... <div title="ron swanson"></div> or use &#013; in place of new line, so... <div title="ron &#013;swanson"></div> these solutions work fine, since i'm using jade templating engine, can't include line break inside code... .title(title="ron swanson") --or-- .title(title="ron\ swanson") without \ throws syntax error, , doesn't insert line break. `.title(title="ron swanson") prints out characters literally. what correct way of including line breaks in jade templates? i found out can use \n represent new line (just javascript string). doing work... .title(title="ron\nswanson")

java - Loosing current session when we click on hyper links -

when click on hyper link request goes tomcat server , renders file content in tab. but, session getting timed out when operation in first tab. can provide solution please? if using sessions need ensure request goes same tomcat server because session stored in memory on server. load balancer should have configuration allow setting sticky sessions based on cookie value.

Using Google Apps Sync with Outlook 2007/2010 and iPads/iPhones -

a little background: use google apps business , having issues users inadvertently becoming meeting owners or moving meeting locations or times on accident. every user in company admin on own machine. users encouraged bring own devices there's no guarantee set unless ask desk help. my supervisor asking me post , guys: there other testing should doing? other ideas? has else using google calendars had attendees inadvertently move meeting times or locations when not meeting owner? test setup: types of setup pcs or ipads: outlook 2007 google apps sync on pc, outlook 2010 google apps sync on pc, google calendar in browser on pc, google calendar in ipad set google (this setup recommended , supported google), google calendar in ipad set exchange (this set neither recommended nor supported google) test cases: machine b accept machine b decline machine b, change meeting time, accept machine b, b change meeting time, accept machine b, change meeting time, decline machine b, b c

c# - MVC3 deploy to a directory, url issue -

i have mvc3 web application delopyed directory of website. address of application seems http://wwww.xx.com/aopo/ . aopo name of directory. after deployement find url in js file not work more. because had write js code hard code url, $.ajax({url:"/employee/getemployee"}) in case request sent http://wwww.xx.com/employee/getemployee instead of http://wwww.xx.com/aopo/employee/getemployee , , 404 returned. there lots of code in js that. don't want modify js. there simple approach make work? can rewrite request in global.asax.cs? i believe you'll need change url references this: $.ajax({url:"@url.action("getemplotee","employee")"}) if script file can write correct url element on page , read that: <div id='main' data-url='@url.action("getemplotee","employee")' /> then in script: $.ajax({url:$('#main').data('url')}) rgarding: there lots of code in js that.

html5 - Can the code in a .crx chrome app have write access to the files within itself (the crx)? -

i have crx has number of files want able change on time. example, might have structure: index.html js/code.js images/someimage.png i want able use ajax (or jsonp) download new image , overwrite image/someimage.png (after crx has been installed chrome). possible? no, can not modify application / extension data files directly. but, can store downloaded image chrome.storage , chrome.filesystem , or chrome.syncfilesystem . @ run time can check see if downloaded image there , swap out image reference. e.g. use dataurl or blob.

c# - Get public ip of router -

i there way determine ip address without resorting remote server validate web request. seems if can trace-route ip's in chain... unsure how validate that. if it's not possible, make sense not be. makes sense want multiple remote endpoints validate ip, in case 1 compromised. traceroute won't help. you'd need traceroute from somewhere out there on internet toward public ip address of nat behind. there no general way ask nat router public ip address use connections originate. in general there more 1 (e.g. load balanced wan connections).

Why does java have Type when it already has Object? -

i hoping tell me why java has java.lang.reflect.type , when inherits object ? could please give example of case need use type , not object ? object base class java classes. type tag interface classes represent types. introduced in java 1.5 because prior java 1.5 there no classes represent java type except java.lang.class . when generics introduced there need create general abstraction common class , generic array etc. defined interface type .

vim - gVim ProportinalResize error -

Image
i have proportionalresize plugin installed, throws following error message (shown below) everytime resize whole gui-window after performing window split. realize ingo karkat plugin makes use of ingo-library (i use l9 func library). lib installed error message changes from to . there comment in this , this file stale window dimensions (comment on revision 1.00.003 ). can't understand talks about. stumbled upon it. if need vimrc, let me know. plugin author here. concur commenters issues these best first addressed directly plugin's author (in case, via email address found in documentation , scripts, since don't use issue tracker these small plugins yet), not via stack overflow. because there no vimresizedpre event, plugin periodically (on cursorhold ) records current dimensions able calculate difference. when there's no current record, you'll stale window dimensions record error. avoid that, try waiting 4 seconds before attempting resize.

C - Linux - kernel module - TCP header -

i'm trying create linux kernel module, inspect incoming packets. @ moment, i'm in process of extracting tcp header of packet , reading source , destination port -> i'm getting incorrect values. have hook function: unsigned int hook_func(unsigned int hooknum, struct sk_buff *skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { struct iphdr *ipp = (struct iphdr *)skb_network_header(skb); struct tcphdr *hdr; /* using filter data machine */ unsigned long ok_ip = 2396891328; /* problem, empty network packet. stop now. */ if (!skb) return nf_accept; /* track packets coming 1 ip */ if (ipp->saddr != ok_ip) return nf_accept; /* incomming packet tcp */ if (ipp->protocol == ipproto_tcp) { hdr = (struct tcphdr *) skb_transport_header(skb); printk(" tcp ports: source: %d, dest:

jquery - Load data from text file with ajax/javascript into html problems -

i want load data text file in same folder html file on computer won't work. in process of learning ajax , put little test myself test.html , text file test.txt . advice please, appreciated. <!doctype html> <html> <head> <title>test</title> <script> function loaddata() { var test; test=new xmlhttprequest(); test.onreadystatechange=function() { if (test.readystate==4 && test.status==200) { document.getelementbyid("test").innerhtml=test.responsetext; } } test.open("get","test.txt",true); test.send(); } </script> </head> <body> <div id="test"></div> <button type="button" onclick="loaddata()">get data</button> </body> </html> when press button, nothing happens. on site saw similar example data text file displayed above button. the problem you're accessing files directly on l

swing - Communication between GUI Java -

i have 3 classes create objects jpanels ie myobject extends jpanel. call 3 panels in main method call. myobject1 mo1 = new myobject1(); // contains textfield , button myobject2 mo2 = new myobject2(); // contains textarea holding long paragraph myobject3 mo3 = new myobject3(); how can mo1 call methods on mo2 changing text of text area? thanks suggestions guys! gonna go ahead , accept first answer. solved problem. update 1 of these panels combination of 2 panels in program, hindering ability pass instance of object class. removing panel class , creating jpanel in main adding 2 panels new jpanel able pass instances of classes each constructor. so in turn solution jpanel panelholder = new jpanel(); // create panel in main instead of new class myobject2 mo2 = new myobject2(); // contains textarea holding long paragrah myobject1 mo1 = new myobject1(mo2); // contains textfield , button panelholder.add(mo1); panelholder.add(mo2); myobject3 mo3 = new myobject3(); and in mo

video - WebRTC - flash client -

i have website 1 user may chat another, using webcam, via webrtc. chrome supports webrtc, firefox's nightly build. however, visitors use internet explorer, , unable use chat. currently, use flash enable 1 one chat. microsoft not bringing webrtc ie. i ditch flash possible, , wondered if there way ie users use flash client, behaved webrtc client, enabling them talk other website visitors use chrome. i can't see online such client. realise not elegant patch, short of microsoft changing mind webrtc, can't see other option. does such thing exist? if not, there technical reason why shouldn't? it's not elegant solution, webrtc works google chrome frame in ie. you can see example of in action @ https://gittogether.com .

Conditional statements in HTML to rule out non-mobile devices -

well i've made responsive website handles in mobile devices. there phonenumbers on website cliƫnt clickable on phone visitor can call directly. found making link of phonenumbers works so: <a href="tel:003164646464">make call</a> this triggers mobilephones call number. triggers webbrowser on other device follow link, results in "page can't found" i'm looking anwser tackle problem. i've been searching while i'm getting bit tired , frustrated. think i've come solution don't excactly know how put in html. there several ways conditional comment browsers in html. if link part , rule out: <!--[if **none mobile** webrowsers: don't read:]><a href="tel:003164646464">003164646464</a> and mobile browsers read link. seems me, easy way this, wrong... hope can give me pointers, appreciate idea's , help! thanks! there no easy way achieve this. can use different approaches depending

jquery - Find prev element source -

i know code below doesn't work, possible call "src" prev, <img> with little tweak jquery below? html: <li> <img src="assets/themes/abstract/1_tbn.png" class="theme_tbn" /> <label class="theme_label">diffuse green</label> <span> <button class="btn-publish choosetheme">choose theme</button> </span> </li> jquery: $(".choosetheme").click(function () { var src = $(".choosetheme").find("img"); alert(src.text()); }); $(".choosetheme").click(function () { var src = $(this).closest('li').find("img").attr('src'); alert(src); });