Posts

Showing posts from January, 2010

visual studio 2005 - How can I override a (.vsprops) property (UserMacro) with an environment variable? -

so, want (visual studio 2005 and/or 2010, microsoft , intel compilers) 1 - new dev checks out code 2 - dev builds on desktop in unknown location "default" values no need environment settings, no need configuration, as-submitted code "just works". 3 - build machine overrides "default" values build-specific parameters i thought had working .vsprops. define things like <usermacro name="shared_libs_home" value="....\shared" /> on build server, it's not in ....\shared, use environment variable shared_libs_home set (say) "g:\shared" , use g:\shared instead of "....\shared" when running. but doesn't work: looks (with visual studio 2005 @ least) if have property defined environment variable , usermacro in included .vsprops, usermacro takes priority. i can see multitude of websites 1 can set .vsprops override .vcproj setting, or set .vsprops export values environment, want set .vsprops set...

question regarding <img> and thumbnails -

i have photo site renders previews of photos in tag when hover dots. (see http://johanberntsson.se/photo/ ). but feels kinda stupid load full image in img-tag. because far know, theres no difference between loading image original size versus adding height , width attributes it. got suggestions how improove preview function? thanks as far client side concerned, there's nothing can do. if you're worried how long takes image load, pre-load them javascript. other thing create few sizes of image on server.

How to setup Komodo Edit for Python 3.2 -

i use komodo edit edit scripts written in python 3.2. how setup komodo edit run python 3.2 interpreter? using latest version of mac osx. the reason ask because using komodo edit , running version of python interpreter. when use print(b, end=' ') command, , error pointing end=' ' . think because komodo using python 2.6.1 default on mac. any suggestions appreciated. thank you. you can change default python interpreter in preferences -> languages -> python .

java - Mybatis 3.0.5 nested collection mapping Example -

i investigating mapping facilities of mybatis 3.0.5. database h2 (1.3.160) in running embedded mode. of user manual, got straightforward parts working. having hard time mapping set uses hashmap backing storage. here's java code custom collection has custom set field (simplified brevity) public class customcollection { @jsonproperty private customset<customitem> customitems; public customcollection() { customitems = new customset<customitem>(); } // other stuff } here's customset code (again, simplified) public class customset<e extends customiteminterface> extends abstractset<e> { private concurrenthashmap<string, e> items; public customset() { items = new concurrenthashmap<string, e>(); } // other stuff } here's mapping interface: public interface customcollectionmapper { customcollection select(@param("somename") string s1, @param(...

flash - I want to create something which records audio from the user and then allows them to send it to an email, OR save it to the server -

i know how use as3 record sound user , enable them save computer. however, instead allow them either send email address right after recording (without them having save computer first , find file), or let them save site owner can access (they know happening.). how might possible? these kinds of questions discouraged in community...the best questions ask how accomplish/fix specific things, not general goal this. however, this question may started . need research rest. feel free post new question if hit specific problems in code.

Can a python script execute a function inside a bash script? -

i have bash script provided 3rd party defines set of functions. here's template of looks like $ cat test.sh #!/bin/bash define go() { echo "hello" } i can following bash shell call go(): $ source test.sh $ go hello is there way access same function python script? tried following, didn't work: python 2.6.6 (r266:84292, sep 15 2010, 15:52:39) [gcc 4.4.5] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import subprocess >>> subprocess.call("source test.sh") traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.6/subprocess.py", line 470, in call return popen(*popenargs, **kwargs).wait() file "/usr/lib/python2.6/subprocess.py", line 623, in __init__ errread, errwrite) file "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child rai...

css - 3-dynamic-width-column layout without tables -

Image
i'm trying achieve following layout without success: the requirements are: all 3 columns, red, green , blue, must have dynamic widths, i.e. width must change according content. the gray container must centered , width must dynamic well, depending on content of 3 columns. the html code green column must before other 2 columns in source code. this easy cake using tables, except third requirement, can't manage using divs , css. closest thing i've found " the perfect 3 column liquid layout (percentage widths) ", has percentage widths, doesn't suit need. i found how put the center column first in code http://jsfiddle.net/gamepreneur/bj6bu/ html <div class="main"> <div class="right-float"> <div class="green"> green </div> <div class="blue"> blue </div> </div> <div class="red"...

ruby on rails - Ajax and voting -

i have parent class car , /cars/show page lists of reviews associated it. reviews can voted on. having difficulty getting :votes_count update javascript. /votes/create.js.erb $("#votes").html("<%= review.votes_count %>") // not work /cars/show <% @car.reviews.each |review| %> <p id='votes'><%= pluralize(review.votes_count, 'vote') %></p> <% if current_user %> <%= form_for(@vote, :remote => true) |f| %> <%= f.hidden_field "review_id", :value => review.id %> <%= f.hidden_field "user_id", :value => current_user.id %> <%= f.submit "vote" %> <% end %> <% end %> <br /> <%= review.content %> <% end %> create.js.erb <% @car.reviews.each |review| %> $("#review_<%= review.id %>").html("<%= pluralize(review.votes_count, 'vote...

Flickr API get a limited number of comments -

i'm using flickr api's flickr.photos.comments.getlist method list of comments of photos site. photos using off of flickr.interestingness.getlist method , have hundreds of comments , favorites. i'd 8 comments per request, there way this? also, need clarification on min_comment_date vs max_comment_date arguments. want photos within last 24 hours, argument use , supply it? no,the flickr api doesn't allow list restrictions of comments via web service api. other commands have limiters page/per_page, not comments-list; @ least not @ moment. about date arguments: flickr accepts unix timestamp or mysql datetime date fields, in case. can create timestamps programatically in programming languages, testing can convert values manually via http://www.unixtimestamp.com . hope helps.

php - Image height and width when image not found -

i have following code: <div> <img src="../images/curry.jpg" height="242" width="300" alt="can't find image (http://localhost/images/curry.jpg)"> </div> i trying precisely lay out page so, if image not found, alt text occupy given height & width. 1) how html/css works? 2) if not, since generating html php, there can achieve want? instance, work if check non-existence , instead of img tage, generate fieldset of desired size, containing alt text? the answer first question yes. alt attribute seo purposes, , behaves have seen it. it possible although must warn of additional overhead, there function file_exists() check if image existent. if function returns false instead of echoing image echo " <p>can't find image (http://localhost/images/curry.jpg)</p> " , add style attribute wrapping div states desired width , height <div style='height: 242px;width: 300...

