Posts

Showing posts from June, 2012

ruby - Devise: Is it possible to NOT send a confirmation email in specific cases ? (even when confirmable is active) -

here situation, use devise allow users create account on site , manage authentication. during registration process allow customers change options, leading different account being created still based on same core user resource. choose not send confirmation email of account types. don't care if account not confirmed , user cannot log in, that's ok, no pb that. how go doing ? thanks, alex actually it's quite easy once dig little deeper. override 1 method in user model (or whatever using): # callback overwrite if confirmation required or not. def confirmation_required? !confirmed? end put conditions , job's done ! alex

java - non-static method encode(byte[]) cannot be referenced from a static context -

package com.cordys.report; import java.io.fileinputstream; import org.apache.commons.codec.binary.base64; public class encode { public static string encodefilestream(string filepath) //file path ex : c:\program files\cordys\web\reports\i0001180.pdf { try { fileinputstream fin = new fileinputstream("e:/css document/test.pdf"); stringbuffer sb=new stringbuffer(); int linelength = 72; byte[] buf = new byte[linelength/4*3]; while (true) { int len = fin.read(buf); if (len <= 0) { break; } sb.append(base64.encode(buf)); return sb.tostring(); } } catch(exception e) { return e.getmessage(); } } } as seen @ http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/base64.html try base64.encodebase64() instead.

c# - How to get Telerik's RadEditor's Spell checker to start automatically when incorrect word is typed? -

currently have click spell check button on radeditor's toolbar see word suggestions. there way that? did find way run spell checker on submit button click how want? have gone through forums in vain. need please. telerik people have not replied. it's been 3 days asking here. familiar telerik controls please me out. edit: in here familiar telerik controls please me out. i don't think there way spellchecker check each word right after type - have click spell tool (or can assign keyboard shortcut it). way - modern browsers except ie offer built-in spellcheck support available inside radeditor - can try opening radeditor page firefox, chrome, etc. - radeditor demo . start typing , incorrect words marked.

python - Delete newline / return carriage in file output -

i have wordlist contains returns separate each new letter. there way programatically delete each of these returns using file i/o in python? edit: know how manipulate strings delete returns. want physically edit file returns deleted. i'm looking this: wfile = open("wordlist.txt", "r+") line in wfile: if len(line) == 0: # note, following not real... i'm aiming achieve. wfile.delete(line) >>> string = "testing\n" >>> string 'testing\n' >>> string = string[:-1] >>> string 'testing' this says "chop off last thing in string" : "slice" operator. idea read on how works very useful. edit i read updated question. think understand now. have file, this: aqua:test$ cat wordlist.txt testing wordlist returns between lines and want rid of empty lines. instead of modifying file while you're reading it, create new file c...

How to resize or remove one object from canvas using Javascript? -

is there change remove or resize selected object canvas without changing other design. for example:- drawn circles (just circle1, circle2, circle3) . circle1 bottom of other 2 circles. want remove circle2 or re-size. should not effect other circles. and there change without using clear canavas method. it should work powerpoint design draw , resize , delete. i not think possible, canvas bitmap object far know , draw on updates image. if use circle object should svg citation: "once rectangle drawn, fact drawn forgotten system. if position changed, entire scene need redrawn, including objects might have been covered rectangle."

google api - Geocoder is not working in android -

i working on program takes address input user , navigates google map particular location,i have used getfromlocationname() method of geocoder not getting output, little afraid because not able understand meaning of below phrase given in android site "the geocoder class requires backend service not included in core android framework. geocoder query methods return empty list if there no backend service in platform. use ispresent() method determine" if end service not present how it.. but when try use ispresent() method giving me compilation error, plz suggest me, response appreciated

java - how to run selenium rc test case in Internet Explorer -

my selenium rc java code running on firefox. can tell me how run same test case on internet explorer? change browser start command string pass defaultselenium factory. *iehta or *iexplore depending on selenium version. new defaultselenium("localhost", 4444, "*iexplore", "http://www.google.com/"); check out docs more info. --sai

android - Grabbing information from an SQLite Database: Filling in already filled fields and updating row -

checked lots of other questions , websites, couldn't find looking for. i'm making contact list practice... i'm trying give user ability update contact's info. when click on contact, fields should filled in are, not blank hint. problem fields aren't populated, else works fine fields have hints instead of text user filled in contact upon creation. here code: contaclist.class's code... @override protected void onlistitemclick(listview l, view v, int position, long id) { super.onlistitemclick(l, v, position, id); mdbadapter = new tagdbadapter(this); mdbadapter.open(); cursor cursor = mcursor; cursor.movetoposition(position); intent intent = new intent(this, addeditcontact.class); intent.putextra(tagdbadapter.key_rowid, id); startactivityforresult(intent, activity_edit); } code addeditcontact.class @override public void oncreate(bundle savedinstancestate) { super.oncreate(...

java - How to use Session on Google app engine -

i not know how use session on google app engine. please tell me. thanks. are talking request.getsession() in java servlet api? have enable sessions before work. see this question more info on using httpsession. way, should tag questions app engine variant you're using (java or python).

Conventions on naming Eclipse projects? -

are there naming conventions (or @ least suggestions) on how name eclipse project? using acronyms idea? the eclipse foundation have suggestions . instead org.eclipse.... user own domain! edit : have no documented best practices. use project name name of main package in project. ancronyms ok if have long names. example: java developement tools -> jdt for additional improvements see eclipse project name policy !

Calculate date of birth from age at specific date [MySQL or Perl] -

apologies if simple question interested in trying reach accurate answer , not "rounded" answer. my problem is: know 27.12 on 18th of march 2008 (random example). how can calculate, nearest approximation, date of birth. age provided real number 2 decimal points. eumiro's answer trick; following, using time::piece module (bundled perl since 5.10) perhaps more maintainable. use strict; use warnings; use 5.010; use time::piece; use time::seconds; ($date, $age) = ('2008-03-18', 27.12); $birthday = time::piece->strptime($date, '%y-%m-%d') - $age*one_year; $birthday->ymd(); this within few days of actual birthday, due lack of accuracy (1/100 year) in age.

http - Stange records in access.log apache 2 -

today notice stange records in access file of apache 2 webserver ::1 - - [25/jan/2011:14:13:31 +0200] "options * http/1.0" 200 - does know these lines means ? yes, it's options request , feature used http clients query server: the options method represents request information communication options available on request/response chain identified request-uri. method allows client determine options and/or requirements associated resource, or capabilities of server, without implying resource action or initiating resource retrieval. it's commonly used load balancers, firewalls , proxies check on status of http server, without requesting resource. the ::1 @ start ipv6 address.

Problem in File Downloading from server in android application -

i using code of snippet download mp4 files server. file download properly, sometime downloading process stops downloading automatically. progress bar stop incrementing. there kernel process stop download. //+++++++++= function call ++++++++++++++++ download_file_name = "demo.mp4"; graburl("mp4 file server url"); //+++++++++++++++++++++++++++++++++++++++++ public void graburl(string url) { new graburl().execute(url); } private class graburl extends asynctask<string, void, void> { private final httpclient client = new defaulthttpclient(); private string content; private string error = null; private progressdialog dialog = new progressdialog(slideshow.this); protected void onpreexecute() { showdialog(dialog_progress); mprogressdialog.setprogress(0); } protected v...

Magento backend - make the price field readonly -

i want make price text field in magento backend readonly because use custom attributes fix prices. how can ? thanks lot. since make attributes silly, don't believe there simple mechanism this. 1 easy hack use add js file page disables price field specifically. use xml layout files default adminhtml package add js file. hope helps! thanks, joe

sorting - In-place radix sort in D programming language -

i'm trying in-place radix sort example in-place radix sort working. far have this: import std.random; void swap(ref string i,ref string j) { string tmp = i; = j; j = tmp; } void radixsort(ref string[] seqs, size_t base = 0) { if(seqs.length == 0) return; size_t tpos = seqs.length, apos = 0; size_t = 0; while(i < tpos) { if(seqs[i][base] == 'a') { swap(seqs[i], seqs[apos++]); i++; } else if(seqs[i][base] == 't') { swap(seqs[i], seqs[--tpos]); } else i++; } = apos; size_t cpos = apos; while(i < tpos) { if(seqs[i][base] == 'c') { swap(seqs[i], seqs[cpos++]); } i++; } if(base < seqs[0].length - 1) { radixsort(seqs[0..apos], base + 1); radixsort(seqs[apos..cpos], base + 1); radixsort(seqs[cpos..tpos], base + 1); radixsort(seqs[tpos..seqs.length], base + ...

sql server - MS SQL compare dates? -

i have 2 dates (datetimes): date1 = 2010-12-31 15:13:48.593 date2 = 2010-12-31 00:00:00.000 its same day, different times. comparing date1 , date2 using <= doesnt work because of date1 time. date1 <= date2 wrong, should true. can compare them looking @ year, month , day same? sql server 2008. thanks :) select case when cast(date1 date) <= cast(date2 date) ... should need. test case with dates(date1, date2, date3, date4) (select cast('20101231 15:13:48.593' datetime), cast('20101231 00:00:00.000' datetime), cast('20101231 15:13:48.593' datetime), cast('20101231 00:00:00.000' datetime)) select case when cast(date1 date) <= cast(date2 date) 'y' else 'n' end comparison_with_cast, case when date3 <= date4 'y' else 'n' end comparison_without_cast dates returns comparison_wi...

content management system - Trying to evaluate using Alfresco as a document portal -

following suggestion in previous question asked i'm giving alfresco go. think fit needs i've still got few doubts... i'm looking document portal such users can't access other users' folders , users not have install view download documents. i think may able in alfresco creating private sites each set of customer's documents , adding users respective sites. how software intended used or wind problems? thanks in advance, rob you approach - creating private site , adding users respective sites - works. users not document library preview in browser, other goodies come alfresco share site e.g. configurable dashboard latest document updates etc. in document library, can set permissions on folders can organize access control different users @ level well. if you're dealing 100's of users / sites, standard hosting server fine. if you're talking 1000's of users / sites need more hardware keep things fast. alfresco supports webdav,...

Post image to Facebook in JSON format in Android -

i want post image facebook in having json string,i have included static image in string, , works fine, if want add dynamic image can if?? here code: parameters.putstring( "attachment", "{\"name\":\"" + b.getstring("title") + "\",\"href\":\"" + b.getstring("cmpweb") + "\",\"description\":\"" + desc + "\",\"media\":[{\"type\":\"image\",\"src\":\"http://184.106.227.45/quaddeals/img/small_thumb/deal/692.e6b86fa39f3ba25e29f0351140b57a94.jpg\",\"href\":\"http://alumni.brown.edu/\"}]}"); this value http://184.106.227.45/quaddeals/img/small_thumb/deal/692.e6b86fa39f3ba25e29f0351140b57a94.jpg \" static value want include dynamic content got previous page using intent,say(b.getstring("url")).. want show web link if user click link should shows web view ist ...

jquery - javascript: time until page load -

i writing animation javascript , want print user loading time until images loaded. images set in html as: <img src="" /> are there javascript code know when page loaded? i.e time until onload() event called you might able @ bottom of page <span id="imgsmsg"></span> <script type="text/javascript"> var imgs = document.images; var len = imgs.length; var percent = 100; var count=0; var messagecontainer = document.getelementbyid("imgsmsg"); (var i=0;i<len;i++) { imgs[i].onload=function() { count++; messagecontainer = (percent - math.floor((100/len)*count))+"% loaded"; // hope math correct ;) } } </script> </body>

java - Thread stop and synchronization -

i'm reading book says not use such code: private volatile thread mythread; .... mythread.stop(); instead 1 should use: if (mythread != null ) { thread dummy = mythread; mythread = null; dummy.interrupt(); } unfortunately subject not elaborated further... explain me this? everyone has given great information on why not call thread.stop(). sergey's comment fixed incorrect information gave interrupt() handling. prefer use signal flag, in lewap's answer. sergey's said, interrupt() purpose of waking thread that's in blocked operation. if thread doesn't call blocking operations, interrupt() won't terminate thread. thread though can call isinterrupted() see if interrupt has been called (a signal flag, basically). going book's example, don't it. if (mythread != null ) { thread dummy = mythread; mythread = null; dummy.interrupt(); } there's no reason copy dummy variable in example. right confused. t...

nhibernate architecture -

hello want create first nhibernate projet. migration winform project associated old dataacess no strong orm mapping. project quite large i'd have architecture beginning. i have layer : repository : create session nhibernate model : bean object, consists of getter / setter properties same name in database but i'll need advices, how handle operations ? if want create item should access directly nhibernate code ? or should create business logic layer ? basically found simple architecture business layer. http://www.codeproject.com/kb/architecture/nhibernatearchitecture.aspx feeling ? another question, program strong validation (glasses domain), should validation ? in winform project or in business layer ? it's hard , give useful advices without seeing project , actual problems. client-server architecture instance? mean "quite large"? there many different projects have rules fit all. generally: in of cases, useful have business layer. v...

Ruby's File.open and the need for f.close -

it's common knowledge in programming languages flow working files open-use-close. yet saw many times in ruby codes unmatched file.open calls, , found this gem of knowledge in ruby docs: i/o streams automatically closed when claimed garbage collector. darkredandyellow friendly irc take on issue: [17:12] yes, , also, number of file descriptors limited os [17:29] assume can run out of available file descriptors before garbage collector cleans up. in case, might want use close them yourself. "claimed garbage collector." means gc acts @ point in future. , it's expensive. lot of reasons explicitly closing files. do need explicitly close if yes why gc autoclose ? if not why option? i saw many times in ruby codes unmatched file.open calls can give example? ever see in code written newbies lack "common knowledge in programming languages flow working files open-use-close". experienced rubyists either explicitly close files, ...

c# - Checking for Null in Constructor -

i'm trying figure out best practices reusable code debugged. have ran common practice among developers don't quite understand yet. public myconstructor(object myobject) { if (myobject == null) throw new argumentnullexception("myobject null."); _myobject = myobject; } it seems unnecessary check. think it's because don't understand benefits of doing check are. seems null reference exception thrown anyway? wrong, hear thoughts on it. thank you. to compiler, null legitimate constructor argument. your class might able handle null value myobject . if can't - if class break when myobject null - checking in constructor allows fail fast .

testing - Geb $ function not found when using Cucumber via Cuke4Duke -

i'm using cuke4duke run cucumber tests. i'm using geb ( geb manual ) control browser. does know how configure cucumber/geb $ function ( geb $ function ) available cucumber tests? browser.$() seems work fine. nice not have type browser though.

Regular Expression for percents (with % sign) in ASP.Net RegEx Validator -

i need regex asp.net (4) regex validation control. needs regex validator support other dynamic behaviors outside scope of post.. i using following, fails if user enters % sign following number (which req of spec): ^(100(?:\.0{1,2})?|0*?\.\d{1,2}|\d{1,2}(?:\.\d{1,2})?)$ i tried adding atomic group of ^(?>%?) @ end, no luck, after reading excellent post regular expression greedy match not working expected does have ideas? many thanks, -jay try this ^(100(?:.0{1,2})?%?|0*?.\d{1,2}%?|\d{1,2}(?:.\d{1,2})?%?)$

ios - How to change the App ID associated with my (Xcode managed) Team Provisioning Profile -

i struggle codesigning work. i'm trying generic provisioning profile work apps during development. they're failing codesign, install on phone. go figure. i've created app id called ##########.mydomainname.* , associated development certificate, when team provisioning profile: * generated, uses app id made when first signed on year ago. don't know if problem, want try associating team provisioning profile: * ##########.mydomainname.* app id. i'm sick of fiddling provisioning - work, it's never same recipe. can somehow edit app id used in profile? update: marking question answered, looks answer can't i'm asking. you can't edit exisiting appid's, can associate existing provisioning profile new appid or create new one.

iphone - What is an appropriate PDF page size (dpi) for iPad? -

in case of drawing pdf quartz , supporting enlarging (using tilted layer), appropriate pdf page size (dpi) ipad? currently, i'm drawing 3 viewes (previous, current, next) on scrollview pdf file. when scrollview scrolled , current page changed, old previous or next view removed , new or previous view created , added. 7,8,9 - (go next page) -> 8,9,10 in above situation, 100dpi pdf ok. pdfs on 150dpi encounter crash (memory problem). in case of 150dpi, first 3 pages (previous, current, next) created , drawn app encounters crash after turning on pages 3 or 4 times. please let me know size (dpi) if made ipad apps viewing pdfs. as you've found out, depends on content. after trial , error, settled on around 100dpi. quite visual content - text content imagery go lot higher. if you're having memory issues @ 150dpi , 100 works fine, i'd stick @ 100.

java - Struts2 + Json Serialization of items -

i have following classes: public class student { private long id ; private string firstname; private string lastname; private set<enrollment> enroll = new hashset<enrollment>(); //setters , getters } public class enrollment { private student student; private course course; long enrollid; //setters , getters } i have struts2 controller , to return serialized instance of class student only. @parentpackage("json-default") public class jsonaction extends actionsupport{ private student student; @autowired dbservice dbservice; public string populate(){ return "populate"; } @action(value="/getjson", results = { @result(name="success", type="json")}) public string test(){ student = dbservice.getsudent(new long(1)); return "success"; } @json(name="student") public student getstudent() { return student; } public void setstudent(student student) { ...

web applications - Technologies allowing to store user data on server as well as on user's PC? -

let me first better explain context. application should have following characteristics: read-only shared data found on database server on internet. (quite big amount of shared data.) the application should distributed in java-web-start-like manner, or web application. (the goal simplify distribution of main package , updates. solutions lowering server load , giving better responsiveness end user preferred.) it must possible store user specific data on server, on user's pc, or on both. (the reason users not willing risk having information out of pc, of them share parts of or make backups.) i'm not knowledgeable in web application programming. technology know allow java web start. removes load server computations done on user side, allows read/write on user's pc (given access) , accessing centralized database not problem it. i know if there other technologies allow development of such application , not require traditional local installation. thank much, mj ...

Getting specific data from list of dictionaries in Python using dot notation -

i have list of dictionaries , strings so: listdict = [{'id':1,'other':2}, {'id':3,'other':4}, {'name':'some name','other':6}, 'some string'] i want list of ids (or other attributes) dictionaries via dot operator. so, given list list: listdict.id [1,3] listdict.other [2,4,6] listdict.name ['some name'] thanks python doesn't work way. you'd have redefine listdict . built-in list type doesn't support such access. simpler way new lists this: >>> ids = [d['id'] d in listdict if isinstance(d, dict) , 'id' in d] >>> ids [1, 3] p.s. data structure seems awfully heterogeneous. if explain you're trying do, better solution can found.

java - InteliJ 10 probelm with JUNIT custom runner -

i have custom runner of junit. runner run few tests. problem parent object of test colored incorrectly. the correct behavior mark entire test red in case of 1 of tests failed, intelij 10 mark test success/fail based on last test result. this work ok intelij 9, have idea how solve this? thanks report, issue has been fixed. find fix in next idea update (10.0.2) when it's available.

How to search Keywords like IN, OR, AND in a column with FullText Index in MSSQL Server 2008 -

i want search keywords in, or, etc table fulltext index this: select * table1 contains(countrycode, 'in or de or gb') but query returning rows "de" or "gb" only, not "in". how can solved? probably because in , or keywords on sql.

ruby on rails - heroku-like workflow on personal server -

i'm trying set server pure-git workflow similar heroku . don't need setting git, informative purposes, i'm using gitolite . i'd (somehow) write custom hooks in operating system (ubuntu) of system that, when receives push on particular branch, performs operators heroku (starting rack, mongrel, apache (for static serving pages in case), etc. can point me towards resource or @ least started? google search didn't seem help... it sounds want execute arbitrary functionality @ point in git workflow. git hooks way go. if in git repo (inside .git folder), you'll see hooks folder. inside there number of example hook files different names. based on explanation above, want edit post-receive hook file, since called after new ref has been updated in remote repo (resulting push local one). more info, read the official documentation on hooks or read perhaps more approachable explanation . you can put shell commands want in hook file. change filename post...

iis - Deploying WCF Service with both http and https bindings/endpoints -

i've written wcf web service consumption silverlight app. initially, service required basic http binding. need able deploy service use under both http , https. i've found settings web.config allow me follows: <system.servicemodel> <behaviors> <endpointbehaviors> <behavior name="silverlightfaultbehavior"> <silverlightfaults /> </behavior> </endpointbehaviors> <servicebehaviors> <behavior name="cxtmappingwebservice.cxtmappingwebservicebehavior"> <servicemetadata httpgetenabled="true" httpsgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="true" /> </behavior> </servicebehaviors> </behaviors> <bindings> <basichttpbinding> <binding name="securehttpbinding"> <security mode="transport" /> ...

.net - New message pop up window on background c# -

i need pop window displayed on bottom right side of screen. it's supposed pop when new message received within software. how can program it? create new form , use it? how can program run on background without interrupting other user actions? thanks. check out notifyicon.showballoontip . , here's example. basically, add notifiyicon form, , (from msdn page linked above): void form1_doubleclick(object sender, eventargs e) { notifyicon1.visible = true; notifyicon1.showballoontip(20000, "information", "this text", tooltipicon.info ); }

c# - Is this Method Thread-Safe? -

can please tell me if following method thread safe. also, please assume call _cache.getorcreate(...) thread-safe. method place in application creates or updates region (dictionary). class containing method singleton, multiple threads access it. public ienumerable<string> getreportlookupitems<t>(string cachekey, func<ienumerable<string>> factory) { dictionary<string, ienumerable<string>> region = _cache.getorcreate("cache-region:lookupitems", () => new dictionary<string, ienumerable<string>>()); ienumerable<string> items; if (!region.trygetvalue(cachekey, out items)) { region[cachekey] = items = factory(); } return items; } no. it's not thread safe. you're using dictionary<t,u> here, , changing contents. since dictionary<t,u> not thread-safe, calls trygetvalue , setting dictionary key not thread safe....

vector graphics - Where can I find a Javascript drawing canvas? -

i want build drawing program in js. (jquery preferred not mandatory). anyway, vision big, blank, white canvas simple grid. user drag "layers" grid (such icons, pictures, etc). also, support drawing curves, lines, boxes, etc. think of adobe illustrator simpler. honestly, used database diagrams more art (unless database diagrams art you...lol) is there out there that? thanks i'm sorry inform you won't first idea. check out these - diagramo.com (html5/canvas) - lucidchart.com (html5/canvas) - gliffy.com (flash) there few more in wild, though new addition competition!

asp.net - How can I have a column in a GridView computed on the fly? -

i have following gridview: <asp:gridview id="gv" autogeneratecolumns="false" runat="server"> <columns> <asp:boundfield datafield="productname" headertext="item" /> <asp:boundfield datafield="unitcost" headertext="cost" dataformatstring="{0:c}" /> <asp:boundfield datafield="originalcount" itemstyle-horizontalalign="center" headertext="old count" /> <asp:templatefield headertext="new count" itemstyle-horizontalalign="center" > <itemtemplate> <asp:textbox id="newcount" width="20" runat="server" /> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> and want add final 'total' column calculat...

entity framework - Using reflection to obtain select fields in a linq query -

i using linq queries , able list of properties want returned in "select" portion using reflection. i've tried following no avail: string[] paramlist = new[]{"appid","name"}; var query = entity in _ctx.app select new {entity.gettype().getproperties().where(prop=>paramlist.contains(prop.name) )}; what missing here? when working reflection inside ef query need write expression yourself. @ these existing question more information help linq , generics. using getvalue inside query how reflect on t build expression tree query? iqueryable<> dynamic ordering/filtering getvalue fails the problem not linq itself, because query parsed expression tree entity framework doesn't understand.

linux - How to specify the bash environment to use the Numeric module for Python? -

i trying manually install (now deprecated need it) numeric module python. use mandriva 2010. have downloaded numeric 24.2, used: python setup.py build python setup.py install --prefix=/other/directory so now, in /other/directory, have following directories: ./include/python2.6/numeric/ ./lib/python2.6/site-packages/numeric/ all need configure correctly pythonpath and/or ld_library_path make find numeric module. problem can't figure it. have tried common values, have received same negative answer: import numeric traceback (most recent call last): file "<stdin>", line 1, in <module> importerror: no module named numeric what correct parameters? missing something? $pythonpath should include entry /other/directory/lib/python2.6/site-packages , , if native library installed in /other/directory/lib , $ld_library_path should include /other/directory/lib .

osx - How to bind numeric keypad keys in TextMate? -

i use textmate on desktop mac full (old-style) macintosh keyboard full numeric keypad. i'd able bind menu item keys, macro key triggers , other actions of numeric keypad keys. i understand can cocoa (?) text editing commands in ~/library/keybindings/defaultkeybinding.dict file, macros textmate dialog box doesn't distinguish between numeric keypad , main keypad keys same name. ditto os/x keyboard shortcuts preference pane used change textmate menu item keys. should trying customize of core bundles instead? any advice appreciated, stu i understand can cocoa (?) text editing commands in ~/library/keybindings/defaultkeybinding.dict file this key. textmate use file, in addition has own version may used override settings or provide unique actions. can call textmate functions (selectors) directly through method. i recommend copying default version /applications/textmate.app/contents/resources/keybindings.dict ~/library/application support/textmate/key...

Object vs Document Storage (Databases) = Difference (nosql)? -

i thankfull short explanation of these different concepts. wikipedia mentions both in context of nosql did not find further information whats difference between both. update regarding comments: http://en.wikipedia.org/wiki/nosql#object_database vs http://en.wikipedia.org/wiki/nosql#document_store but difference unclear me. (stackoverflow not allow me post 2 links newbie links disabled) thanks jens for practical purposes, there no difference - document serialized object, , if need basic storage, key/value store can hold objects. there may differences in things how partial updates , queries handled, since there no such thing standard nosql, many differences between products in same category.

javascript - Why would .append randomly fail in jquery? -

i'm using jquery add elements blank list. on page have: <ul id="mylist"> </ul> and go through loop in script that's called dynamically created event handler. (it's "ondrop" of list item having been sorted drag operation) var mylistitemhtml; (var = 0 ; < 5 ; i++) { mylistitemhtml += '<li id=listitem'+i+'>this item number'+i+'</li>'; } $('#mylist').append(mylistitemhtml); and if check after... if ($('#mylist li').length == 0 ) { alert('going crash since i'm expecting list items') } roughly 95% of time list populated, 5% of time hit alert that's going cause exception later. has run this? there callback or way know when/if append happens? var mylistitemhtml; (var = 0 ; < 5 ; i++) { $('#mylist').append('<li id=listitem'+i+'>this item number'+i+'</li>'); } try appending inside loop. if ($(...

naming conventions - Start -> end | stop | finish? -

i'm programming class , wondering pair of methods makes more sense describing process cycle: start() -> stop() start() -> end() start() -> finish() basically these methods called before , after executing task. what i'm asking in english (specifically in programming - language -) pair more common see? sorry i'm not native speaker hear 1 people prefer. if not clear enough please let me know fix or add more info. thank in advance. update: the intention of methods call "user functions" before , after running task. task nothing special. update 2 i didn't want language i'm using (to make general), i'm doing jquery plugin , want users of plugin add custom functions triggered before , after executes main task. hope makes clear. thinking in using answer not jquery php/java. it depends. if calling method abort task or stop early, call abort() or stop() . if calling method wait until task finishes, call waitfor() . ...

Is there anything that PHP with CodeIgniter can do, which Ruby on Rails 3 can't do? -

i , partner trying develop website, , arguing language use build website. both have experienced php codeigniter 1.6++ ror, although partner used rails when in ror1, ror3. he wants use php codeigniter because knows whats going around more explicitly, while ror not seem satisfy him. i want use ror 3, because takes less time, , there many gems can use (devise example). he kind of worrying ruby on rails won't easy change configuration in db or codes once websites gets bigger , bigger. i hate think writing lines , lines of codes scratch codeigniter within 2 months.. although think not easy manage db tables, once things got settled in rails.. so, have been wondering.. there big advantage 1 other? as avid user of both not question of framework better or worse apples , oranges. codeigniter has not changed since 1.6.x both of experience still valid , able code right get-go. rails 3 wonderful quite lot has changed since rails 1 (not using then). think partner have...

java - How to obtain data from a webservice in a JSF action method? -

i'm trying determine correct api calls on facescontext following when processing backing bean action: within action method construct url of dynamic parameters send constructed url service parse returned service response parameters continue action method processing based on reponse string request. any suggestions on highlevel api calls steps 2 , 3 send me in right direction appreicated. note, service i'm calling external application in blackbox. instructions are: send url in specified format, parse response see happened. this problem not specific jsf in particular, you'll find nothing in jsf api. standard java api offers java.net.url or, allows more fine grained control, java.net.urlconnection fire http requests , obtain response inputstream can freely parse usual java way. inputstream response = new url("http://google.com").openstream(); // ... depending on content type of response, there may 3rd party api's ease parsing. example, ...

cannot find symbol-method add (java.lang.integer)..whats the problem actually? -

public class arraylist { // instance variables - replace example below own public void processinput (string s) { int[] = {34, 25, 16, 98, 77, 101, 24}; arraylist b = new arraylist(); for(int = 0; < a.length; i++) { int d = a[i]; if(d%2 > 0) { b.add(new integer(d)); } } for(int = 0; < b.size(); i++) { system.out.print(b.get(i) + " "); } for(int = a.length; >= 0; i--) { system.out.print(a[i] + " "); } } } notice package of class: arraylist not java.util.arraylist . correct: java.util.arraylist b = new java.util.arraylist();

UIpickerview size is not reduced in iphone os 4.0 -

i need reduce size of uipickerview. for use code picker = [[uipickerview alloc] init]; picker.frame = cgrectmake(0, 0, 100, 100); it not reduce in os 4.0 , test in os 3.0 reduced. what wrong,how can reduce size of uipickerview in iphone os 4.0. can 1 please me. thank u in advance. see how change uipickerview height

Accessing Vectors In C++ -

i wrote simple program accesses file called "input.txt" , pushes contents vector of string type. #include <iostream> #include <vector> #include <fstream> using namespace std; int main() { fstream input; input.open("input.txt"); string s; input >> s; while (!input.eof()) { cout << s <<endl; input >> s; vector<string> v; v.push_back(s); } input.close(); } i know isn't best way there way can access vector , use equation? if wanted add elements of vector , find sum? for starters, here's cleaner version of code you've written: ifstream input("input.txt"); string s; while (input >> s) { cout << s << endl; vector<string> elems; elems.push_back(s); } this uses ifstream instead of fstream , seems appropriate here since aren't using write facilities of fstream . combines read log...

algorithm - Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations -

i came across question: implement queue in push_rear(), pop_front() , get_min() constant time operations. i thought of using min-heap data structure has o(1) complexity get_min(). push_rear() , pop_front() o(log(n)). does know best way implement such queue has o(1) push(), pop() , min()? i googled this, , wanted point out algorithm geeks thread . seems none of solutions follow constant time rule 3 methods: push(), pop() , min(). thanks suggestions. you can implement stack o(1) pop(), push() , get_min(): store current minimum each element. so, example, stack [4,2,5,1] (1 on top) becomes [(4,4), (2,2), (5,2), (1,1)] . then can use 2 stacks implement queue . push 1 stack, pop one; if second stack empty during pop, move elements first stack second one. e.g pop request, moving elements first stack [(4,4), (2,2), (5,2), (1,1)] , second stack [(1,1), (5,1), (2,1), (4,1)] . , return top element second stack. to find minimum element of queue, @ smallest 2 elements o...

python - lighttpd, mod_rewrite, web.py -

i've small issue lighttpd , web.py. runs fine on apache2 there's small issue on lighttpd. here's lighttpd config web.py fastcgi.server = ("/code.py" => (( "socket" => "/tmp/fcgi.socket", "bin-path" => "/home/ivan/www/code.py", "max-procs" => 1, "check-local" => "disable", )) ) url.rewrite-once = ( "^/favicon.ico$" => "/static/favicon.ico", "^/static/(.*)$" => "/static/$1", "^/(.*)$" => "/code.py/$1" ) and sample web.py demonstrate how i've defined urls. urls = ( '/page', 'page', '/', 'index', ) class index(object): def get(self): raise web.seeother('/page') the problem occurs when browser redirected example.org/page url. apache2 redirects example.org/page lighttpd redirects example.org/c...

authentication - Rails: How to separate static content and application but while maintaining a connection between the 2? -

ok question might sound bit weird, let me try explain trying achieve here. i need: - static pages: home page, us, etc. usual suspects - full complex rails web app the web app being heart of system have lot of stuff, including user authentication (with devise way). application have standard navigation menu possible actions changing depending on user status (login or not, admin or not, etc). until now, nothing out of ordinary. however unrelated reason, must have entry point of whole system home page hosted on server (ergh). so now, since home page , other static pages on server , application on server b how can maintain contact between 2 ? meaning: keep navigation menu dynamic on static pages, have sign-in / sign-up form on static server registering account on "real" application server ? can share same database, no pb there. any pointers on how ? not put iframes on static site... thanks ! alex signin/signup stuff, can have forms action going ...

how to read an image file in asp.net c# using asp:fileupload? -

i used code below upload image. please let me know why code not work @ all. using updatepanal , multiview control tab controlling. <asp:fileupload id="fuphoto" runat="server"/> <div style="margin-top:20px;text-align:center;"> <asp:button id="btnaddmemberinfo" runat="server" text="add" width="100px" onclick="btnaddmemberinfo_click" /> </div> public byte[] getphtostream() { byte[] bufferphoto = new byte[fuphoto.postedfile.contentlength]; stream photostream = fuphoto.postedfile.inputstream; photostream.read(bufferphoto, 0, fuphoto.postedfile.contentlength); return bufferphoto; } protected void btnaddmemberinfo_click(object sender, eventargs e) { photo = getphtostream(); //photo represent database field datatype image } fileupload doesn...

Scalar and List context in Perl -

1 @backwards = reverse qw(yabba dabba doo); 2 $backwards = reverse qw(yabba dabba doo); 3 4 print @backwards; #gives doodabbayabba 5 print $backwards."\n"; #gives oodabbadabbay 6 print @backwards."\n"; #gives 3 in above code why line 6 give 3 output? why convert scalar context if concatenated \n? thanks your question "why @backwards in scalar context in line 6", begs question, "how can determine term's context?". context determined "what around" (i.e. "context") term. how can determine term's context? looking @ operator/function using term. what steps follow figure out context @backwards if didn't have helpful stackoverflow folks around tell context? here have print @backwards."\n" so there 2 operators/functions. how know 1 provides context @backwards? consulting precedence. near top of perlop.pod have perl's precedence chart (print "list operator"): left ...

c# - Asynchronous call to WCF service from MVC controller -

i have restful wcf service need call asynchronously within mvc controller. what "lightest" way of going this? kindness, dan i'd issue httpwebrequest using asynchronous methods, begingetresponse .

c# - How to find minimum key in dictionary -

i declare dictionary following: private dictionary<int, touchinformation> touchdictionary = new dictionary<int, touchinformation>(); and used following: touchdictionary[touchid] = touchobject; so, touchdictionary keep key touchid. now, try find minimum key using dictionary don't know how do. have suggestion? regard, c.porawat dictionary has keys property allows enumerate keys within dictionary. can use min linq extension methods minimum key follows: int minimumkey = touchdictionary.keys.min();

multithreading - C thread not behaving correctly - simple code -

i creating new thread in c using _beginthreadex. have written following code. same code written in 2 versions, first version working second 1 not working. working code main.c #include <windows.h> #include <stdio.h> extern void func(unsigned (__stdcall *secondthreadfunc)( void* )); int main() { func(null); } second.c #include<windows.h> //when thread start routine declared in same file new thread running fine... //but if routine moved main.c , passed parameter func new thread not working unsigned __stdcall secondthreadfunc( void* parguments ) { printf( "in second thread...\n "); return 0; } void func(unsigned (__stdcall *secondthreadfunc)( void* )) { handle hthread; printf( "creating second thread...\n" ); // create second thread. hthread = (handle)_beginthreadex( null, 0, &secondthreadfunc, null, 0, null ); // wait until second thread terminates. waitforsingleobject( hthread, infinite )...

variables - Loop on all var in xslt -

i have issue xslt syntax, stylesheet : <?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:saxon="http://saxon.sf.net/"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <root> <xsl:for-each select="for $x in(collection('file:///users/admin/documents/xmlsoapui/?select=*.xml;recurse=yes'))return saxon:discard-document($x)//testsuite"> <ident> <xsl:value-of select="base-uri()"/> <xsl:if test="matches(base-uri(),'catalog')"> <xsl:call-template name="summarycatalog"/> </xsl:if> <xsl:if test="matches(base-uri(),'status')"> <xsl:call-template name="summarystatus"/> </xsl:if> <xsl:if test="matches(base-uri(),'alarm')...

PHP MD5 Create User Form -

i have used tutorial here: http://www.phpeasystep.com/phptu/26.html create login form website. have set upassword field in database md5 , of passwords in database encrypted md5. the login works perfectly, confused creating registration form. the form requests user input desired password. confused how take password user inputs, converting md5 , inputting md5 password upassword field in user table. below code have processresgistration.php file: /* database connection info*/ mysql_select_db("dbname", $con); $encryptedpassword = md5($_post['upassword']); md5($upassword); $sql="insert users (uname, upassword, usurname, ufirstname) values ('$_post[uname]','$encryptedpassword','$_post[usurname]','$_post[ufirstname]'"; if (!mysql_query($sql,$con)) { die('error: ' . mysql_error()); } echo "account created. can login"; mysql_close($con) ?> the code above supposed to: create variable n...