Posts

Showing posts from August, 2015

rails 3, how add a view that does not use same layout as rest of app? -

i not find docs or examples on how structure app allow different views in same controller use different layouts , stylesheets. our app scaffolded , used nifty-generators generate views, added devise authentication. have views , controllers 2 models: widgets , companies. i have single layout: layouts/application.html.haml, don't see referenced anywhere assume (a rails newbie) it's used naming convention. i need add couple of views (for mobile browsers) have different stylesheet , layout (for example, no login/logout links in top right), within same controllers. how can done? by default, layouts/application.html.haml ( .erb if not using haml). in fact, layout file set per controller or per action, instead of per view, per view folder. there few cases: to change default layout file controller (ie. use another.html.haml instead of application.html.haml ) class applicationcontroller < actioncontroller::base layout "another" # way l

forms - How to simulate HTTP POST programatically in ASP.NET? -

i need simulate http post programatically, i.e., need generate request post variables , send page. to clarify, need simulate behaviour of regular post, not whole thing programatically. need fill in request in same way filled if form post happening, , send browser page expects post. here 1 way it. you send method url , name/value parameters in form of namevaluecollection. method makes http post on endpoint , returns response string. of course depending on what/why you're doing , how many times method called, there maybe other alternatives. until provide more information on specific needs, method enough. the method below uses tasks (.net 4.0) , async methods faster synchronous method next code listing if you're making multiple calls in loop example. static string getwebresponse(string url, namevaluecollection parameters) { var httpwebrequest = (httpwebrequest)webrequest.create(url); httpwebrequest.contenttype = "application/x-www-form-urlencoded&qu

jQuery - How to translate a Scriptaculous toggle in a jQuery slidetoggle? -

i have simple question (i guess!) i used work scriptaculous add dom effects pages use jquery, seems conflict between scriptaculous , jquery how can translate : <a href="#" onclick="effect.toggle('header', 'blind', { duration: 1.0 }); return false;">link</a> to jquery similar effect? ( slidetoggle() maybe?) <a href="#" onclick="???; return false;">link</a> thank you! onclick = "javascript:$('#header').toggle(100);" assuming have element id header. parameter 100 milliseconds toggle transition. can call slidetoggle().

iphone - NSLocalizedString always fall back to english -

i have project english , french translation. used work fine. reason language fallback english. i tried delete english.lproj , french.lproj folders, regenerate them genstrings : still same issue i tried delete app device, clean target , deploy again, no results. the language of device didn't change since has been set french. p.s: problem similar one, except project used work fine : iphone: nslocalizedstring reading english .strings file when lang set does have idea of ? thanks help, vincent there several details need follow, including in project drag localized files. have @ tutorial step-by-step explanation: http://www.icanlocalize.com/site/tutorials/iphone-applications-localization-guide/

iOS: Sound generation on iPad given Hz parameter? -

is there api in 1 of ios layers can use generate tone specifying hertz. i´m looking generate dtmf tone. link explains how dtmf tones consists of 2 tones: http://en.wikipedia.org/wiki/telephone_keypad which means should need playback of 2 tones @ same time... so, exist: somecleverplayerapi(697, 1336); if spent whole morning searching this, , have found number of ways playback sound file, nothing on how generate specific tone. know, please... check out au (audiounit) api. it's pretty low-level, can want. intro (that gives need) can found here: http://cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html

mdx - Differing NON EMPTY behaviour in Analysis Server 2000 and 2008 -

we run front-end manager information tool connects sql analysis server provide flexible reporting. front-end builds mdx executes on analysis services, , prettifies result table. we upgrading sql 2000 sql 2008 , have come across difference in use of non empty in mdx. this mdx query in question select non empty {[measures].allmembers} on rows, non empty {} on columns sales when run on analysis server 2000 returns list of measure member names rows, when run in analysis server 2008 nothing returned. looking @ mdx think 2008 working expected, , 2000 wrong, has sort of broken our front-end showing nothing in case mdx run (the user expected drag on columns after see, nothing showing, can't this). so, there reason difference. 'bug' in 2000 fixed in 2008? or there configuration option somewhere can affect returned? (essentially want avoid having make change our front-end cope this!) thanks. it's been long enough since i've used ssas 2000 doesn'

html - How to organize code in text editors like dreamweaver and notepad++? -

wanted know to organize html or other code, spaces border. mean keyboard shortcut that, add spaces code make neater ? and thanks to organize code mean wish to achieve better readability . so, you have indent code , in dreamweaver ,i used ctrl+shift+> indent code, or refer these key shortcuts of dreamweaver . notepad++ ,key shortcuts here . refer following links, might solve query: improving code readability

jar to .java conversion -

possible duplicate: where can find java decompiler? can tell me how can convert jar file it's corresponding .java source file? i have jar file unknown source. possible corresponding .java source file out of jar? you can use java decompiler

Using complex variables in django templates -

in template below, user.group number , has shown group_name.get(user.group) there ability pass template group_name dict , use group_name.get(user.group) inside template? <table> {% user in users %} <tr> <td>{{ user.name }}</td> <td>{{ user.age }}</td> <td>{{ user.group}}</td> </tr> {% endfor %} </table> in spirit of django logic should live in code, not in template. can't add method user.get_group() returns group?

Getting information from Yahoo! finance -

i'm trying data currency exchange yahoo! finance in csv format. e.g. there lot of information in this page , when i'm downloading csv file on the url there no such data change, bid, ask, prev close, open, etc. there "n/a" values instead them. how can complete information relevant page? i suggest use yql. thread provides example: help creating yql query search companies

android - TTS reads out received sms, if sms exceeds normal 160 characters - will stop -

as in title. have tts reading out received messages. if message exceeds 160 characters, no read rest (which assume technically second text, linked 1 "big" message network provider) how can modify code if sms bigger standard single message, can read out? here snippet of code public void onreceive(context context, intent intent) { int n; bundle bundle = intent.getextras(); object messages[] = (object[]) bundle.get("pdus"); smsmessage smsmessage[] = new smsmessage[messages.length]; (n = 0; n<messages.length; n++){ smsmessage[n] = smsmessage.createfrompdu((byte[])messages[n]); } string sms1 = smsmessage[0].getmessagebody(); /**send variable class handling tts, read out-loud corresponding method */ speakeractivity.speaksms(sms1); each member of array in example contains 160 character part of message. i

c++ - How to detect if mouse click is legit or automated? -

how know if mouse click simulated or not? when mouse click send program or real mouse device ... i'm programming system detection game avoid bots, autoclicks,etc accept legit mouse clicks this depends bit on kind of application writing, if can, watch cursor movement, not clicks. human mouse movement has non-uniform speeds, reaction times, imprecisions (clicks on different coordinates of buttons, etc...). also, can defend gui against bots randomly requiring interaction hard script. example: if scripts depend upon buttons being in same position, make sure that, while trying remain intuitive, dialog should pop in different positions every time. otherwise: there no way detect if mouse real 1 or simulated one. windows hid/macos/linux driver layer abstracts away distinction between mice, trackpens, trackballs, draw-pads, touch screens... , of course script-mice...

orm - Multiple record deletion using hibernate -

what best way delete multiple records using hibernate.my requirement getting list of uuids , based on need remove records database. since hibernate not have build in delete method can take collection input , work on behalf of us. so looking best possible way achieve this. not going bulk delete option since number of records not gooing high , nor using spring's template has support type of operation. thanks in advance umesh two options come mind: fetch records , call session.delete(..) on each entity use hql delete , clause. have in mind cascades won't handled.

android - How can I add separating lines between my TableRows that are created programmatically? -

i have tablelayout created programmatically in android project. keep adding tablerows long there more rows fetched database. want add separating lines, border, between tablerows. in other tablelayout created statically xml used view separator, style style.xml. i tried adding view tablelayout so: view v=new view(this); v.setlayoutparams(new layoutparams( layoutparams.fill_parent, layoutparams.wrap_content)); v.setbackgroundresource(r.drawable.rowseparator_shape); tr.addview(mtvdate); tr.addview(mtvresult); tl.addview(tr); tl.addview(v); but gets added once after collected tablerows. smart way of adding 1 view each tr added? or should use else alltogether? view v = new view(this); v.setlayoutparams(new tablerow.layoutparams(tablerow.layoutparams.fill_parent, 1)); v.setbackgroundcolor(color.rgb(51, 51, 51)); tr.addview(mtvdate); tr.addview(mtvresult); tl.addview(

blackberry - Add vertical spacing between fields on VerticalFieldManager -

i adding fields verticalfieldmanager. there method of adding vertical spacing between fields? there more elogant ways of doing using setpositionchild() methods simple work around give fields padding using setpadding(int top, int right, int bottom, int left) method. myfield.setpadding(5, 0, 5, 0);

c# - Deleting column causes column does not exist in table error -

i'm populating dataset sql query. fetch columns in query need them further queries. delete columns after im' done them, column "columnname" doesn't exist in "dataset" error when try bind dataset gridview. any ideas cause? edit: here's code actual error message: " column 'bid' not belong table results. " string command = "select b.bid, b.name 'name', b.fare 'fare', b.departure 'departure', b.max_seats 'max', null 'seats available' "+ "from route r, bus b "+ "where r.from_location = @from , r.to_location = @to "; if(_ac) command += "and b.ac = @ac "; if(_volvo) command += "and b.volvo = @volvo "; if(_sleeper) command += "and b.sleeper = @sleeper "; command += "and b.runs_on '%"+day+"%' , r.rid = b.rid"; sqlcommand cmd = new sqlcommand(command, con); cmd.parameters

Are table value parameter from PHP to SQL Server supported in Microsoft's PHP - SQL Server (v2.0) driver? -

does official microsoft sql server driver v2.0 php support table value paramerers? i'd call stored procedure php , pass in table. php sql server table value parameter

syntax - Cant assign new enum value to variable -

i have enum defined so: public enum direction { left, right, up, down } and following variable in class: private direction direction; in constructor, assign variable: direction = direction.right; then, in method in same class, try assign new enum value: direction = direction.down; but won't let me! keeps going right value thought place gets set in constructor! what's going on? o_o edit - more code namespace myfirstgame { public enum direction { left, right, up, down } } using microsoft.xna.framework; using microsoft.xna.framework.graphics; namespace myfirstgame { public class invader : sprite, imovable { private invadertype invadertype { get; set; } private direction direction; private vector2 speed; public invader(texture2d image, vector2 position) : base(image, position, new point(30, 16), new point(0, 0), new point(2, 0)) {

Looking for an svn -

im looking svn allow moderation (no 1 can see commit until accept it), easy integration existing user / acl scheme. the users should not allowed comunicate in way without moderation. is there can use (i have little expirence svns) or have (shiver) write own ? edit : clarification - want software linux :p subversion (svn) particular version control system; commits executed against central server. there "mods" / hacks introduce partial distributed / decentralized versioning (such svk), i'd rather use genuine distributed version control system (dvcs) git or every developer can have separate repository. in dvcs, have "official" branch particular developers can write (i guess done using pre-commit hooks on primary "authoritative" / "official" server or special mechanisms provided dvcs). you have guidelines saying developers should check out / fetch authoritative server when starting work on something. regarding access co

windows 7 - Running Bat file on Win 7 machine -

i have executeable (command line requires arguments/parameters) need run on win 7 machine. can run executeable if right click , choose run administrator. of course, returns error code required command line parameters not found. in addition, executable create error log if has problem, errors out, throws exception, etc. created batch file , added myprogram.exe param it, , right clicked , chose run administrator. nothing.....no return code, no error log. created shortcut on desktop batch file , changed advanced properties run administrator , still nothing. have ideas? need run executable params batch file on win 7 machine. thanx edited: i guess maybe problem batch file, since novice @ well. had 1 line: myprogram.exe myimportfile.txt 1 1 try creating shortcut on desktop cmd.exe there have commandline. right click new shortcut, run administrator. run bat file or exe directly parameters.

Get Center point in my app android -

in app horizontalscrollview present. consist of linearlayout in it, layout have added number of buttons it.viewflipper present in it. flip layout want move horizontalscrollview respective button should center position. layout(s) , number of button(s) same. 1st layout 1st button should @ center location? thnx help.... hmm, okay, point out, when first or last position (possibly first + 1, last - 1 well, depending on button size), won't able have in center, can't overscroll horizontalscrollview. in mind, general case (you can handle edge cases -- i'd suggest leaving scrolled far can, , giving selected button sort of highlight) should able this: displaymetrics metrics = new displaymetrics(); getwindowmanager().getdefaultdisplay().getmetrics(metrics); int screenwidth = metrics.widthpixels; //get instance of linearlayout, hsv, , viewflipper linearlayout ll = (linearlayout)findviewbyid(r.id.my_linear_layout); viewflipper vf = (viewflipper)findviewbyid(r.id.my_vie

java - Android Dictionary upgrade -

can guide me code in git apps in android can add words default dictionary. i thought easy because edit box capable of adding words android default dictionary. solutions found using ndk , not working on htc devices. thank guidance. the userdictionary part of android sdk , can used add words predictive texting.

arrays - What does it mean for .slice() to be a "shallow clone"? -

actionscript's array , vector classes both have slice() method. if don't pass parameters, new array or vector duplicate (shallow clone) of original vector. what mean "shallow clone"? specifically, difference between array newarray = oldarray.slice(); vector.<foo> newvector = oldvector.slice(); and array newarray = oldarray; vector.<foo> newvector = oldvector; ? also, if vector's base type isn't foo, simple , immutable int? update: what result of following? var one:vector.<string> = new vector.<string>() one.push("something"); one.push("something else"); var two:vector.<string> = one.slice(); one.push("and thing"); two.push("and last thing"); trace(one); // something, else, , thing trace(two); // something, else, , last thing thanks! ♥ in context, .slice() make copy of vector, newarray refers different object oldarray , except both seem identical objects.

Safari won't play <audio> if .ogg file is first in the list? -

i have audio object 2 sources, in m4a , ogg formats. the code follows: <audio id="audio1" controls="controls" preload="none"> <source src="music.m4a" /> <source src="music.ogg" /> </audio> i can call document.getelementbyid('audio1').play() , starts playing. it works in browsers. in safari, works if m4a file first source. i.e. if have code ogg file first: <audio id="audio1" controls="controls" preload="none"> <source src="music.ogg" /> <source src="music.m4a" /> </audio> safari won't react play() javascript call, mouse click on play button. is there solution apart putting m4a file first? thanks! have tried telling browser mime type you're using. use "audio/mp4" mime type (don't forget add .htaccess) <audio id="audio1" controls="controls" preload="n

iPhone Simulator: start iPad by default? -

can somehow force specific hardware device when running universal app? whenever rebuild , test, iphone 3 fires , have switch on ipad , rotate device. annoying. a similar question has been asked , answered, check out: how set default device in iphone simulator?

html - Reuse PHP image randomizer -

i wrote simple image randomizer on php picks random image list using rand() function. code works perfectly, , random image generated when include on html picture. the problem comes when try include twice in same html. random image generated , displayed both times included it, same image. in other words, repeated random image on page. an easy way solve copy randomizer.php, give new name, , include both images in html. reason don't want because final html have 25 pictures, , feel there should better way this. keep in mind cannot add php functions html, given files hosted in different servers, , html server not support php. if know of better fix other creating 25 copies of randomizer.php file (or creating 25 different files include it), please let me know. appreciate input!! thank very, much!! here's snippet of code: if (count($filelist) > 0) { { //do-while loop new random image until image has not been used yet in session $imagenumber = rand( 0 , (

asp.net - Firebird Data Provider and Entity Framework in Visual Studio 2010 -

i'm trying use entity framework firebird database in visual studio 2010 useful info: windows 7 64-bit visual studio 2010 ultimate firebird 2.5.0 firebird .net data provider 2.6 ddex 2.0.5 i've done: installed firebird server (and works , can connect database) downloaded ddex (i've run registry files) used gacutil on firebirdsql.data.firebirdclient.dll , checked indeed installed , modyfied machine.config both 2.0 , 4.0 in 32-bit , 64 bit folders include provider in element when try add connection in server explorer choose "firebird data source" , firebird data provider , press continue. "add connection" dialog window fill in info "data source, database, user, password.." , press ok , following error: failed find or load registered .net framework data provider also when try add new entity data model cannot see firebird option.. can see sql options. i need on 1 i've spent many hours on , cannot work.. i'

serialization - Boost c++ serializing a char * -

i have class , trying serialize shared_ptr normal method of serializing object not working: class object { public: object(); ~object(); shared_ptr<char>objectone; friend class boost::serialization::access; template <typename archive> void serialize(archive &ar, const unsigned int version) { ar & objectone; } }; i've attempted in way still doesn't work: void serialize(archive &ar, const unsigned int version) { (int = 0; < (strlen(objectone.get())); i++) ar & objectone.get()[i]; } any ideas how approach this? thanks. some information: i've included both shared_ptr header files: #include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/shared_ptr_132.hpp> i've attempted convert string , serialize in way produces following error: boost::archive::archive_exception' what(): stream error friend class boost::seriali

domain driven design - DDD and Entity Framework - manually building associations -

if manually build our associations have expose foreign keys in our domain model? for example, if retrieve products , categories, way can manually build product.categories property if expose productcategory mapping in model? i'd rather not if there alternative (note eager loading via ef not option have 2 many associations load). you add partial class "product" project , extend "product" entity ienumerable<category> property "categories" (or method returns ienumerable<category> ). this way implement retrieval of "categories" yourself.

dojo - Spring form field errors with Dijit Controls -

i have simple form using spring form controls. using dojotype on controls. ex: <form:input path="salary" style="width:10em" dojotype="dijit.form.validationtextbox"/> i doing form validation dojo. added server side validation spring. trying use springs validation update dijit fields highlighted errors. came with. feels hack , wondering if has better solutions. first on bottom of form have hidden span element lists errors returned spring:hasbinderrors so: <span id="allerrors" style="visibility:hidden"> <spring:hasbinderrors name="myform"> <c:foreach var="error" items="${errors.allerrors}"> ${error.field} </c:foreach> </spring:hasbinderrors> </span> then have dojo function added onaddload spilts string of form fields, removes brackets, , sets dijit class error field this: dojo.addonload(displayerr

mod rewrite - Refactoring a mod_rewrite depending if query string exisits -

rewritecond %{query_string} lang_opt\=e rewriterule /lc/courses.asp english-resource [r=301,nc,l] rewritecond %{query_string} lang_opt\=f rewriterule /lc/courses.asp french-resource [r=301,nc,l] rewriterule /lc/courses.asp english-resource [r=301,nc,l] a link comes in 3 flavors /lc/courses.asp /lc/courses.asp?lang=e /lc/courses.asp?lang=f is there more elegant way deal these 3 variations of link. have quite few of them , 5 line of mod_rewite per seems excessive. thanks since english default, need french , redirect else english: rewritecond %{query_string} lang_opt=f rewriterule ^/lc/courses\.asp$ french-resource [r=301,nc,l] rewriterule ^/lc/courses\.asp$ english-resource [r=301,nc,l]

Getting a random UserProfile In SharePoint 2010 -

i trying retrieve random number of users userprofilemanager. but encountering errors when deploying live servers. can't seem see causing error. code below: for (int = 0; < numberofuserlimit; i++) { userprofile = profilemanager.getuserprofile(random.next(1, numberofuserlimit)); if (up["firstname"] != null && up["firstname"].value != null && !string.isnullorempty(up["firstname"].value.tostring())) { datarow druserprofile; druserprofile = dtuserprofile.newrow(); druserprofile["displayname"] = up.displayname; druserprofile["firstname"] = up["firstname"].value; druserprofile["lastname"] = up["lastname"].value; druserprofile["department"] = up["department"].value;

python - Should class-specific "constants" still be declared at module level? -

in pep 8 , it's stated "constants defined on module level […]". makes sense standard library, constants tend pertain entire module rather particular class (e.g. zlib.max_wbits or re.unicode ). i'm writing module, however, constants related individual classes. the module designed allow python programs work application-specific serialization format in blocks of data arranged "chunks" , chunks further arranged "regions". dimensions of chunks , regions useful constants expose, , had been doing class properties until chanced across line in pep 8. i'm inclined leave them (pep 8 also says "foolish consistency hobgoblin of little minds", after all), want make sure won't too badly breaking users' expectations doing so. (the module hasn't yet been released, backwards compatibility isn't issue.) for reference, "pep 8" style… chunk_size_x = 16 chunk_size_z = 16 region_size_x = 32 region_size_z = 32 de

asp.net - using active directory, NTLM and then accessing the users exchange unread emails -

i building intranet site , want display users email(not complete email), subject, from, date , time. however, first step connecting exchange server using ntlm credentials, same, however, dont want user have type password connect email. is possible , how? any resources/examples me started thanks

Max database name length in SQL Server -

i trying ui validation on database name. told different places sql server database name stored sysname inside sql server. verified checking sys.databases . so, make textbox in ui have maxlength 128 characters long. max length of sysname type. however, found in sql server 2005 express edition, if enter database name 128 characters long, complains could not create default log file because name long to make sure can create database, found need set max limit 124 characters. my question whether 124 characters limit true versions of sql server on different windows os? the log file name not need include database name. this works fine me example. create database [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] on primary ( name = n'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', filenam

mongodb - Indexing schema-less dbs having user-defined schemas? -

one of essential features of database query speed. store data away , want quick access data matches our criteria. however, of late, schema-less databases have become popular. it's 1 thing if have schema-less database there inferred (in-the-head/in-the-app) schema; hasn't been declared formally database. on other hand, let's need open database several users have own schemas own individual problem areas. user define own "domain". domain (a database on rdbms server) have types (tables in rdbms) , types have own properities (columns in rdbms). how create compound indexes pull specific objects/documents/records (what have you) given domain? query should select 1 or more domains (an in clause), 1 topic type (e.g. calendarevent), against columns (start_date >= today, start_date <= today + 1 week, open_for_registration = true, calendar_name = ‘public'). in database fixed schema (implied if not declared), simple: create compound index against column

Books on parallel programming in OpenMP and MPI -

i've been programming c , fortran past 6 years, have done serial programming until now. switch parallel program design, haven't found book me make jump. have looked @ chandra's book on parallel programming in openmp , michael j. quinn's book on programming in c open mp , mpi, wondering if there better alternative these two. in advance! prashanth i can recommend using openmp chapman, jost , van de pas. it's introduction openmp , includes plenty of details on using language , getting best performance. this tutorial might useful introduction if have never experienced parallel programming, it's entry general concepts , ideas.

couchdb - Is it possible to make CouchApp send requests autonomously? -

i want write simple app, witch monitors states of sites. want make in couchapp style without using environment except couchdb. so question how can make couchapp send sites requests using schedule itself ? btw, if fail couchapp, there way make not involving demon stuff (or cron) on php or on java? want keep simple possible, not simpler. you can't in couchdb alone (couchapps can have pure functions without side effects can guaranteed cacheable) can using simple scripts talk couchdb. see this talk mikeal rogers details on how it.

c# - Date Range Calculation .Any Suggestions? -

i need calculate date ranges. i have 3 date ranges: 25 july 11 - 10 oct 11 05 aug 11 - 05 oct 11 20 aug 11 - 08 nov 11 i need create new membership valid periods can before , after what way this? code example public enum membershiptype { gym=1, magazine=2, hotel=3 } class program { static void main() { // during 1st aug 2011 , 20th oct 2011 membership payment must stopped var stoppaymentstartdate = new datetime(2011,08,1); var stoppaymentenddate = new datetime(2011,10,20); var gymmembership = new membership{membershiptype=membershiptype.gym, startdate = new datetime(2011, 07, 25), enddate = new datetime(2011, 10, 10)}; var magazinemembership = new membership{membershiptype = membershiptype.magazine,startdate = new datetime(2011, 08, 5),enddate = new datetime(2011, 10, 5)}; var hotelmembership = n

iphone - NSMutableArray crashes when adding after proper initialization -

i have nsmutablearray defined property, synthesized , have assigned newly created instance of nsmutablearray. after application crashes whenever try adding object nsmutablearray. page.h @interface page : nsobject { nsstring *name; uiimage *image; nsmutablearray *questions; } @property (nonatomic, copy) nsstring *name; @property (nonatomic, retain) uiimage *image; @property (nonatomic, copy) nsmutablearray *questions; @end page.m @implementation page @synthesize name, image, questions; @end relevant code page *testpage = [[page alloc] init]; testpage.image = [uiimage imagenamed:@"cooperatief leren veenman-11.jpg"]; testpage.name = [nsstring stringwithstring:@"cooperatief leren veenman-11.jpg"]; testpage.questions = [[nsmutablearray alloc] init]; [testpage.questions addobject:[nsnumber numberwithfloat:arc4random()]]; the debugger reveals moment use testpage.questions = [[nsmutablearray alloc] init];

c# - call to WCF from multiple threads returns properties with null value sometimes -

i call wcf service multiple threads @ same time, response comes empty. if have 10 threads working in parallel calling service, 1 returs data, rest of them return properties null value. service consumed project in same solution in vs. service refference obtained discovery(so service not hosted in iis). why think behaviour? if allow 1 thread @ time with: mylist.asparallel().withdegreeofparallelism(1).forall(x => worker(x)); all fine, need @ least 5 speed things up. worker method calls wcf service. public void worker(object cui) { mydata mf = null; mf = (new analyseservice.analyseserviceclient()).getdatafromwcfservice((string)cui, true); } on server response correct, when reaches client may have it's properties equl null it turned out vs having problems this.

iphone - Apple ZoomingPDFViewer won't allow dragging until after first zoom -

i'm using sample code view pdf in iphone app: http://developer.apple.com/library/ios/#samplecode/zoomingpdfviewer/introduction/intro.html#//apple_ref/doc/uid/dts40010281-intro-dontlinkelementid_2 however, problem can't seem drag initially. can pinch , zoom initially, , after i've zoomed once, can drag view around fine. can't drag when view first loads. any ideas? i think i've figured out solution, though why doesn't work beyond me. if set zoomscale property, seems trigger whatever needed allow dragging , scrolling take place, if set property 1, nothing. i did in initwithframe: method of uiscrollview: ... self.zoomscale = 1; ... if else knows of better or more correct way this, or has explanation why happens, i'd know.

c# - HttpWebRequest.BeginGetRequestStream() best practice -

i'm working on async http crawler gathers data various services, , @ moment, i'm working threadpools serial httpwebrequest calls post/get data services. i want transition on async web calls (begingetrequeststream , begingetresponse), need way response data , post stats (% completed write, when complete (when complete more important), etc). have event called object spawns/contains thread, signaling http data has been received. there event in webrequests can attach to call implemented event? seamless transition. thanks help!! you passing delegate (as part of async "state" parameter) needs called. after endgetresponsestream need , call delegate parameters need. personally, since you're moving aysnc programming model (i assume better performance) suggest move workflow on to asynchronous well. model allows process results come in , fast possible without blocking whatsoever. edit on blog there article httpwebrequest - asynchronous programming

c# - WPF equivalent to GDI+'s ColorMatrix -

i noticed wpf has system.windows.media(.imaging) namespaces contain lot of same functionality system.drawing(.imagine), don't see equivalent colormatrix in gdi+. don't see way of doing color transformations in general. 1 exist? i'm happy using gdi+ curious. wpf allows write custom pixel shaders. these more versatile colormatrix replicate pixel shader, plus executed on gpu. shazzam ships samples , simplifies process of writing them. just note: wpf more suited creating user interfaces image editing, there's not more members of system.windows.media.imaging writeablebitmap , rendertargetbitmap. if after bitmap image editing features gdi+ , direct2d might more appropriate.

lucene - Querying Raven with Where() only filters against the first 128 documents? -

we're using raven validate logins people can our site. what we've found if this: // context idocumentsession context.query<usermodels>() .singleordefault(u => u.email.tolower() == email.tolower()); the query filters on first 128 docs of documents in raven. there several thousand in our database, unless email happens in first 128 returned, you're out of luck. none of raven samples code or sample code i've come across on net performs looping using skip() , take() iterate through set. is desired behavior of raven? is same behavior if use advanced lucene query? ie; advanced queries behave differently? is solution below appropriate? looks little ugly. :p my solution loop through set of documents until encounter non null result, break , return . public t singlewithindex(string indexname, func<t, bool> where) { var pageindex = 1; const int pagesize = 1024; ravenquerystatistics stats; var queryresults = context

xml - Adding sibling element in ElementTree with Python -

with xml such as <a> <b> </b> </a> i need add sibling of like <a> <b> </b> <b'> </b'> </a> does elementtree has function add sibling node? if not, guess need function parent node , add child node, how can that? in standard lib's version, cannot directly access parent, you'll have work down parent, or keep track of parent-child relations yourself, read these tips (from author of library). if use lxml however, there getparent() method (you have getnext() , getprevious() well), more convenient: there addnext() , addprevious() . so, choose 1 of these solutions, based on elementtree implementation using (or maybe switch implementation)

variables - Error in python replace. (AttributeError: 'tuple' object has no attribute 'replace') -

environment i using python 3 , os windows 7. understand commands have changed transition python 2.7 3 (what have used). problem the variable temporary this: (((((0, 7), 7), 8), 4), 5) here code rid of brackets: randy = randy.replace(")", "") randy = randy.replace("(", "") randy = randy.replace(" ", "") when tries execute replace function, thrown error: traceback (most recent call last): file "<string>", line 248, in run_nodebug file "criptic.py", line 134, in <module> randy = randy.replace(")", "") attributeerror: 'tuple' object has no attribute 'replace' edit: here of code: #import string import string import random #input user data text = input("enter text converted: ") #test print print("-------------------------") print("your text is: ",text) #break data data = list(text) #lowercase count = tex

javascript - Looking for a way to render an outline around flowing text on a web page -

Image
as far know isn't possible. i draw outline around text flowing around floated picture on web page. css or javascript tricks appreciated. horrible mockup: http://i.stack.imgur.com/wf7bw.png . edit: this link demo aloha editor give idea of purpose of outline: http://www.aloha-editor.org/demos/wordpress-demo/ why? in cms i'm working on, users can edit information in contenteditable divs on front end of website. in situation above having outline around entire div create confusion user cannot edit black block. currently have been adding class create outline around content can edited. worked @ first, got little creative formatting (e.g. no margin on bottom of div, content wrapped in div outline) things started getting hacky , ugly. if there way wrap text of div nicely spaced outline , apply consistently on site make things easier. plus i'm @ impasse content structure outlined above. i'm open other ideas besides outline convey users text can edited

copy file from a previous version in the svn repository -

i trying copy deleted file previous version svn repository working directory. i know file present in revision r xxx , because svn log -v , can see old revision number associated file. i svn info find repository name in case of form svn+ssh://repository i svn copy -r xxx svn+ssh://repository name/filename ./filename but complains svn: file not found by default when specify url of file in repository, svn assumes you're referring object in head . command means: locate 'filename' in head trace history of file revision xxx copy file looked then, current directory of course, fails @ first step since file no longer exists in head. need explicitly reference object used called filename in revision xxx , using what's known "peg revision": svn copy -r xxx svn+ssh://repository/filename@xxx ./filename the svn book has a more in-depth explanation of peg revisions , if you're feeling brave...

How Smalltalk deals with DataBases? -

i'm using squeak4.1. how handle database connections? provides similar odbc/ado in .net or j2ee stuff? which packages deal database operations? can give me hints? few links might of use you: squeak smalltalk , databases squeakdbx persistence in seaside (also see chapter 8 in seaside tutorial) magma databases , persistence squeak postresql

bash - Generating a base64 encoded SHA512 digest for a file (or set of files) -

the blackberry webworks sdk tablet os build tool generates archive contains files , manifest.mf entry each file , base64 encoded sha512 digest. however, there bug many files in build cause build failure. trying figure out how generate same information myself. the example below comes manifest.mf , contains filename , digest. however, base64 variant uses _ instead of / , - instead of + , has no trailing == padding. archive-asset-name: air/xx/img_0999.jpg archive-asset-sha-512-digest: yi_kxwjpjwwsi5mdqpebqc9svi-bh6zyq5pgbd3jqiqhu-r-5hv8a0yh_y5j2t9mpyz5tvmw4jxhsxnympv1ta i running windows 7, have git installed have mingw32 bash shell. found piped combination of openssl , tr commands seems bit of kludge. openssl dgst -sha512 -binary img_0999.gif | openssl enc -base64 | tr '+' '-' | tr '/' '_' | tr -d '=' | tr -d '\n' is there better way generate digest? eventually, have images in directory tree. hoping script soluti

Can python modules be used from Java programs using Jython without modification? -

can python code used java using jython, without modifying python code in way prevent working correctly in cpython? if yes, steps have taken (in java code)? if not, reasons cannot done (so far)? python modules can depend on python versions (e.g. python 3 vs python 2 , may require minimum python version (e.g. 2.6) in case of using dedicated language features introduced in python version) python modules may depend on c extensions won't work jython python modules may use cpython features not available in jython in general: python-only code should work jython - in cases: have test, test, test. written modules provide unittests - should try run tests jython , see what's happening.

python - Figuring out what REALLY went wrong when an `ImportError` is raised -

take django instance, in manage.py : try: import settings except importerror: sys.stderr.write("error: can't find file 'settings.py'...") seems legit, happens when settings imports non_existant_lib_foo ? well, you're sent on goose chase possible things have done path , etc. of course can use except importerror e: , print out actual error message, if want catch specific error , give bit of advice, above? you're left using regexp more or less or, @ best, guessing "right" module failed importing, , display message. is there better way handle this? basically problem error message wrong - there other reasons why import can fail, not wrong paths. importerror means "you cannot use module, @ traceback find out why", jumped conclusion. if want display "can't find file" should file first. imp.find_module that.

vb.net - Having trouble installing SQLite -

what need "system.data.sqlite ado.net 4.0", cannot find in home-page. so downloaded "precompiled binary (windows) zip archive " here (i think .net 3.5). now suppose copy sqlite.dll project , add reference. but reason vs-2010 says "cannnot added . please make sure file accessible, , valid assembly or com component." i reffering site you'd need existing sqlite database. create own sqlite databases outside of visual studio, use sqlite admin tool. it's easy use, , if you're familiar sql server management studio , like, you'll easy. design tables, etc, , you'll save file (.s3db). to give application access sqlite database, download system.data.sqlite @ sourceforge page sqlite ado.net provider . install binaries directory c:\program files (x86)\sqlite.net\bin\ . can reference these binaries .net project. system.data.sqlite , system.data.sqlite.linq . this library easy use in .net project. ado.net provider sqlit

javascript - How to get frame's current src using chrome extension? -

i have webpage contains 2 frames:top , main. main frame not under domain, , websites. yes can $("#main").attr("src") reach "first" src, not "current" src. and know it's not possible done javascript due security issue, thinking creating chrome extension it. i tried content script, think can not because it's add js page. is there offer advices? thx i can answer part: i tried content script, think can not because it's add js page. you need set "all_frames": true in manifest: "content_scripts": [ { "js": [ "script.js" ], "matches": [ "http://*/*", "https://*/*" ], "all_frames": true } ], this inject scripts each frame well.

php - facebook upload photo without news feed post? Possible? -

is possible use graph api upload photos facebook without news feed post? i guess can bypass post-if upload photo user's album, , post own news story user's album, example "here new photo xxxxxxx application" profile show news post, , photo upload. make sure first publish photo, publish news story.

python - Django CSRF check failing with an Ajax POST request -

i use complying django's csrf protection mechanism via ajax post. i've followed directions here: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/ i've copied ajax sample code have on page exactly: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax i put alert printing contents of getcookie('csrftoken') before xhr.setrequestheader call , indeed populated data. i'm not sure how verify token correct, i'm encouraged it's finding , sending something. but django still rejecting ajax post. here's javascript: $.post("/memorize/", data, function (result) { if (result != "failure") { get_random_card(); } else { alert("failed save card data."); } }); here's error i'm seeing django: [23/feb/2011 22:08:29] "post /memorize/ http/1.1" 403 2332 i'm sure i'm missing something, , maybe it's simple, don't know is. i've search

debugging - Can I successfully use DEBUG as a constant symbol in C? -

in class work, i've done successfully, in simple programs. today, had more complex program, , eclipse did horrible borky things after defined debug symbol, , these horrible things did not go away after removed definition. i've been told source symbol debug in used gcc compiler, , interfering standard library defining myself. is okay use #define debug myself? or not? yes, ok define symbol debug yourself. not ok define symbol _debug (note leading underscore): symbols beginning underscore , capital letter, or 2 underscores, reserved use implementation (that is, compiler , toolchain). since reserved, should not define them yourself, can test existence. see §7.1.3 of c99 standard. another symbol aware of ndebug , free define or not define, if define before inclusion of <assert.h> , causes assert statements removed.

Do all mysqli PHP functions have mysqli or do some have just mysql? -

i learned there 2 types(?) of mysql functions--mysql , mysqli. on w3schools, mysql functions included in php section http://www.w3schools.com/php/php_ref_mysql.asp . if turn mysql function mysqli function, add on 'i' ? instance, function mysql_select_db(), change mysqli_select_db() same function in mysqli version? if yes, there mysql functions couldn't this? and finally, there mysqli functions don't have mysql equivalent , there up-to-date list of them anywhere? the mysqli_* functions provided mysqli php module superset of mysql_* functions. supersede , replace mysql module, though both available on servers compatibility reasons. mysqli stands mysql improved. in reality, should using pdo new code, not either of these sets of functions. for information despite this: mysql_* function list mysqli_* function list re: w3 schools, please have read of site . quite correct lot of things, including poor php tutorials @ w3 schools. the php