display my json list of customers in asp.net mvc with jquery -

i have customer list object server , want display in view. what's best way this? instance, showing customers in div on page it depends on business , how want display it. there no generic solution this. in case want display json "as is" (don't know why you'd to this, maybe debugging), put inside pre: <div> <pre id="pre"></pre> </div> ... $("#pre").html(json.stringify(jsonobject)); json.stringify work on modern browsers. but, (i insist), there no "correct" answer question, depends on "business" needs.

encoding - decode string encoded in utf-8 format in android -

i have string comes via xml , , text in german. characters german specific encoded via utf-8 format. before display string need decode it. i have tried following: try { bufferedreader in = new bufferedreader( new inputstreamreader( new bytearrayinputstream(nodevalue.getbytes()), "utf8")); event.attributes.put("title", in.readline()); } catch (unsupportedencodingexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } i have tried this: try { event.attributes.put("title", urldecoder.decode(nodevalue, "utf-8")); } catch (unsupportedencodingexception e) { // todo auto-generated catch block e.printstacktrace(); } none of them working. how decode german string thank in advance. udpdate: @override public void characters(char[] ch, int start, int length) throws s...

objective c - XCode Analyzer Warnings Without Details / Line Numbers -

i ran analyzer , found handful of warnings can't associate lines in code. i'm not sure how handle them. clicking on them brings me right file in editor, analyzer summary results tell me much. don't know each of these referring to, , going through code line-by-line not productive (i don't know i'm looking for). object +0 retain counts returned caller +1 (owning) retain count expected incorrect decrement of reference count of object not owned @ point caller object +0 retain counts returned caller +1 (owning) retain count expected object sent -autorelease many times for last warning, removed autorelease, , went away, don't know how release it, since it's used in return statement. - (client*) createnewclient { ... client *client = [nsentitydescription insertnewobjectforentityforname:@"client"inmanagedobjectcontext:datainterface.managedobjectcontext]; ... return client; } what do these, in general? as not owning...

php - How can we find First and last day of a date -

possible duplicate: in php, there easy way first , last date of month? how can find first , last day of date? i have date "01/05/2011". getting date dynamically. know last day of date. '31 or 30 or 28 or 29'. i want find using php... this function may : function lastday($month = '', $year = '') { if (empty($month)) { $month = date('m'); } if (empty($year)) { $year = date('y'); } $result = strtotime("{$year}-{$month}-01"); $result = strtotime('-1 second', strtotime('+1 month', $result)); return date('y-m-d', $result); } call like $month = 3; $year = 2011; $lastday = $this->lastday($month, $year); that give last day of march 2011......

Android Eclipse AVD window won't close -

i'm running eclipse on ubuntu host android sdk plugins. cannot seem close avd window gracefully. i've tried powering down android , gets stuck in endless "power off shutting down" screen. end having start killing processes eclipse ide doesn't particularly like. it known issue eclipse/android sdk/ubuntu? there workaround this? i have same problem, "power off - shutting down" stays on screen forever. as far understand it, don't have shutdown emulator @ all. first time start choose "save snapshot". once it's started close down (simply close window) , persist state snapshot (it takes few seconds). starting point future runs. after choose "launch snapshot" option (and clear "save snapshot" option) when starting emulator , continue left last time. again close closing window , since clear "save" option you'll resume same state. if need 'cold boot', tick "wipe user data...

Why does Postgresql say "schema does not exist" -

how can query work? select weather.id, cities.name, weather.date, weather.degree weather join weather.city_id on cities.id weather.date = '2011-04-30'; error: schema "weather" not exist. weather not schema, it's table! perhaps: select weather.id, cities.name, weather.date, weather.degree weather join cities on (weather.city_id = cities.id) weather.date = '2011-04-30'; postgres complaining join on weather.city_id interpreted table/view called 'city_id' in schema 'weather'

r - Turning a column into rows -

i have , example, data rows <- c(1,1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4,4, 5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6, 7,7,7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9) columns <- c(1,2,3,4,5,6,7,8,9, 1,2,3,4,5,6,7,8,9, 1,2,3,4,5,6,7,8,9, 1,2,3,4,5,6,7,8,9, 1,2,3,4,5,6,7,8,9, 1,2,3,4,5,6,7,8,9, 1,2,3,4,5,6,7,8,9, 1,2,3,4,5,6,7,8,9, 1,2,3,4,5,6,7,8,9) data <- c(1:81) dataset <- cbind(rows,columns) dataset <- cbind(dataset,data) but these 3 columns. this: rows columns data [1,] 1 1 1 [2,] 1 2 2 [3,] 1 3 3 [4,] 1 4 4 [5,] 1 5 5 [6,] 1 6 6 what need table looks this:, row-column being rownrs , column-column being columnnrs , data on it's respectful place [,1][,2][,3][,4][,5][,6][,7][,8][,9] [1,] 1 2 3 4 5 6 7 8 9 [2,] 10 11 12 13 14 15 16 17 18 ...

database - Populating a JSP page with contents from client -

i have server hosting jsp page. can populate it's text boxes client's database? create servlet loads data, puts in request scope , forwards request jsp. if want whenever client opens link/bookmark, in doget() method. or when want when client submits form, in dopost() method. here's example preloads specific product db based on request parameter: product product = productservice.find(request.getparameter("id")); // db access job. request.setattribute("product", product); // it'll available ${product}. request.getrequestdispatcher("/web-inf/product.jsp").forward(request, response); // let jsp display it. map servlet on url pattern of /product you'll able call http://example.com/somecontext/product?id=123 in jsp have set value attribute of html input element display value of input element. since sensitive xss attacks when print plain suggested in other answer, you'd use jstl fn:escapexml() avoid xss attack...

ruby - what is the advantage of EventMachine -

this test case, found em not faster general tcp server the em server: require 'rubygems' require 'benchmark' require 'eventmachine' class handler < eventmachine::connection def receive_data(data) operation = proc # simulate long running request = [] n = 5000 in 1..n << rand(n) a.sort! end end # callback block execute once request fulfilled callback = proc |res| send_data "send_response\n" end puts data em.defer(operation, callback) end end eventmachine::run { eventmachine.epoll eventmachine::start_server("0.0.0.0", 8080, handler) puts "listening..." } and benchmark test: require 'rubygems' require 'benchmark' require 'socket' ...

java - Should I explicitly wake a thread sucking on BlockingQueue.take() for performance? -

i understand having thread sucking elements of blockingqueue using take() method wait element available (unless interrupted). i have 2 questions: i) thread automatically woken-up element becomes available or there delay (i.e., thread checks later)? ii) if there delay, make sense wake thread (by interrupting explicitly example)? thinking latency , performance. there no additional delay. method call returns if element available or thread interrupted. retrieves , removes head of queue, waiting if necessary until element becomes available. returns: head of queue throws: interruptedexception - if interrupted while waiting the blockinqueue doing automatically (impl. of arrayblockingqueue ). // in add etc. notempty.signal(); // in take() while(count == 0) notempty.await();

