Posts

Showing posts from June, 2013

binary - Adding and subtracting two's complement -

using six-bit one's , two's complement representation trying solve following problem: 12 - 7 now, take 12 in binary , 7 in binary first. 12 = 001100 - 6 bit 7 = 000111 - 6 bit then, flip bit two's complement , add one? 12 = 110011 ones complement + 1 ------- 001101 7 = 111000 ones complement + 1 --------- 111001 then, add 2 complement together 001101 +111001 ------- 1000110 = overflow? discard last digit? if 5 now, if have number like -15 + 2 i add sign magnitude on msb if it's zero? like: -15 = 001111 6 bit would add 1 @ end here before flip bits? = 101111 using two's complement represent negative values has benefit subtraction , addition same. in case, can think of 12 - 7 12 + (-7) . hence need find two's complement representation of -7 , add +12: 12 001100 -7 111001 -- this, invert bits of 7 (000111) , add 1 ---------- 5 1000101 then discard carry (indicates overfl...

Python HTTP Redirect requests forbidden -

i'm trying scrape website url redirected, programmatically trying gives me 403 error code (forbidden). can place url in browser , browser follow url though... to show simple example i'm trying go : http://en.wikipedia.org/w/index.php?title=mike_tyson i've tried urllib2 , mechanize both not work. new web programming , wondering whether there other tricks need in order follow redirect! thanks! edit okay, messed. looking alternative methods because trying scrape mp3. managing succesfully downloading mp3 mangled. turns out somehow related me downloading on windows or current python version. tested code on ubuntu distro , mp3 file downloaded fine.... so used simple urllib2.openurl , worked perfect! i wonder why downloading on windows mangled mp3? try changing mechanize flag not respect robots.txt. also, consider changing user-agent http header: >>> import mechanize >>> br = mechanize.browser() >>> br.set_handle_robots(f...

.net - Nhibernate Update does not persist change to database -

i have problem getting change(s) data object retrieved using nhibernate persist database. no exceptions it's difficult know look. suggestions? string name = "somenewname"; string repositoryid = "somerepositoryid"; isession nhbsession = getnhbsession(session); nhbsession.transaction.begin(); try { repositorydto existingrepository = nhbsession.get<repositorydto>(repositoryid); if (existingrepository == null || existingrepository.timedeleted != null) throw new exception("repository not exist in system or deleted. cannot modify."); existingrepository.name = name; //works fine here expected; in db old name nhbsession.update(existingrepository); nhbsession.transaction.commit(); } catch (exception ex) { nhbsession.transaction.rollback(); throw new exception("error modifying repository: " + ex.message, ex); } <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xml...

ImageScience for Windows on Ruby 1.9 -

has have success installing imagescience on ruby 1.9 windows? unfortunately, using ruby 1.8 windows development. want upgrade ruby 1.9 performance improvement. able install of gems, haven't had luck imagescience. rob anderton had put in useful instruction installation on 1.8, used. seems started using mac since :) (i considering that, in meanwhile...) http://thewebfellas.com/blog/2008/2/18/imagescience-on-windows-without-the-pain try devil instead, works in windows: http://banisterfiend.wordpress.com/2009/10/14/the-devil-image-library-for-ruby/

c# - Check to make sure a number has been picked in each box -

Image
i want have check make sure user picked number in 2x2. if user doesnt pick number in 1 of boxes want messagebog popup telling user fill in boxes. look validation events , controls should start http://msdn.microsoft.com/en-us/library/f6xht7x2.aspx

c++ - Templated function being reported as "undefined reference" during compilation -

these files: --------[ c.hpp ]-------- #ifndef _c #define _c #include<iostream> class c { public: template<class cartype> void call(cartype& c); }; #endif --------[ c.cpp ]-------- #include "c.hpp" template<class cartype> void c::call(cartype& c) { //make use of c somewhere here std::cout<<"car"<<std::endl; } --------[ v.cpp ]-------- class merc {}; --------[ main.cpp ]-------- #include "c.hpp" #include "v.cpp" //#include "c.cpp" int main() { merc m; c somecar; somecar.call(m); }//main i'm able generate ".o" files above files, command g++ -c main.cpp , g++ -c c.cpp , on. when try linking ".o" files g++ -o car c.o main.o v.o error: main.o: in function `main': main.cpp:(.text+0x17): undefined reference `void c::call<merc>(merc&)' collect2: ld returned 1 exit status the error goes away when uncomment line ...

transparency - Delphi 6 : How to create a Bitmap with TextOut that has an Alpha channel? -

i'll describe overall goal in case question asked isn't in best form answer i'm looking for. have sphere of words or "word ball" spins around x axis. words spin (z coordinate goes -1 1, front back), intend change size , opacity of each word words in "front" 100% opaque , full-sized , words in smaller , transparent. prefer straight delphi code , avoid things direct3d, etc. have rotation code working fine. need implement z coordinate based perceptual shading idea. when create word ball dynamically create timage component each word. "print" word timage bitmap using tcanvas.textout() method in centered manner. intend use bitblt copy bitmap correct location in main canvas holds word ball, because bitblt fast , can resize bitmaps on-the-fly, meeting 1 of requirements perceptual shading operation. but don't know best way facilitate alpha blending. know windows has alphablend() call , seems straightforward use. need know how create...

What does the "@" sign in jQuery selector means? -

what @ sign in following code means ? $("input[@type=checkbox][@checked]").each( function() { ... } ); this xpath convention attribute selection , discontinued 2 versions ago. should remove @ sign if want selectors work on current version. alternatively, selector $("input:checkbox:checked") should work same.

c# - How do I concatenate two System.Io.Stream instances into one? -

let's imagine want stream 3 files user in row, instead of him handing me stream object push bytes down, have hand him stream object he'll pull bytes from. i'd take 3 filestream objects (or cleverer, ienumerable<stream> ) , return new concatenatedstream object pull source streams on demand. class concatenatedstream : stream { queue<stream> streams; public concatenatedstream(ienumerable<stream> streams) { this.streams = new queue<stream>(streams); } public override bool canread { { return true; } } public override int read(byte[] buffer, int offset, int count) { if (streams.count == 0) return 0; int bytesread = streams.peek().read(buffer, offset, count); if (bytesread == 0) { streams.dequeue().dispose(); bytesread += read(buffer, offset + bytesread, count - bytesread); } return bytesread; } ...

blocking/non-blocking timer in C -

this might repeated question, sorry bringing again. unable find solution :( . writing vm monitoring code in c in linux. want read , write count of vm's every 10 seconds. there c library provides feature(timer alone), blocking/non-blocking timer doesn't matter. !! regards, sethu sleep(10); will make thread sleep 10 seconds in unix system. use in loop code monitoring, , go. if you're using windows host monitoring, sleep function accept in milliseconds. also, multithreading/multiprocessing required, implementations vary based on os/platform.

java - JSTL c:forEach, decremental number loop impossible? -

i want print decremental numbers like: <c:foreach var="i" begin="10" end="0" step="-1"> ... ${i} ... </c:foreach> then got jsp exception: javax.servlet.jsp.jsptagexception: 'step' <= 0 javax.servlet.jsp.jstl.core.looptagsupport.validatestep(looptagsupport.java:459) org.apache.taglibs.standard.tag.rt.core.foreachtag.setstep(foreachtag.java:60) .... but answer says possible loop in both ways: jstl foreach reverse order what's wrong me? i not sure how answerer of other question got work, can't work here reference jstl implementation. anyway, can achieve requirement following: <c:foreach var="i" begin="0" end="10" step="1"> ... ${10 - i} ... </c:foreach> or if you'd avoid duplication of 10 : <c:foreach var="i" begin="0" end="10" step="1" varstatus="loop"> ...

javascript - Custom form validation using jquery plugin, based on attributes -

i using jquery valdiation plugin validating form @ client side. want validation like. <input type="text" id="txtinf" regex="/some regular expression/" error="inf mandatory"></inf> here regex , error custom attributes. field validated against given regular expression in regex , if regular expression text fails error meessage should shown. i tried add method validator this. $("*[regex]").each(function () { $.validator.addmethod($(this).attr('id'), function () { return this.optional($(this)) || $(this).attr('regex').test($(this).text()); }, $(this).attr('error')); }); but there issue, approach. please let me know, if thinking right. if there other approach in mind, please let me know. thought process welcomed. i haven't used plugin, looks you'll error use of test(). $(this).attr('regex').test($(this).text()); should...

coordinates - Selecting Map Points Inside a Map Poly -

i'm trying find algorithmic way select points fall within specific arbitrarily shaped area on google map. want able provide point , ask function if point lies within arbitrary (but defined) map area. for example, how tell if point contained within green section (brions regional park) on follow map: http://maps.google.com/maps?ie=utf8&q=state+park&fb=1&gl=us&ei=rm-ttigrbi2jnqexrzytbg&ved=0ceoqtgmwaw&sll=37.912242,-122.078705&sspn=0.086,0.17355&split=1&rq=1&ev=zi&radius=5.68&hq=state+park&hnear=&ll=37.934585,-122.13192&spn=0.089358,0.17355&z=13 i need figuring out how define specific area , algorithm take in defined area & point , return true/false. thanks in advance help! this has been helpful me: https://github.com/tparkin/google-maps-point-in-polygon

Handle skype message using Ruby -

is there library allows handle skype messages using ruby? take @ this: http://rubyforge.org/projects/skyperapper if using jruby http://skype.sourceforge.jp/ might better option for public api doc: http://developer.skype.com/accessories

sql - Optimize a simple JOIN or IN query -

i have query: select distinct id, label bbproduct_cust custno in (select custno customer slsrptgrp = '1996') , deptno = '0' order label asc explain shows id select_type table type possible_keys key key_len ref rows 1 primary bbproduct_cust ind_deptno 91834 using where; using temporary; using filesort 2 dependent subquery customer ref primary,ind_slsrptgrp ind_slsrptgrp 3 const 4 using it takes 2-3 seconds, , need optimized. what options have? use inner join , rather in select something like select distinct id, label bbproduct_cust inner join customer on bbproduct_cust.custno = customer.custno slsrptgrp = '1996' , dep...

windows - SConscript StaticLibrary attribute error. -

i couldn't find information on net, kindly ask one. i have build environment set properly, compiler 'cl' vs express package. i try build static library, when set tools 'default' works, when set 'msvc' have following error: scons: reading sconscript files ... attributeerror: 'sconsenvironment' object has no attribute 'library': file "d:\n\workspace\cpp\sipher\sconstruct", line 37: scypherlib_gen = env.sconscript(os.path.join(libbuilddir, 'lib_gen', 'sconscript'), 'env') file "c:\python26\lib\site-packages\scons-2.0.1\scons\script\sconscript.py", line 551: return _sconscript(self.fs, *files, **subst_kw) file "c:\python26\lib\site-packages\scons-2.0.1\scons\script\sconscript.py", line 260: exec _file_ in call_stack[-1].globals file "d:\n\workspace\cpp\proj\src\sconscript", line 5: lib = env.library(target='myprog', source = src) ...

java - Changes in dependent modules cannot be seen in other module in Maven Eclipse -

i working on multi module project m2eclipse. set maven take care of resolving workspace dependencies. when make change on, say, service module, change not visible on other modules immediately. if make new method in service layer, not visible in webapp layer. run/maven install , refresh , project/clean , maven/update dependencies doesn't work. can give me idea on problem? my project structure looks follows: parent module <groupid>com.myproject</groupid> <artifactid>einvites-parent</artifactid> <modules> <module>myproject-common</module> <module>myproject-domain</module> <module>myproject-service</module> <module>myproject-web</module> </modules> service module <parent> <artifactid>myproject-parent</artifactid> <groupid>com.myproject</groupid> <version>1.0</version> </parent> <groupid>com.myproject</group...

Load jquery Ui Scripts in asp.net applications -

is there component or control exist asp.net application load jquery ui scripts , themes? thanks. depend on this sample can body me , introducing component or control ? :) hmm - couldn't have them included in masterpage , they'd on every page referenced (by master) on site?? this how i'd if wanted keep simple. if you're looking control this, of course create usercontrol , place in head section of masterpage same thing. that said, maybe i've missed here :)

rapidxml - is there is any way to get xml value by tag in rapid xml using c++ -

is there way value of tag tagname in rapidxml using c++ <?xml version=\1.0\ encoding=\latin-1\?> <book>example</book> <book1>example1</book1> i need book value ie example , book1 value ....we can use doc.first_node()->value() first node , next node need there way value get name answer xml_node<> *node = doc.first_node("book"); cout <<< node->value() << "\n"; you should able call first_node using node name matched. the docs : function xml_node::first_node synopsis xml_node* first_node(const ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const; description gets first child node, optionally matching node name. parameters name name of child find, or 0 return first child regardless of name; string doesn't have zero-terminated if name_size non-zero name_size size of name, in characters, or 0 have siz...

C#: How do I instantiate a class in C#, like showin this C++ example -

i've translated following c++ code c#, cant determine , how put class instance. if using: customanalysis test = new customanalysis(); it receive errormessage, telling me class instantiated rhino3d, , therefore i'm not supposed it. need create reference class can it's static member m_am_id variable created base-class. this line im having trouble with: static class czanalysisvam thezanalysisvam; thanks in advance. c++ code: ////////////////////////////////////////////////////////////////// // // begin z analysis mode class // // example demonstrates how add false color // analysis mode rhino. example uses false color indicate // world "z" coordinate. // {df4688c-9671-4389-ac41-515b8693a783} static const guid false_color_example_analysis_mode_id = { 0xdf4688c, 0x9671, 0x4389, { 0xac, 0x41, 0x51, 0x5b, 0x86, 0x93, 0xa7, 0x83 } }; class czanalysisvam : public crhinovisualanalysismode { public: czanalysisvam(); ~czanalysisvam(); // virtual ...

javascript - Set the name of a Jquery selector as a string in a variable -

i'm quite noob @ jquery i'm trying set variable based on name of form element. i.e. variable = "someform" based on example: <form id="hello" name="someform" > first name: <input type="text" name="firstname" /> last name: <input type="text" name="lastname" /> email: <input type="text" name="email" /> <input type="submit" value="subscribe" /> </form> i'm using following code doesn't seem work: var formname = 0; $('input').parentsuntil('form', this).focus(function() {var formname = this.name;}) if (sttime == 0) { // ensures cannot start form multiple times var sttime = new date(); stdelay = sttime - lotime; alert(formname); } thanks in advance! the focus event not bubble, see http://www.quirksmode.org/dom/events/blurfocus.html#t06 couple of other issues: the formname varia...

java - How to extract a jar to a particular location? -

i using jar -xf <name of jar> -c <location jar extracted> but getting issues syntax. please let me know wrong or site example. thanks. you can do: unzip -d /path/to/your/directory my.jar as if jar file zip file.

python - Authenticating on Web.py - will this code be unsafe for production? -

i making simple web-app requires login admin page. came across incantation on web.py site ( http://webpy.org/cookbook/userauth ) : import hashlib import web def post(self): = web.input() authdb = sqlite3.connect('users.db') pwdhash = hashlib.md5(i.password).hexdigest() check = authdb.execute('select * users username=? , password=?', (i.username, pwdhash)) if check: session.loggedin = true session.username = i.username raise web.seeother('/results') else: return render.base("those login details don't work.") however page gives ominous warning: "do not use code on real site - illustration.". wondering if there major holes in this, i'm unfamiliar web-programming wanted make sure using code wont unwittingly make app open trivial attack vectors? many thanks the possible problem can think of here, if somehow possible exploit md5 collisions , i.e. 2 different string...

git reset - How to discard local commits in Git? -

i'd been working on something, , decided screwed...after having committed of it. tried following sequence: git reset --hard git rebase origin git fetch git pull git checkout at point got message your branch ahead of 'origin/master' 2 commits. i want discard local commits , without having wipe out local directory , redownload everything. how can accomplish that? git reset --hard origin/master will remove commits not in origin/master origin repo name , master name of branch.

git - Any good tutorial on using TortoiseGit with workflows? -

most git tutorials use command line fine i'm looking resources showing workflows in tortoisegit (note emphasis on workflows , not installation , basic checkouts / commits). any links / suggestions? this identical our workflow in simplest form works quite well http://uncod.in/blog/github-tortoisegit-and-organizational-workflow-tutorial/ and here screenshot-enhanced explanation of branching , merging http://joelabrahamsson.com/entry/remote-branches-with-tortoisegit

Where create cookie that holds only user id in Zend MVC project? -

i working zend mvc project. mission: add cookie have user unique id. problem:i don't know create cookie. options place create cookie, thing about: bootstrap.php init()/run() index.php (not make sense) in controllers my project structure : application/bootstrap.php public/index.php please me, if can give example great. thanks, yosef i've put in bootstrup.php, created new method called _inituseruniqueid: protected function _inituseruniqueid(){ $uniq = uniqid(); if(!isset($_cookie['f_uniq'])){ setcookie('f_uniq', $uniq, time() + 60 * 60 * 24 * 365, '/'); } }

php - Pointing domain to a page in my site -

i'm having directory website sub-pages each city. example newyork have address www.directory.com/newyork, la have www.directory.com/la so want point the domain newyorkdirectory.com www.directory.com/newyork , each sub sections... options have.. can in code? there way detect domain php , load content accordingly? if point domain's site can detect incoming domain , refer them page? totally have no idea on this. clarification: when people goto site through newyorkdirectory.com page www.directory.com/newyork/malls should accessed through newyorkdirectory.com/malls so want point the domain newyorkdirectory.com www.directory.com/newyork you mean want existing "newyorkdirectory.com" links of website point "www.directory.com/newyork"? or want point "www.directory.com/newyork" when people try go "newyorkdirectory.com"? second case impossible if not possess domain "newyorkdirectory.com", else can reroute u...

version control - What is the right way to structure a large multi-application codebase in SVN -

we've got single repo codesion, http://john.svn.cvsdude.com , single svn project http://john.svn.cvsdude.com/myproject , contains few subdirs individual visual c++ solutions this started 1 application , though did split off separate library projects future re-use, it's still same svn project. lets aim have multiple applications overlap in libraries used, what's right/best way set in svn? of course 1 keep 1 svn project , put app-projects , library-projects sub-dirs, hardly seems right somehow. say have app1, app2, app3 , librarya, libraryb, libraryc, libraryd these separate projects/solutions... how organise under 1 (or more repos)? there best-practice? i keep everything in one repository , put each project and library in separate root directory of repository (see planning repository organization details). keep in mind repository structure do not have to identical project files structure on disk. also use svn-externals share library directories (ke...

html - How to open a new window in FULLSCREEN with javascript? -

i using code doesn't work because new window half of screen ( 1280x800px ): <a href="javascript:void(0);" onclick="window.open('http://www.stackoverflow.com', '', 'fullscreen=yes');">open full screen window</a> why ? in browsers supported in first place, feature has been phased out due user hostility , ability used phishing security attacks. fullscreen do not use. not implemented in mozilla. there no plans implement feature in mozilla. this feature no longer works in msie 6 sp2 way worked in msie 5.x. windows taskbar, titlebar , status bar of window not visible, nor accessible when fullscreen enabled in msie 5.x. fullscreen upsets users large monitor screen or dual monitor screen. forcing fullscreen onto other users extremely unpopular , considered outright rude attempt impose web author's viewing preferences onto users. — https://developer.mozilla.org/en/dom/window.open

Google Chrome extention modifying page request -

is possible catch request of page before sent out? check , modify data sent out. example if have text box on page , form submitted data of text box using extention modify , send on it's way. if 1 can point me in right direction grate thanks eli chrome has chrome.experimental.webrequest api module allows catch web requests before sent, docs doesn't can modify them, observe. i think better off injecting content script pages , listening onbeforesubmit event on forms.

e-commerce, customizing checkout process based on product -

after lots of research, i'm considering using wordpress , either wp e-commerce plugin or shopp plugin. we'll integrate paypal actual credit card transaction. the products selling combination of regular products , "odd" products have crazy dimensions , weights. whenever 1 of these "odd" products part of shopping cart, want transaction passed on sales associate. sales associate @ order , provide estimated shipping information (they need figure out how group , package odd products regular products, if possible). will 2 plugins mentioned allow intercept checkout process this? is ecommerce plugins/engines allow do? i'm thinking of tagging these "odd" products , able "hook" process somewhere. i've crossposted @ wordpress stackexchange. i have used wp e-commerce in past. allows create "odd" product , define different landing page instead of paypal's without trouble. have write own procedures on such l...

iphone - iPad form creation? -

i create form in ipad application similar form used when setting cellular data account on ipad. that is, collects user information, payment information, , other information user in modal view across multiple steps. is there tutorial out there creating type of interface? looks makes use of tableview embedded uitextinputs in editable cells. creating kind of interface trivial in html. equally easy on ipad. thanks in advance links. its not trivial html, there few tutorials when combined should point on way: editable uitextfields in uitableviewcell , , modal view part, have uinavigationcontroller presented modally, , push/pop uitableviewcontrollers wished.

mysql - Poor Man's Load Balancing -

i have mysql database several tables. have input makes ajax calls every character. there way load balance distributing other domains etc? estimated statistics: ~1000-2000 hits day. average site time per user ~30-60 secs. i think you'd better off making ajax form set timeout whenever character input let's 300ms after last character ajax request made. i've done similar solution in java swing application , load on server make simple query stupendous. far load balancing mysql know you'll either have give on consistency or you'll have deal degraded write performance.

excel vba - Starting javascript function due to URL Link in "Browser" -

i'm using wininet sourcecode homepages, afterwards analyse information. use vb in excel that. of working fine, want information special page. i have open page , click link go side wanted information. problem is, link javascript function. question: possible open side , start javascript function due url? i use following vb function: 'api-deklarationen: private declare sub internetclosehandle lib "wininet.dll" ( _ byval hinet long) private declare function internetopena lib "wininet.dll" ( _ byval sagent string, byval laccesstype long, _ byval sproxyname string, byval sproxybypass string, _ byval lflags long) long private declare function internetopenurla lib "wininet.dll" ( _ byval hopen long, byval surl string, _ byval sheaders string, byval llength long, _ byval lflags long, byval lcontext long) long private declare sub internetreadfile lib "wininet.dll" ( _ byval hfile long, byval s...

php - cakephp find all posts that have comments -

i created simple blog has posts , comments. want find posts have @ least 1 comment , find posts no comments. there cakephp way this? i.e. maybe like $this->post->find('all', ???); i ended writing own query, example below finds posts @ least 1 comment select * ( select posts.*, count(comments.id) comment_count posts left join comments on posts.id = comments.post_id group posts.id ) t comment_count != 0 but there seems there better way this. note: post hasmany comment , comment belongsto post $grouped_comments = $this->comment->find('all', array('group' => 'comment.post_id')); this give array of comments grouped post_id have 1 comment each post, want. there can whatever want data. let's wanted post list of post titles comments. echo "<h1>posts comments:</h1>"; foreach ($grouped_comments $comment) { echo $comment['post']['title'] . "...

Help needed for creating an Android Activity Layout - Screenshot given -

i need create screen(scrollable) similar screenshot shown here . have no idea regarding kind of layout patterns should resort or widgets should use. the data including thumbnail links, available dynamically. experts, kindly valuable suggestions, advices , help. looking forward, regards, rony i have worked lot on listviews , looking @ screenshot, suggest avoiding use of listviews if can. if have constant layout, if layout showed there in screenshot layout of each element[unique ones only] in xml file , add them dynamically , when required. although not sure how want layout exactly, might not if elements can increase in number.

python - Multiple authentication options with Tornado -

just started playing tornado , want offer multiple methods of authentication. app working fine google's hybrid openid/oauth using tornado.auth.googlemixin , unauthenticated users automatically sent google's auth page. if unauthenticated user wants use option (ie. local auth or tornado.auth.twittermixin), how can implement logic choose auth mechanism within login handler? i added decorator 'tornado.web.authenticated' of exposed methods, , here login handler class (pretty straight tornado examples) working google openid/oauth: class authloginhandler(basehandler, tornado.auth.googlemixin): @tornado.web.asynchronous def get(self): if self.get_argument('openid.mode', none): self.get_authenticated_user(self.async_callback(self._on_auth)) return ## redirect after auth self.authenticate_redirect() def _on_auth(self, user): ## auth fail if not user: raise tornado.web.htt...

iphone - xCode Active Configuration: Release, Distribution -

in xcode 3.2.3 (haven't updated 4.1 yet) under active configurations have: debug, release, distribution. when select release, 'base sdk missing' , when 'build , archive' , try 'validate application', code sign error. when select 'distribution' 'validate application' succeeds. i have confirmed using valid distribution provisioning profile. so, how can 'release' setting work (ie. eliminate validate application error of not code signing properly) , happen if sent 'distribution' build itunes , accepted on app store? thank time. check base sdk option under release configuration in target build properties. needs updated sdk have available.

iphone - In App Purchase : adding new items for sale -

i wanna make sure if got right, if want sell ebooks through iphone app, shouldn't bundle them application ( because want add ebooks sale time time ), should put on separate server, , each time want add ebook, add information in itune connect , , ebook put on server downloaded when purchased, correct ? help yes correct, every in-app items review apple.

.net - LRU file cache and the cost of finding a file in a Windows directory -

i have application download , cache, @ minimum, 250,000 8kb* files totaling 2gb. need remove least used file when updating cache. *these tiny files span 2 4kb sectors. what relative cost of obtaining file handle name type of file in directory on ntfs-formatted 5400 rpm drive? if store 200k files in 1 directory merely getting file handle take more few milliseconds? can bucket files different directories. windows 7 disables last access time files default, , don't want require administrator enable feature. should maintain separate list of file access times in memory (serialized disk when app exits?) should consider storing these files in 1 large flat file? memory mapping might difficult if use older .net 4.0 opening 250,000 files -- if that's mean -- take more few milliseconds, yes. size of directory less interesting fact you're going through entire file system stack 250,000 times (everything ntfs, kernel, , grandmother's favorite anti-virus filter h...

OpenGL ES 2.0 (specifically for the iphone) rendering is slightly off. Best guess is it's a projection matrix problem -

so bought o'reilly's iphone 3d programming , found believe bug in there code. can't figure out problem is, , unless can't move forward own code. i paste consider appropriate code post luckily code available online at: http://examples.oreilly.com/9780596804831/hellocone/ the problem having opengl es 2.0 renderer, not show in es 1.1 renderer. so have been noticing cone not render in correct position. test changed modelviewmatrix render on frustumnear plane. cone should appear cut in two. when es 1.1 render case, when same in opengl es 2.0 not. cone part there, shaved off. meaning not landing on fustrum's near face. here initialization code projection matrix created , set up: void renderingengine2::initialize(int width, int height) { const float coneradius = 0.5f; const float coneheight = 1.0f; const int coneslices = 40; { // allocate space cone vertices. m_cone.resize((coneslices + 1) * 2); // initialize vertices of triangle strip. vect...

installaware - What's the difference between an EXE and a MSI installer? -

i've created installation package using installaware , generated exe , msi. exe 3.1mb , msi 265k. why there such big difference in size? an msi file can launched msiexec.exe - the windows installer engine . msi file windows installer database file capable of installing software. requires right version of windows installer engine runtime @ minimum installable. systems date latest engine versions since comes down via windows update. the exe file generate self-extracting launcher application containing both msi various runtime requirements setup might have. various components exe file might include: the version of windows installer engine runtime msi requires (current version 5.0). these days runtime should installed windows update, , setup should verify present. scripting runtimes required custom actions in msi (installscript installshield ) the .net runtime version required application (gaining on 10 versions now). prefer using windows update well, if ap...

Django-nonrel in Google App Engine ListField -

i trying build example app in google app engine using django-nonrel. , having problems implementing listfield attribute model. i have created app test_model , have included installed app in settings. model.py is: django.db import models djangotoolbox import * dbindexer import * # create models here. class example(models.model): some_choices = models.listfield('choice_examples') notes = models.charfield(max_length='20') updated_at = models.datetimefield(auto_now=true) def __unicode__(self): return u'%s' % (self.notes) class choice_examples(models.model): name = models.charfield(max_length='30') def __unicode__(self): return u'%s' % (self.name) the above example gives me: attributeerror:'module' object has no attribute 'model' if comment out djangotoolbox import, following : attributeerror: 'module' object has no attribute 'listfield' what doing wrong h...

hyperlink - Jquery Colorbox linking? -

does know if there way embed link inside of colorbox? so, example, have clicked image , opened colorbox popup, place link in caption page? or navigating different page clicking on image? i'm sure there way, little new javascript/jquery. it's not pretty yet, because it's not done. can see i'm talking here: http://www.catanesedesign.com/test/artists.html . click on 1 of images make colorbox come up. thanks in advance. you can add link inside title attribute: <a href="myimage.jpg" rel="examples" title="sandra - <a href='sandra.htm'>go page</a>">sandra</a> note single quotes inside title attribute, or use escaped quotes.

What is the serialization pattern? -

i've seen referenced in couple places i've been unable find description of pattern. to me, means specific form of memento pattern . mementos, in case, serialized objects. caretaker file system.

jquery - Enabling the Back button to act as an 'undo' button in an Ajax app -

i have problem ajax app i'm trying working browser's , forward buttons. using jquery history plugin enable browser history. the app consists of page of products. there sort bar enables user sort products various values. user may select product clothing category (dresses, tops, bottoms, skirts, etc), sub-category department (skirt: mini, maxi, high-waisted, boho/hippy, etc), size (xs s m l xl xxl xxxl), color (white, black, gray, blue, red, etc), , era , materials. most options enabled using ajax load latest selected option appropriate div. so instance, select color black, following code executed $('#colorsort').load('colorsort.php?color=black'); then if user selects brown: $('#colorsort').load('colorsort.php?color=brown'); then if user de-selects black: $('#colorsort').load('colorsort.php?colorremove=black'); this works fine long don't need support back/forward buttons, when add button capability via jque...

How to read a file (e.g txt file) from another java package withouth specifying the absolute path? -

i have stored non-java files in package. want read files package without specifying absolute path file(e.g c:\etc\etc...). how should this? use getresourceasstream for example: myclass.class.getresourceasstream("file.txt"); will open file.txt if it's in same package myclass also: myclass.class.getresourceasstream("/com/foo/bar/file.txt"); will open file.txt on package com.foo.bar good luck! :)

High-level Architecture (HLA) versus Distributed Interactive Simulation (DIS) -

is there high-level overview of hla versus dis simulation frameworks? can 1 host other , vice-versa? i (though week or so) work in simulation industry - apologize in advance errors, correct them if remembering incorrect information. dis the standard specifies layout of data on wire, i.e. packets/data pdus laid out defined in dis specifications relies on best-effort networking (i.e. udp protocol, broadcasting) entities have heartbeat @ intervals (default: 5 seconds) notify else still part of exercise no central server managing various applications joined exercise simulation applications can join simulation @ time, leave @ time hla uses central manager, called rti (run time infrastructure), receives data various applications , sends them other applications in simulation (in context of hla, these called federates , set of federates federation) all federates must join , leave simulation going through rti unlike dis, hla specification not specify layout of d...

PHP: Facebook / Twitter Integration -

i have cms built in php , i'm looking add social networking integration it. basicaly want pre-populate comments , contact forms facebook/twitter information of visitor if it's available. is there reliable built , tested or should start scratch? thanks. one of solutions that's getting pretty popular disqus.com, allows users comment when they're logged facebook/twitter , many other sites. , it's starting wide adoption.

algorithm - Predicting Probability of Winning Free-Throw % in Basketball? -

my actual problem bit more general this, here specific example. in basketball, calculate free throw percentage as: free-throw percentage (ft%) = free-throws made (ftm) / free-throws attempted (fta) i have 2 teams, , each team have mean , variance of team's ftm , fta, can model each random normal variable (obviously ftm , fta correlated). can compute probability 1 team make more free throws other, example. my question is... how can find probability 1 team shoot higher free-throw percentage other? why hard compute? ideas? thanks in advance! :-) it turns out ratio of distributed variable (such fta , ftm in model), distributed in way rather complicated describe! simplest (or perhaps least intractable!) case when both means 0, in case ratio follows cauchy distribution . distribution tough work with, because integrals representing mean , variance not defined. fta , ftm have nonzero means, oversimplification. don't think you're going find simple express...

c# - Splitting strings in a "Google" style way -

i trying create function split string search terms. using code work fine: string teststring = "this test"; string[] terms; terms = teststring.split(" "); this split string 4 strings: "this", "is", "a", "test". want words enclosed in quotes treated 1 word: string teststring = "this \"test will\" fail"; string[] terms; terms = teststring.split(" "); this split string 4 strings, again: "this", "\"test", "will\"", "fail" what want split last string 3 strings: "this", "test will", "fail" anyone have idea on how this? try using regex: var teststring = "this \"test will\" fail"; var termsmatches = regex.matches(teststring, "(\\w+)|\"([\\w ]+[^ ])\"");

c# - how to use parameter in linq to select different columns -

i want use linq select columns populate each combobox. right have individual linq query job. wish write method that. var getusername = entity.select(a=>a.username); var gettype = entity.select(a=>a.type); var getaddress = entity.select(a=>a.address); can that: public object getdata(string columnname) { var q = in entity select columnname; return q.distinct(); } combobox1.bindingsource = getdata("username"); combobox2.bindingsource = getdata("type"); combobox3.bindingsource = getdata("address"); do need write construct? dynamic linq helpful in situation. here tutorial . code need this: public object getdata (string colname) { northwinddatacontext db = new northwinddatacontext(); var q = db.products.select(colname); list list = new list(); foreach (var element in q) { if (!list.contains(element)) list.add(element); } return list;

Is it possible to run php code online? -

possible duplicate: online php ide in php possible run code n result online? yes, go codepad.org or ideone.com

Get real IP address in local Rails development environment -

i have rails 2.3.8, ruby 1.8.7, mongrel web server , mysql database. i in development mode , need find real ip address when use request.remote_ip getting ip 127.0.0.1 i know getting 127.0.0.1 because developing on local machine.. there way real ip-address if on local machine? i using these mentioned below in controller , 127.0.0.1 of them in view. request.remote_ip request.env["http_x_forwarded_for"] request.remote_addr request.env['remote_addr'] as far can see there no standard method getting remote address of local machine. if need remote address (testing) geocoding, suggest adding 127.0.0.1 database table matches ip addresses locations. as last resort hard code remote address. e.g. this: class applicationcontroller < actioncontroller::base def remote_ip if request.remote_ip == '127.0.0.1' # hard coded remote address '123.45.67.89' else request.remote_ip end end end class mycontrol...

html - how to give opacity on area map -

i having problem html opacity .. currently have applied opacity using css not working html , css code below.. <area shape ="rect" class="transbox" coords ="0,0,30,22" href ="test1.htm" target ="_blank" opacity="0.5" /> area{ opacity: 0.6; -ms-filter:"progid:dximagetransform.microsoft.alpha(opacity=60)"; filter: alpha(opacity=60); -moz-opacity: 0.60; -khtml-opacity: 0.6; } any 1 have idea it? thanks in advance i don't think can change opacity per area element. however, still achieve effect mapper.js .

algorithm - Finding median of large set of numbers too big to fit into memory -

i asked question in interview recently. there n numbers, many fit memory. split across k database tables (unsorted), each of can fit memory. find median of numbers. wasn't quite sure answer one. there's few potential solutions: external merge sort - o(n log n) sort numbers on first pass, find median on second. order statistics distributed selection algorithm - o(n) simplify problem original problem of finding kth number in unsorted array. counting sort histogram o(n) have assume properties range of numbers - can range fit in memory? if known distribution of numbers other algorithms can produced. for more details , implementation see: http://www.fusu.us/2013/07/median-in-large-set-across-1000-servers.html

python - Making decorators with optional arguments -

from functools import wraps def foo_register(method_name=none): """does stuff.""" def decorator(method): if method_name none: method.gw_method = method.__name__ else: method.gw_method = method_name @wraps(method) def wrapper(*args, **kwargs): method(*args, **kwargs) return wrapper return decorator example: following decorates my_function foo_register instead of ever making decorator . @foo_register def my_function(): print('hi...') example: following works expected. @foo_register('say_hi') def my_function(): print('hi...') if want work correctly in both applications (one using method.__name__ , 1 passing name in), have check inside of foo_register see if first argument decorator, , if so, have to: return decorator(method_name) (instead of return decorator ). sort of "check see if it's callable" seems ha...

.net - Invalid XML characters -

i have text file(utf-8) file. content of file extracted form rich text documents, might ms word, pdf, html or thing. have pass content web service, of time contain invalid characters form feed or null. happens when pass content of file, containing invalid character, web service throw exception (not valid xml character). as found few characters not valid xml can have proper .net function clean string , remove invalid characters or can have list of invalid characters authentic site. thanks in advance. if it's important send file's content without modification best decision escape content. if it's not, try use xmlconvert.isxmlchar method, helps check character's correctness. check this answer code samples.

ruby on rails - How to configure an extra/different migrations folder -

a colleague , working in different projects share models. so, sharing models through git submodule. additionally, we'd able share migrations: in way, colleague's migrations in folder db/migrate/other_db of project. how can configure rails migrations run migrations in folder? in config file (config/application.rb environments or config/environments/$(environment).rb particular environment) add line: config.paths['db/migrate'] += 'db/migrate/other_db' and if want change default 'db/migrate' path (config.paths['db/migrate'] array 1 string 'db/migrate' default), this: config.paths['db/migrate'] = ['db/my_migrate'] here default config.paths, can change: "app" => ["app"], "app/assets" => ["app/assets"], "app/controllers" => ["app/controllers"], "app/helpers" => ["app/helpers"], "app/models" => [...

objective c - Download a PDF file from server -

i want download pdf file server , save documents directory. able using nsdata file in documents directory not pdf: it's nsdata object. there way download , save straight pdf file? nsdata *pdfdata = [nsdata datawithcontentsofurl: [nsurl urlwithstring:@"http://…"]]; [pdfdata writetofile:@"…" atomically:yes]; this not work?

What do ! and # mean when attached to numbers in VB6? -

i have come across numeric literals such 10! , 50# in visual basic programs. tell me these punctuation marks mean? they called type declaration characters. this article has more information. % integer & long ! single # double $ string @ currency

asp.net mvc - Database back up from mvc.net application -

i using vs2010 , working on mvc application. want database backup c# code , want restore database. if 1 has solution please reply. you can perform database backups using t-sql script see msdn page: http://msdn.microsoft.com/en-us/library/ms186865.aspx then wrap stored procedure , execute c# code.

javascript - JQuery Cross-Domain .load() (self-constructing widget) -

i'm creating widget people use on websites, keep widget future-proof, want self constructing using external javascript. so widget code ask people put on websites like: <div id="my_widget"></div> <script type="text/javascript" src="http://www.external-domain.com/mywidget.js"></script> mywidget.js use jquery's .load() populate #my_widget div iframe. problem doesn't work.... what need do? (note dont want have iframe in code give customers) it depends on url specifying in load function. if url not hosted on same domain executes page containing script won't work due same origin policy restriction. 1 possible workaround make cross domain ajax calls use json-p if have control on server side script used in load function. here's idea behind json-p: you provide server side script hosted on domain return jsonp formatted response. domain domain have full control. this server side script ...