javascript - backbone.js - simple view -

i'm trying run simple view in backbone.js here code: (function($){ window.templateloaderview = backbone.view.extend({ events: { 'click #add_contact': 'loadtaskpopup' }, initialize: function () { alert('templateloaderview - initialize'); _.bindall(this, 'render'); }, render: function() { alert('templateloaderview - render'); }, loadtaskpopup: function() { alert('templateloaderview - loadtaskpopup'); } }); })(jquery); $(document).ready(function() { window.templateloaderview = new templateloaderview(); }); <div id="add_contact">click here</div> when page loads, alerts alert('templateloaderview - initialize'); , when click div, nothing happens. please tell wrong? there couple of things going wrong. when create view, creates this.el div isn't ...

php - How do I find all YouTube video ids in a string using a regex? -

i have textfield users can write anything. for example: lorem ipsum dummy text. http://www.youtube.com/watch?v=duqi_r4sgwo of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. has survived not 5 centuries, leap electronic typesetting, remaining unchanged. http://www.youtube.com/watch?v=a_6gnzckaju&feature=relmfu popularised in 1960s release of letraset sheets containing lorem ipsum passages, , more desktop publishing software aldus pagemaker including versions of lorem ipsum. now parse , find youtube video urls , ids. any idea how works? a youtube video url may encountered in variety of formats: latest short format: http://youtu.be/nlqaf9hrvby iframe: http://www.youtube.com/embed/nlqaf9hrvby iframe (secure): https://www.youtube.com/embed/nlqaf9hrvby object param: http://www.youtube...

c# - Difference between property Users and IRepository.Users -

i have interface irepository abstract repository. dbcontext class entity framework work first code. public interface irepository { iqueryable<user> users { get; } } public class repository : dbcontext, irepository { public dbset<user> users { get; set; } iqueryable<user> irepository.users { get{ return users; } } } i did not understand user property user in repository class. this code compiles, wonder why. what interface name before name of property? this valid syntax, called explicit interface implementation . it's useful in 2 situations: when implement 2 interfaces same method (check link above) when want "hide" implementation detail in sense. in example, if user have dbcontext reference, see dbset<user> property , able access it, on other hand, if give user irepository - see iqueryable<user> , let's hide what's underneath it. //edit: actually, 1 more usage , used in code well: you...

Installing Sqlite3 for Ruby (Mac OSX 10.5.8) -

i following guide atm - http://guides.rubyonrails.org/getting_started.html#getting-up-and-running-quickly-with-scaffolding when trying create database, got: morgans-computer:blog morgan$ rake db:create not find gem 'sqlite3 (>= 0)' in of gem sources listed in gemfile. run bundle install install missing gems. when try run 'bundle install', more errors: installing sqlite3 (1.3.4) native extensions /users/morgan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:551:in `rescue in block in build_extensions': error: failed build gem native extension. (gem::installer::extensionbuilderror) /users/morgan/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb i have tried install ruby gem sqlite3 (http://rubygems.org/gems/sqlite3-ruby) continues fail. found post on here saying need install c because compiler written in? wasn't sure meant, or how go doing it. any appreciated!! if don't have homebrew installed, set ...

oauth - Twitter Connect & Sending a tweet via PHP? -

i need send tweet via php, need authorize app & login beforehand. how can utilize twitter connect this? straightforward guide here: http://dev.twitter.com/

How to use NSNotification in following scenario (IPhone SDK)? -

considering real life situation, suppose have assigned work 3 people(say person a, person b, person c), instead of waiting them complete task each, want when each person completes assigned tasks, he/she notify me distinctly. can take further decision based on his/her task. i want implement situation in code, out using separate thread , delegates, mean using nsnotification. how can stuff programming, can u solve above situation using code (iphone sdk-objective c)? [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(mymoviefinishedcallback:) name:mpmovieplayerplaybackdidfinishnotification object:self.movieplayer.movieplayer]; - (void)mymoviefinishedcallback:(nsnotification*)anotification { // release movie instance created in playmovieaturl mpmovieplayercontroller *themovie = [anotification object]; [[nsnotificationcenter defaultcenter] removeobserver:self name:mpmovieplayerplayb...

Clicking 'OK' on alert or confirm dialog through jquery/javascript? -

i thinking of writing ui tests in backbone.js , jquery. may not best way it's thinking - automate tests without record , playback - through plain code. the thing made me scratch head using approach this: in 'use-case flow' (of execution) confirm/alert dialogs show up. i'd click 'ok' , continue flow - doable through plain javascript code? how? note: know gui testing libraries exist, want know how using jquery/javascript code, if @ possible. as far know if use standard alert() call cannot trigger "ok" click because alert call blocks normal js event loop. however should able replace window.alert , window.confirm own function nothing: window.alert = function() { console.log.apply(console, arguments); }; place these @ top of js before else loaded , subsequent calls alert() or confirm() call these instead.

filesystems - Mysql link to external resources: .zip an image file -

i need help: have installed easphp on laptop (apache, php, mysql). i'm developing db mobile app (an online market) i need add field link external file staying in dir on file system (cause i'm working in locale). i found tutorial explaining how upload files db using blob type , mime, file staying in folder , on db have fields like, title, description, size, extension , 1 filed pointing file(the application .zip or images .jpg in case need previews). didn't find how that. i don't have yet php interface i'm working through phpmyadmin what kind of type field should use? varchar, text........ where should store file? in generic folder c:\file or somewhere specific (inside apache folder or else) what should insert in field when create record myphpmyadmin: path? c:\bla bla bla simply? do need other fields menage later file mime type or else? thanks lot you can visit uploading files mysql database if store path of file in db . , save file in di...

Deserialize objective-c binary NSMutableArray in python -

i'm putting google app engine webapp in python , i'm seeding database iphone app (sqlite). i'm having bit of difficult on 3 fields defined blob fields , have binary serialized objects in them. (typically start out "bplist" i'm assuming it's binary serialized property list - ones interested in contain serialized nsmutablearray's within them.) i'm suspecting 2 choices a) see how amenable binary format regex style scraping out of values (they text) b) write quick ios app, open database, export data better format any other ideas, suggestions on best route, or (fingers cross) pointers sort of great python egg solves problems. below have encluded sample , tried format reasonably medium - out of bottom need extract (anonymized actual data) street = "1111 address ln #2004" street2 = "" city = "dallas" state = "tx" zip = "75243" country = "" type = "" here's data loo...

SQLite Cursor return NULL if no record found in Android -

i have problem today retrieving data sqlite. here coding public cursor fetchdictionary(string searchword) throws sqlexception { cursor mcursor = mdb.query(true, database_table, new string[] {key_rowid, key_word, key_def}, key_word + "='" + searchword + "'", null, null, null, null, null); if (mcursor != null) { mcursor.movetofirst(); } return mcursor; } above coding if no record found, android prompt dialogbox , force close. there way return "no record found" error message if no record found? do try catch, , replace e.printstacktrace() messages.

c# - how to get the height of multiline textbox increased automatically as form get stretched vertically in WPF -

i m using following hierarchy wpf form - grid - groupbox - grid - multiline textbox can tell me how height of multiline textbox increased automatically form gets stretched vertically in wpf. form resizable user. <window x:class="wpfapp.userfunctions" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:rp="clr-namespace:wpfapp" windowstartuplocation="centerscreen" resizemode="canresize" title="user functions" showintaskbar="false" minwidth="770" minheight="570" width="770" height="550" icon="/wpfapp;component/images/globe.png" name="frmuserfunctions" closing="onwindowclosing"> <grid margin="2" verticalalignment="stre...

"Callback Error: Invalid response from server" from C# ASP.Net application -

i have asp.net application button containing following javascript invoked when clicked:- function calculate() { sectionindex = getselectedradioindex("section"); compositionindex = getselectedradioindex("composition"); callbackou.callback( "calculate" , sectionindex, compositionindex ); } i can verify control reaches last line of function setting breakpoint on it. instead of invoking method in code-behind file... protected void callbackou_callback (object sender, componentart.web.ui.callbackeventargs e) { //blah blah } i dialogue reporting callback error: invalid response server. this dialogue appears 3 times, after page sits there doing nothing (forever, far can make out). i can't find information this. can give me clues or pointers how go diagnosing problem? without seeing signature of calculate callback method shot in dark issues have encounter when invoking web methods javascri...

oop - JavaScript OO issue when accessing instance methods -

i've used few tutorials on oop in javascript. seemed go well, until met following... result of expression 'this.prepareframe' [undefined] not function. ok. i'm using prototype , make use of this keyword. see app.js page here... // plain "main" function called html page, <script>main()</script>. works nicely: function main() { engine = new abstractengine(); engine.init(); } // next creates new instance of abstractengine class. seems work far: function abstractengine() {} // init() method called defined afterwards: abstractengine.prototype.init = function() { this.initloop(); } // remark: i'm using "this", , according debugger, "this" refers abstractengine made instance of. // next, define initloop method: abstractengine.prototype.initloop = function() { setinterval(this.tick, 1000 / 30); } // fine, works fine far. define "tick" method: abstract...

default sort in lucene.net -

my index contains ~4 million recrords. when sort results, query runs slower, not surprising. my question is, there way create index when make call , don't pass sort, sorts field use? thanks. by default lucene returns results in order, depends on relevance. far know, have use boost, sort function or else if other listing order. ever take - results not return faster using sort or boost function.

java - Solving a simple maximization game -

i've got simple question game created (this not homework): should following method contain maximize payoff: private static boolean goforbiggerresource() { return ... // must fill }; once again stress not homework: i'm trying understand @ work here. the "strategy" trivial: there can 2 choices: true or false. the "game" simple: p1 r1 r2 p2 r5 p3 r3 r4 p4 there 4 players (p1, p2, p3 , p4) , 5 resources (r1, r2, r3, r4 worth 1 , r5, worth 2) each player has 2 options: either go resource close starting location gives 1 , player sure (no other player can resource first) or player can try go resource worth 2... other players may go too. if 2 or more players go bigger resource (the 1 worth 2), they'll arrive @ bigger resource @ same time , 1 player, @ random, , other player(s) going resource 0 (they cannot go resource worth 1). each player play same strategy (the 1 defined in method goforbiggerresource ()) ...

java - Testing Conflation of data in Dequeue -

i have data structure implemented involves linkedblockingdequeue need test. suppose have 10 data inserted 1 end , other end retrieve values. these 2 threads run simultaneously. while inserting data possible particular "key" second update comes on key, if value corresponding data has not been retrieved, user should on retrieval new data. i need test operation operating. can tell me how that?

ios5 GM upgrade went bad...how to save my device? -

i have tried follow upgrade ios5 process... didn't realize device must registered in ios developer program. i have registered apple id in program (after upgraded device) - when load device - says unable activate device because device not registered in ios developer program. how should resolve issue? have developer license - , have paid enrollment fee apple. i need figure out how complete upgrade ios5 or rollback device 4.3 in order restore it's functionality. any suggestions? restore using downloaded ios image in xcode organizer. if don't have image, can download them off apple's developer portal.

c++ - Validate string within short range -

i have short integer in string. eg: "123456". there api check whether string contains valid number in range of unsigned short? thanks! simply use stream operators input number: istringstream istr("12346"); short s; if ((istr >> s) , istr.eof()) cout << "valid: " << s << endl; else cout << "invalid" << endl; (needs header sstream .)

compilation - What's NOT in an interface file? -

i under impression "a d interface file contains import of module needs, rather whole implementation of module." me, translates signatures - return types, names , arguments, compiler knows it's valid , linker can dirty work later. running file through dmd , though, strips nothing: import std.stdio; void sayhello(const string name) { writeln("hello, ", name, "!"); } dmd interface.d -o- -h // d import file generated 'interface.d' import std.stdio; void sayhello(const string name) { writeln("hello, ",name,"!"); } hardly paragon of optimization. what, exactly, stripped in interface files? ( header-files added because it's closest thing find.) any function going inlined must have full source in .di file. function going used in ctfe must not have full source in .di file, full source of every function uses - directly or indirectly - must available compiler. also, because of how templates wo...

design - When to truncate strings longer than the storage location allows? -

let's have function inserts records database table string fields of limited length. in general, @ point should truncating strings long storage location, in insert function itself, or @ every point in code it's called? (i'm assuming here truncation of strings long more desirable having exception thrown.) i think depends on function , how accessible is. if it's private function makes own sql library can away truncating in function. if it's in library that, say, team @ work use perhaps need @ least parse string before attempting insert it. if it's public api, shouldn't silently truncating - throw meaningful exception instead.

c++11 - C++ Templates variadic but static -

i training template skills in c++ , want implement vector class. class defined vector dimension n , type t. have constructor takes n variables of type t. can't head around how tell variadic template accept n parameters. maybe possible template specialization? or thinking in wrong direction? thoughts/ideas on appreciated. more thoughts all examples on variadic templates saw used recursion "iterate" through parameter list. have in mind constructors can not called constructors (read comments in answer). maybe not possible use variadic templates in constructors? anyway defer me usage of factory function same basic problem. a variadic constructor seems appropriate: template<typename t, int size> struct vector { template<typename... u> explicit vector(u&&... u) : data {{ std::forward<u>(u)... }} { static_assert( sizeof...(u) == size, "wrong number of arguments provided" ); } t data[...

asp.net mvc - RedirectToAction() with tab-id -

i have web application in asp.net mvc , in there have jqueryui tab forms in. , when submit want return open tab. with me redirecttoaction() create url www.foo.com/cv/edit/9 but want able generate www.foo.com/cv/edit/9#tab-2 i tried redirecttoaction("edit/"+id+"#tab-2"), generates: www.foo.com/cv/edit/9%23tab-2 any1 knows answer? create url, append #tab-2 it. return redirectresult redirect created url: return new redirectresult(url.action("edit", new { id }) + "#tab-2");

javascript - detecting browser scrolling -

how can know when user has scroll on screen? you subscribe window.onscroll event. example: window.onscroll = function() { // user scrolled window };

Java: Public key different after sent over socket -

i'm trying send public key on socket connection in java. while i'm conscious java provides ssl functionality sort of activity, uni assignment; cannot use java implementation. the server encodes public key , transmits client via socket connection. when client receives key , decodes it, appears different. not this, data received client appears different transmitted server. believe giving me problems when attempt encrypt user name , password using key. the problem can reproduced following code: client: public class testclient { /** * @param args */ public static void main(string[] args) { final int sport = 4321; socket sock = null; key serverpubkey = null; bufferedreader clientin = null; // initialise server connection try{ sock = new socket(inetaddress.getlocalhost(), sport); clientin = new bufferedreader(new inputstreamreader(sock.getinputstream())); } catch (unknown...

MySQL: Getting a Query out of the While Loop -

the following simple example of multi-player game many games played on several seasons. game id, player name , score of each player , season being played recorded in table. queries below show how 1 can derive summary of player's rank games played in particular season. select game, score table name='name' , season='season' order game; while(fetching result) { select count(*) 'total', sum(case when score>='score' 1 else 0 end) 'rank' table game='game' , season='season'; } the output contains game , score , rank , total games played player in particular season, order game . wondering whether there more efficient ways instead of using while loop. sorry, got confused column name when first posted. cannot make of optimization here in query itself, because second time want data games, not player trying rank. can add them subqueries/joins first, second query works more 1 row, can done, result in addit...

question on this java code segment -

the following code claimed use loop flag repeat input until valid int obtained. { try { // attempt convert string int n = integer.parseint( s ); goodinput = true; } catch ( numberformatexception nfe ) { s = joptionpane.showinputdialog( null, s + " not integer. enter integer" ); } } while ( !goodinput ); i little confusing logic here. if integer.parseint works fine, or there no exception occuring, "goodinput" assigned "true" @ line of goodinput = true; then !goodinput evaluated false, while loop continue again. seems me contradicts designed logic, i.e., while loop should stop after performing correct parse operation. wrong analysis above. do { } while(x); loops while x == true , i.e. until x == false . therefore, do { } while(!x); loops while x == false , i.e. until x true .

jQuery validate single input and require two strings First and Last name -

i use registration form asks users enter full name 1 input field. php class parses first , last name , inserts our db. found out our billing system doesn't receiving first name have validate form field , make sure there 2 strings entered. fiddle of basic input validation i'm not , writing rule check 2 strings. appreciated thanks http://jsfiddle.net/peter/4x3mx/1/ you try with: $(document).ready(function() { $("#btn").click(function(e) { if (/\w+\s+\w+/.test($("#cname").val())) { alert("good"); } else { alert("bad"); } e.preventdefault(); }); }); fiddle: http://jsfiddle.net/yrffg/

java - How to capture images using LWUIt VIdeoComponent -

i have tried using mediacomponent , since deprecated wont moving forward. not able re-size full screen on form. trying use videocomponent capture screen shot in s40 device. cant find how instantiate videocomponent capturing image , not playing video. you can use videocomponent capturing image. first, instantiate videocomponent, need create native peer: videocomponent videocomponent = videocomponent.createvideopeer("capture://video"); player player = (player) videocomponent.getnativepeer(); player.realize(); videocontrol videocontrol = (videocontrol) player.getcontrol("videocontrol"); to capture image, have start video component , use getsnapshot of video control: videocomponent.start(); videocontrol.getsnapshot(null); if want resize video component full screen can use: videocomponent.setfullscreen(false); other posibility is: videocomponent.setpreferredh(display.getinstance().getdisplayheight()); videocomponent.setpreferredw(display.ge...