Posts

Showing posts from January, 2014

c# - import and export of dll -

can pls. explain mean export or import dll? when should preferred? , if alternative exist? is possible in c#? thanks. i think in context you're asking dll importing means running code of native dlls within managed .net enviroment. native = code executes directly on x86/x64 cpu magnaged = code run under .net clr. dllimport allows wrap unmanaged function declaration in external dll managed equivalent can call managed code. enabling use native code in managed app. you uses dll export in c++ code identify calls can imported ( msdn link ) http://pinvoke.net/ shows how can use many of windows' built in native dlls in managed code. here microsoft article showing how might use dllimport.

jquery - Help with Image Source replacement using jCarousel -

i'm trying create image gallery website incorporating jcarousel plugin. the general idea have carousel thumbnails in div below div there full size image. i have tested when click image returns alert box (showing me registering click) of yet snippets on net ive seen haven't worked in replacing image in div fullsize copy. has got idea of how can achieve this? main image in div called "imagebox" the list jcarousel id called mycarousel inside div called scrollbox so when 1 of images in mycarousel clicked, image in imagebox replaced file of same name _l @ end of file name (but larger size) any appreciated. all ahve working @ moment : $('#mycarousel1 li img').live('click', function() { alert("clicked") }); to test if click oin carousel works thanks here link adds gallery type functionality jcarousel plugin: http://www.queness.com/post/3036/create-a-custom-jquery-image-gallery-with-jcarousel ...

How to refer a file from jar file in eclipse plugin -

i have created eclipse plugin , wanted deploy during eclipse runtime. have below package structure. com.myplugin | ---resources | ---server.bat as part of plugin job, "server.bat" file should executed. i packaged plugin .jar file including resouces folder in binary , placed in eclipse "plugins" folder. plugin took effect , work fine, have problem while executing "server.bat" file, inside jar generated. error message says: "windows cannot find "resources\server.bat" make sure typed name correctly , try again" i tried relative paths , absolute paths, didnt work. here code doing work: url url = activator.getdefault().getbundle().getentry("/resources/server.bat"); string fileurl = filelocator.tofileurl(url).tostring(); string commandline = "cmd.exe /c start " +fileurl; process process= runtime.getruntime().exec(commandline); i got "fileurl" output: file:/d...

asp.net mvc 3 - dynamic theme in MVC3 -

i have been working on mvc3 new project wanted introduce concepts of dynamic themes. instead of creating bunch of .css files , dynamically linking right one, wanted use <style> section in master <head> section specifies values use selectors , properties. the values pulled database , written header section in style, this: <head> <style type="text/css"> .testclass { color:purple;background-color:lightgreen; } </style> </head> not answer on how achieve end, per se, as suggestion reconsider. have seen approach taken firsthand several times on years, , invariably ends first writing proprietary tool edit database themes , subsequently expensive rewrite extract themes out of database , proper css files. one typical reason go down path of putting styles in database tends desire allow given style "overridden" on case-by-case basis - instance, in application service provider model, 1 customer wants change 1 or 2...

asp.net - Viewstate Disabled - Dropdown box not returning values -

in effort speed site, trying disable viewstate don't think using everywhere. have master page setup user controls loaded (using loadcontrol) in default.aspx. typical page setup be: main.master -> default.aspx -> controlwrapper.ascx -> mycontrol.ascx i have put enableviewstate="false" in default.aspx page. when try , read value dropdownlist in mycontrol.ascx comes blank when form posted. first all, why this? thought should still able read value drop down list? i tried enabling viewstate on control , didn't work. i tried enabling viewstate on page_init event of mycontrol.ascx using page.enableviewstate = true; didn't either. i guess misunderstanding viewstate somewhat, can point me in right direction please? p.s don't know if information relevant adding contents of dropdownlist dynamically in page_load event. (thinking it, issues - test now). thanks. i assume you're using .net 4. view state method asp.net page framewor...

events - C# (outlook add-in) context menu on folders -

in vsto outlook addin i'm trying put button show when right click on folder. in startup function have this: outlook.application myapp = new outlook.applicationclass(); myapp.foldercontextmenudisplay += new applicationevents_11_foldercontextmenudisplayeventhandler(myapp_foldercontextmenudisplay); then have handler that... void myapp_foldercontextmenudisplay(commandbar commandbar, mapifolder folder) { var contextbutton = commandbar.controls.add(msocontroltype.msocontrolbutton, missing, missing, missing, true) commandbarbutton; contextbutton.visible = true; contextbutton.caption = "some caption..."; contextbutton.click += new _commandbarbuttonevents_clickeventhandler(contextbutton_click); } and handler click.... void contextbutton_click(commandbarbutton ctrl, ref bool canceldefault) { //stuff here } my question how send mapifolder folder myapp_foldercontextmenudisplay contextbutton_click ? (if can done way, i'm open suggestions to...

Android live video streaming delay -

i'm trying play axis video stream on rtsp in videoview on htc desire hd. there delay of 7 seconds on video when play on htc desire hd. is there way reduce delay? i have tried play video stream on computer vlc , works delay of 0,5 seconds. when reduced framerate, bitrate , resolution delay still stays @ 7 seconds. have tried functions prepareasync , seekto not them work. has got live video working videoview wrapper or mediaplayer? as far can tell looking through gingerbread (android 2.3.3) source code implementing mediaplayer (which videoview based on), there no way change buffer settings. mediaplayer seems inherently designed playback, gaps , errors must avoided @ costs. live streaming video chat, low latency more important gaps , errors. there effort port gstreamer android, should provide tools doing low-latency video streaming.

mysql - APIs that parse data from email -

i'm attempting create product needs parse particular data fields emails , enter them in mysql database. are there apis can utilised avoid having code scratch? you can use javamail api fetch mails pop3/imap coservers

asp.net - ReportViewer 10.0 on IIS 7.5 not rendering -

we trying move our reports visual 2008 visual 2010, not being capable of making asp.net reportviewer control work on our iis 7.5 machines. os windows 7. we have moved our refernces microsoft.reporting.webforms 10.0 in code , in config files well. our web.config file following sections regarding reportviewer: <system.web> <httphandlers> <add path="reserved.reportviewerwebcontrol.axd" verb="*" type="microsoft.reporting.webforms.httphandler, microsoft.reportviewer.webforms, version=10.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" validate="false" /> </httphandlers> <hostingenvironment shutdowntimeout="30" shadowcopybinassemblies="false" /> <compilation debug="true" targetframework="4.0"> <assemblies> <add assembly="microsoft.reportviewer.webforms, version=10.0.0.0, culture=neutral, publickeytoken=...

c# - Code Conversion from Classic ASP to ASP.NET -

my client have classic asp site on dedicated server on sends mail using iis (its working there). set mail = server.createobject("persits.mailsender") mail.host = "localhost" ' specify valid smtp server mail.username = "mail@site.com" mail.password = "password" mail.from = "info@site.com" i tried converting asp.net this. smtpclient smtp = new smtpclient(); smtp.host = "localhost"; smtp.port = 25; //smtp.enablessl = true; smtp.deliverymethod = smtpdeliverymethod.pickupdirectoryfromiis; smtp.usedefaultcredentials = false; smtp.credentials = new networkcredential("mail@site.com", "password"); smtp.send(message); but doesn't work. legacy app without error logger / monitoring , cannot debug code on online server. what wrong code? this seems permissions issue. check thread details.

applications of mutation testing -

what different applications of mutation testing? mutation testing used "test test cases". idea make small mutations application , run tests make sure catch bugs added these mutations. there explanation examples posted here .

GLSL + OpenGL Moving away from state machine -

hey guys, started moving 1 of projects away fixed pipeline, try things out tried write shader pass opengl matrices , transform vertex , start calculating own once knew worked. thought simple task not work. i started out shader normal fixed pipeline: void main(void) { gl_position = gl_modelviewprojectionmatrix * gl_vertex; gl_texcoord[0] = gl_multitexcoord0; } i changed this: uniform mat4 model_matrix; uniform mat4 projection_matrix; void main(void) { gl_position = model_matrix * projection_matrix * gl_vertex; gl_texcoord[0] = gl_multitexcoord0; } i retrieve opengl matrices , pass them shader code: [material.shader bindshader]; glfloat modelmat[16]; glfloat projectionmat[16]; glgetfloatv(gl_modelview_matrix, modelmat); glgetfloatv(gl_projection_matrix, projectionmat); gluniformmatrix4fv([material.shader getuniformlocation:"model_matrix"], 1, gl_false, modelmat); gluniformmatrix4fv([material.shader ...

Windows 7 driver hooking -

my question regarding driver development windows 7. i need intercept system calls driver. theoretically in such cases it's recommended create filter driver, in case driver doesn't expose filter-compatible interface. it's vista/7 display miniport driver exact. display driver loaded standard wdm driver. in driverentry it's expected call dxgkinitialize system routine (exported win32k.sys guess). goal intercept call. can suggest me useful source can find information how achieve this? the key victory replacing dxgkinitialize within driver executable import section address of function. problem should done after executable loaded (mapped + relocated if necessary + import table entries prepared), before driver's entry point invoked. i thought following options: map executable system memory , "prepare" manually (i.e. work of loader). patch needed function(s) , run entry point. with effort zwsetsysteminformation can used module loading (?) m...

forms - Use PHP to maintain format of a textarea -

hy ho, it possible maintain format of text area php form message mail'd admin formatted nicely. ie. if writes in textarea, dear sir, i writing in connceti.... many thanks, at moment emails dear sir, writing in connceti... many thanks, if not suppose solution rich text editor replacement textarea. thats , good, if javascript disable. any ideas, marvellous you need replace (depending on system): \n\r or \n or \r by: <br /> php function: ln2br()

The pros and cons of localization when submitting an iPhone app -

i wondering pros , cons of submitting metadata , changing ui buttons people don't speak english. according this study there isn't huge percentage of users go stores aren't in english (all smaller countries have stores in uk english). that said, wondering if maybe there advantage this? example, if submit french store assume there less apps metadata in french , therefore might have better chance of getting featured. keep in mind app super simple no network activity , couple of buttons need translate. ps please forgive me if not appropriate question site. , feel free vote migrate. there no disadvantage of providing localised versions of application. it's more question of knowing target audience. generally 1 should assume in country, official language not english, people don't speak english. of course there exceptions germany lot of people speak english. still feel more comfortable using native language. following example, french traditionally ha...

jquery - Not sure why my div is not showing validation messages -

ello stack, cant seem figure out why there isn't text showing in div after validation of field. here code. know validation running but, i'm not sure why validation message isn't showing in div. <html> <head> <script src="scripts/jquery-1.5.2.js" type="text/javascript"></script> <script src="http://localhost:62147/scripts/jquery.validate.js" type="text/javascript"></script> <script type="text/javascript"> "use strict"; $(document).ready(function () { $("#testerbtn").bind("click", function () { alert("onclick fired"); $("#myform").validate({ errorlabelcontainer: $("#errors"), rules: { texttoval: { required: true } }, messages: { ...

c# - Does a List do auto sorting? -

i wondering list auto sort or something? i have list<myclass> myclass = new list<myclass>() myclass.add(anotherclass); myclass.add(anotherclass2); myclass.add(anotherclass3); myclass.add(anotherclass4); so of them myclass object. have in it public class myclass { public string type {get; set;} public string title {get; set;} } list<myclass> first = myclass .where(x => x.type == "first").tolist(); list<myclass> second = myclass .where(x => x.type == "second").tolist(); first.sort((x, y) => string.compare(x.title, y.title)); second.sort((x, y) => string.compare(x.title, y.title)); myclass.clear(); myclass.addrange(first); myclass.addrange(second); so real code sort of looks except "myclass" more complex , have them in foreach loop. when first.sort() , second.sort() objects in correct order based on title. when clear , add "first" objects in first , "second" object second ruins s...

ms access - Dlookup dependant on Label/Textbox -

i trying figure out how can make dlookup function associated label , value of label. my example is: =dlookup("[officeof]","tbllocationmstr","[locationcode]=label content here") and on top of that, need add mid() command this: =dlookup("[officeof]","tbllocationmstr","[locationcode]=mid("label content here")") your textbox have set of controls if label attached. =dlookup("[officeof]","tbllocationmstr","[locationcode]='" & me.textbox1.controls(0).caption & "'") you have determine name of textbox on form. used textbox1 example.

asp.net - How to reset ListBox.Rows property to default (without hard coding the default value) -

i have asp.net listbox on page, , postbacks occur, change items in list. if there >= 10 items in list, set rows property = 10. if there less 10 items, i'd set rows whatever default value rows. i see examining reflected code default value 4, i'd rather not hard code 4 in code , instead somehow reset default. is there way this? you can fetch default value during page's init phase. documentation : in stage of page's life cycle, declared server controls on page initialized default state; however, view state of each control not yet populated. so can like: private int _defaultrows; protected void page_init(object sender, eventargs e) { _defaultrows = yourlistbox.rows; } protected void page_prerender(object sender, eventargs e) { if (yourlistbox.items.count >= 10) { yourlistbox.rows = 10; } else { yourlistbox.rows = _defaultrows; } }

c# - How to pass value from visible = false textbox? -

i set textbox visible = false on textbox holds value. when trying convert value , input query fails in visible=false. proper way since not it. here code passes 2 textbox values query. private void cmdaddadd_click(object sender, eventargs e) { dataclasses1datacontext db = new dataclasses1datacontext(); int interestskey; interestskey = convert.toint32(interestskeytextbox.text); interestadd newadd = new interestadd(); newadd.casenumberkey = casenumberkeytextbox.text; newadd.interestskey = interestskey; db.interestadds.insertonsubmit(newadd); db.submitchanges(); loadcasenumberinterestskey(interestskey, newadd.casenumberkey, false, "interestadd"); this.interestadddatagridview.endedit(); this.interestadddatagridview.refresh(); } i set textbox behavior visible = false. thanks, kor you can use these alternatives:...

Import variables in python -

i ran python script create dict variable based on database, , pickled variable disk file later usage. have lot of feature classes need variable create different features. thing dict variable large cannot afford import multiple times. wondering if there way can unpickle , import variable once, , feature class can share it? python import module once. code executes @ load time executed first time file imports module.

php - How would you use jQuery autocomplete with a MySQL database -

i want use terms stored in table called terms id , term columns how use autocomplete database instead of array? <!doctype html> <html> <head> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <script> $(document).ready(function() { $("input#autocomplete").autocomplete({ source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] }); }); </script> </head> <body style="font-size:62.5%;"> <input id="autocomplete" /> </body> </html> you can arra...

cocoa - NSDocument subclass "close" method called twice -

i have document-based cocoa application subclasses nsdocument mydocument . each mydocument manages separate background process (as nstask ). want make sure nstask terminated when corresponding mydocument closes or when whole application quits. for latter, make document observe nsapplicationwillterminatenotification. former, override close method: -(void)close { // cleanup code here [super close]; } (incidentally, can't put cleanup code in dealloc method since project gc'd.) the problem this: if open mydocument , make unsaved changes , press cmd-q, close method called twice . debugger, call chain is: [mydocument close] calls [nsdocument close] , calls [nswindowcontroller _windowdidclose] , calls [mydocument close] again. (after call, application quits). is expected behavior? if so, there better way release document-specific resources? or should make close safe run multiple times? i believe i've seen post cocoadev mailing list ...

apache - Django Image Upload Fails...File not written to directory (weird bug) -

i have django model supposed upload image media directory on server via imagefield. i've done before on linux server. in case, i've changed group www-data , changed permissions g+w allow apache write files specific media folder media root. when save model via both admin portal , modelform in frontend of site, model validates. expected, link file stored in database. file isn't written. this confusing because a) working on local server , b) have different model saves , writes image server. can't figure out why both of things working while other image upload failing. here model: class post_photo(models.model): post=models.foreignkey(post,blank=true,null=true) photo=models.filefield(upload_to="post_photos") def __unicode__(self): return str(self.post) here settings file: media_root = '/home/public_html/media' the directory post_photos lives @ /home/public_html/media/post_photos. said, made c...

html5 - Javascript/HTML 5 Slider steps issue -

i have html 5 slider designed (or should be) change width of line in canvas im painting app im creating. have issue. on moving slider initial position jumps middle i.e. 5 , stuck there, removing steps numbers 1-10 in between. below code have: html: <input type="range" name="penwidth" id='penwidth' min="1" max="10" value="1" step="1" onchange="this.value='';" /> <span id="range">1</span> js: function brushwidth() { var varwidth = document.getelementbyid('penwidth').value; context.linewidth = varwidth; document.getelementbyid("penwidth").value = newvalue; } when slider in 1 (default position line daw 1 width , when move , jumps position 5 line width of 5 know works fine slider having problem. if remove following html code slider moves in steps fine nothing: onchange="this.value='';" i hav...

c# - How to list all files in a directory Silverlight -

i need quick code see files listed when run code current directory. i have sqlite database file silverlight application use don't know put can't find directory application working from. can me out here? generally cannot access local filesystem in silverlight - runs in it's own sandbox. should able deploy sqlite db part of solution, it's available sandbox. or can expose db via webservice, , silverlight app can use service calls talk db.

javascript - How do you alter editing line of textarea? -

Image
is possible alter line user on in textarea, separate other line in textarea? image demonstration: click here image... if possible, mind showing me on http://jsfiddle.net/ ? thanks in advance. expanding on 1 of previous answers, , borrowing code this answer : live demo (v0.2) known bugs/limitations: only tested in firefox 3.6.x requires field_selection jquery plugin (plain javascript code caret position pain) matches lines begin same current line. (likely fixable) if cursor on blank line, not fade anything out. (likely fixable) if cursor @ end of line, fade everything out. (likely fixable) only triggers on keyboard actions (not mouse) (didn't code part yet, may not possible) does not play nicely mouse. (due z-index , focus) doesn't work if there's 1 character on line (silly mistake on part) jquery/javascript isn't strong area, if can provide fixes working better, i'd appreciate it. :)

sql server - SQL and Google Charts - Given a series of dates, scale date range -

i'm using google charts create graphs , it's working well. problem i'm having when have large date range. x axis displays series of dates. it's fine 1 , 2 weeks (only weekdays, either have 5 or 10 dates) when start month(s) range, dates overlap 1 , it's unreadable. ideally, on 2 weeks, i'd 10 significant dates. example, if series dates 6/1 - 7/15, i'd x axis on graph display like: 6/1 | 6/5 | 6/10 | 6/15 | 6/20 | 6/25 | 6/30 | 7/5 | 7/10 | 7/15 with google charts, have specify series of data, can't provide start , end date , have scale appropriately. fyi - i'm using sql server stored proc obtain data i'd able calculate dates on database side. ok understand requirement , here piece of code form string separated ";" can return sql server sp! begin declare @dt1 smalldatetime declare @dt2 smalldatetime declare @intdays int declare @curdt smalldatetime declare @interv int declare @outtext varchar(10...

iphone - Problem with singleton -

i have singleton @interface cartesmanager : nsobject { nsmutablearray *carteman ; nsinteger indexcartecourante ; nsinteger numimage ; bool iseditable ; } i want change contents of last cell of array "carteman. took last box of array. -(void)donebutton :(id)sender { int valeur ; valeur = ([[cartesmanager sharedinstance].carteman count] -1 ); carte *unecarte= [[[cartesmanager sharedinstance].carteman]objectatindex:valeur]; //expected ":" before ";" token switch (indexsectioncurrent) { case 0: unecarte.titre = textfield.text ; break; case 1: unecarte.nom = textfield.text ; break; case 2: unecarte.prenom = textfield.text ; break; case 3: unecarte.adresse = textfield.text ; break; case 4: unecarte.phone = textfield.text ; break; case 5: unecarte.mobile = textfield.text ; break; case 6: unecarte.mail = ...

class - Override default behavior of comparison operators in JavaScript -

i have custom javascript class (created using john resig's simple javascript inheritance ). want able compare 2 instances of class, using == , < , > , >= , , <= symbols. how override comparators of custom class? this cannot done in way implying should done (though sweet). best way have seen done implement on prototype set of methods act comparatives: gte : function( obj ){ // greater or equal // return custom comparison object comparable on left }, gt : function( obj ){...}, // greater not equal eq : function( obj ){...}, // equal // etc. i thinking problem somemore @ work today , there alternate way take advantage of standard comparison operators have custom object comparisons. trick have property (getter) on object represented comparable state. require instances of object evaluate same numeric value given same comparable properties. example let's talk vectors: function vector(x,y,z){ this.comp = function(){ // assuming these floats ma...

asp.net - .net webservice needs to authenticate Android client -

i have android app talks .net 2 webservice (iis7) using http , managed make run on https using self-signed server certificate (but not requiring client certificate). see http traffic encrypted , looks secure. options have on how authenticate client? example, block webservice access internet explorer on pc. client-authenticated tls handshake described here way go? how can accomplish that? advice or example appreciated. well, given each user should authenticate anyhow, want setup sort of per-user authentication strategy variety of reasons. first, given might distributed app, having single "gold master" authentication certificate or credentials fail hack -- either grabbing cert or grabbing account. , do? second, not particularly hard handle. can use asp.net membership it, , take credentials number of ways depending on nature of service. third, alot easier manage client certificates.

http - JavaScript key undefined in IE over SSL -

i'm working on web app works fine inside lan using http when test remotely on ssl fails ie (7 & 8). firefox, camino , safari work perfectly. i've tracked down issue key being undefined. relevant bit of code is: function showresult(e,str,num) { var key = (window.event) ? e.which : e.keycode; if(((key > 32 && key < 58) || (key > 64 && key < 91) || (key > 95 && key < 123)) && (str.length >= num)) { any clues why key undefined ie on ssl works fine on http? better yet, can tell me how overcome problem? fwiw, don't need support ie prior version 7. update: there answer suggested replacing var key = (window.event) ? e.which : e.keycode; with var key; e = e || window.event; key = e.keycode || e.which; that works. problem can't accept answer because has been deleted. ok, i'll re-add answer, though wasn't mine, , add info along way can feel ok accepting if wasn't answer b...

java - findViewById crashing when using a custom view with <merge> and <include> tags -

i trying make custom view using xml retrieve properties , edit them. custom view added test2 view several times different id's each. have tried retrieve id 1 of these custom views (player_1) textview (player_name), , edits properties , no other views player_2 id view. but not sure this possible? renders fine, error every time try in code. i'm not sure how approach this, can't seem inflate work either test instead. ideas? thanks! game.java setcontentview(r.layout.test2); view player1 = (view) findviewbyid(r.id.player_1); textview player1name = (textview) player1.findviewbyid(r.id.player_name); player1name.settext("john"); test2.xml <include layout="@layout/player_view" android:id="@+id/player_1" /> <include layout="@layout/player_view" android:id="@+id/player_2" /> player_view.xml <?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="h...

java - Problem with Android project -

when attempt create android project first time, error saying "an sdk target must specified. looked on internet, , couldn't find fix problem. in android sdk manager, have downloaded every available package, , none of htem fixed problem. at console window @ bottom of eclipse, these errors: [2011-04-11 20:09:57 - sdk manager] warning: ignoring platform 'android-11': android.jar missing. [2011-04-11 20:22:22 - com.android.ide.eclipse.adt.internal.project.androidmanifesthelper] unable read c:\program files (x86)\android\android-sdk\androidmanifest.xml: java.io.filenotfoundexception: c:\program files (x86)\android\android-sdk\androidmanifest.xml (the system cannot find file specified) did not install correctly? thanks in preferences window, select android in menu on left. on right side of window, click browse, find location of android sdk on hard drive, , enter in sdk location field. eclipse needs information able access tools supplied android, such em...

C++ program not responding to tile/cascade window from task bar -

i have complicated program in c++ (hybrid of old-school win32 , wtl) not respond taskbar tile/cascade request (i.e. right click on task bar , select "cascade windows" or "show window side side"). when use spy++, found none of window receiving window message, while other programs (in case, firefox) series of wm_getminmaxinfo, wm_size, wm_paint ... my frame window styled ws_overlappedwindow. create several hidden windows before creating frame window. have tested on multiple different os'es , symptoms same. there limitation or prerequisites windows shell send out messages frame window? windows sends messages window represented taskbar button. in app, , i'm guessing bit here, 1 of hidden windows represented taskbar button. window manager won't send of these messages hidden window. you can solve problem arranging main window 1 represented in taskbar. can read gory details of windows appear in taskbar in excellent msdn topic titled wind...

python - How to restart a guess number game -

i using python 2.7.1 i able restart game based on user input, option of restarting, instead of exit game , open again. can me figure out??thanks import random the_number = random.randrange(10)+1 tries = 0 valid = false while valid == false: guess = raw_input("\ntake guess: ") tries += 1 if guess.isdigit(): guess = int(guess) if guess >= 1 , guess <= 10: if guess < the_number: print "your guessed low" elif guess > the_number: print "your guessed high" elif tries <= 3 , guess == the_number: print "\n\t\tcongratulations!" print "you took",tries,"tries!" break else: print "\nyou guessed it! number was", the_number,"\n" print "you took",tries,"tries!" break el...

python - How to select only certain tag and text using xpath? -

for example, html block: <p><b>text1</b> (<span><a href="#1">asdf</a>text2</span>)</p> i need select tags "a" , rest must plain text see in browser: result = ["text1", " (", <tag_a>, "text2", ")"] or that. tried: hxs.select('.//a|text()') in case finds tags "a" text returned direct children. at same time: hxs.select('.//text()|a') gets texts, tags "a" direct children. update elements = [] in hxs.select('.//node()'): try: tag_name = i.select('name()').extract()[0] except typeerror: tag_name = '_text' if tag_name == 'a': elements.append(i) elif tag_name == '_text': elements.append(i.extract()) is there better way? is kind of thing you're looking for? you can remove desc...

gwt - I want my CheckboxCell to control the selected state of each row -

i've got celltable column rendered checkboxcell . want check boxes select rows. the default behavior checkboxcell(false, false) tantalizingly close goal - selecting row checks checkbox, , de-selecting row unchecks checkbox. however, if click checkbox , unselects already-selected rows. worse, when uncheck checkbox, row not deselected. argh! i'm looking @ coding own cell (or messing selectionmodel?), seems behavior google might have been trying for. i've tried every permutation of values in constructor, no avail. there simple override can add make dream... reality? you know how can search 30 minutes, , 20 seconds after post question find answer? well, turns out unleash power of checkboxcell, need pass handler equipped deal complexities of situation. try setselectionmodel(selectionmodel, defaultselectioneventmanager.<t> createcheckboxmanager()); with multiselectionmodel selectionmodel - selectionmodel not enough!

java - Problem displaying components of JList -

i trying dsiplay twitter timeline in jlist component. have fixed size of frame , cell height , cell width of jlist following code. jlist.setfixedcellheight(50); jlist.setfixedcellwidth(70); i find height , width of each cell fine if content of tweet inside cell exceeds width not displaying further part of tweet. for example: assume 70 width fits tweet "i good" suppose if tweet "i , great" tweet getting displayed "i good....." exceeded part of tweet not getting displayed. what want here is, want rest out part of tweet displayed below line have sufficient height display tweet in second line. in same example, within cell, want content displayed "i good and great" how can achieve this? you need custom listcellrenderer returns component supports multiple lines of text. default renderer returns jlabel single-line only. can implement f.i renderer returns jtextarea

networking - Minimal FOSS RTOS with TCP/IP, SSL, USB and basic file-system support for ARM -

here's candid admission first -- know zilch rtos or embedded programming, folks know better may me frame query more appropriately. what minimal foss rtos (or os matter) support tcp/ip, ssl, usb , basic file-system low-end arm devices cortex-m3's ? have not ruled out arm9/arm7tdmi, rtos has "optional" mmu support, may major plus. @ present dabbling few uncertainities precise processor, mmu/no-mmu, running head-less (no display), wanted start little ramp-up. would gladly answer counter questions clarify requirement. i believe ecos has support need , scalable. alternatively build self-selected kit of parts; choosing independent rtos, filesystem, usb, etc. different sources, , integrating them yourself.

Make jquery autocomplete not to fill the input value with the label of selected item -

is there way make jquery autocomplete plugin respond "select" callback, not fill target input label value of selected item after user selection? i trying still no success, waiting help... regards. larry demo on js fiddle $('#ac').autocomplete({ source : ["hello", "how", "do", "you", "do"], select: function(event, ui){ settimeout(function (){ $('#ac').val(''); }, 1000) } })

javascript - jsTestDriver + Nant = test directory issue -

i working on project javascript becoming more complex, , needs tested part of our automated build. now have got project structure shown below: - root |- build.xml |- tools |- js-test-driver |- js-test-driver.js |- js-test-driver.conf |- src |- code |- projectname.web |- assets |- javascript |- my-javascript-files.js |- tests |- projectname.javascript |- my-javascript-tests.js in nant build kick off java using pass js-test-driver.js file, arguments use config file provided. noticed when running config file paths seem relative js-test-driver directory, not project root directory. i didnt think issue, , put following in config file: server: http://localhost:9876 load: - ../../src/code/projectname.web/assets/javascript/*.js - ../../src/tests/projectname.javascript/*.js now if run task in nant, starts test driver (in firefox currently) fine fails, saying cannot find ...

javascript - Autocomplete hover removing autofill -

Image
i'm trying alter behaviour of autocomplete little. i've got mock here http://jsfiddle.net/ekzmn/6/ producing desired result (a la chrome address bar) - pictured below (currently case sensitive). the problem i'm having when autocomplete list showing , hover on items in list, input value changes inputted term rather staying on adjusted term autofill. i.e. in above image change hackn [ey, eastern cape, south africa] hackn . i guess bit of default autocomplete behaviour need overide can't work out. i've tried focus: false , blur: false no avail. thanks. is you're trying achieve - input text change based on hovered item? http://jsfiddle.net/ekzmn/8/ override focus event: focus: function(event, ui){ $("#location").val(ui.item.label); return false; }, if want text set first index , not change whenever hover on list, can set first index of result list.

How to create multirow & multicolumn bitmap layout on Blackberry -

i have 8 bitmap , want put 4 of them first row, rest second row... can me use tablelayoutmanager? see blackberry developer knowledgebase article: create rich ui layout tablelayoutmanager it's pretty simple class work with, if you're familiar rim's thought process (lol)

c - Is using enums safe in all compilers? -

in discussion, colleague told me never uses enum because experienced some c-compilers don't cope enum statement correctly. he couldn't remember compiler had problems among problems, there errors when doing like enum my_enum{ my_enum_first = 5; my_enum_second = 10; }; i.e. initializing enum values instead of letting compiler automatic assignment. 1 compiler decides how big enum , therefore have unpredictable behavior sizeof my_enum when compiling code under various platforms. to around that, told me better use #define s define constant elements. using doxygen it's quite handy have enum (e.g. function parameter) because in generated documentation, click on my_enum , directly jump description of my_enum . another example code completion, ide tells specify valid parameters functions. know – long you're compiling code c-code – there's no type-safety (i.e. specify 5 instead of my_enum_first ), use of enum seems more cosmetic thing. the questio...

Error Using Phusion Passenger - Could not find sqlite3-ruby-1.2.5 in any of the sources (Bundler::GemNotFound) -

i have got ror set on server using phusion passenger , default ror applicatioon page shows, when click 'about application’s environment' error saying 'ruby (rack) application not started' , under error message bit 'could not find sqlite3-ruby-1.2.5 in of sources (bundler::gemnotfound)'. if 'bundle install' @ command line list of 'using x (y)' style messages including this: using sqlite3-ruby (1.2.5) (i had downgrade 1.2.5 due issue latest one) i dont understand why getting error above sqlite3-ruby there. stack trace on error page: 0 /opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/spec_set.rb 87 in `materialize' 1 /opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/spec_set.rb 81 in `map!' 2 /opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/spec_set.rb 81 in `materialize' 3 /opt/ruby-enterprise-1....

call flock with node.js? -

i have cron job run node.js scripts. want use flock lock file make sure cron jobs not overlapped. any module doing file locking ? or should call in child process ? or should not file locking ? sorry, new , not sure file locking async env node. thanks see flock function in fs-ext package: https://github.com/baudehlo/node-fs-ext

iphone - Call Delegate method from UIPopover -

i have popover gets loaded navigation controller, displays itemsview xib, , have delegate method popover can dismissed main view controller. works fine, until drill down next level in uitableview (which loads detail view). once detail view loaded, can not call dismiss method on main view controller. quite new delegates , appreciate guidance. thank you! mainview ---> itemsview -----> detailview how call delegate method located on mainview detailview? //load popover first view: itemsview *popoverview = [[itemsview alloc] init]; uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:popoverview]; self.popovercontroller = [[[uipopovercontroller alloc] initwithcontentviewcontroller:navcontroller] autorelease]; popoverview.delegate = self; [navcontroller release]; [popovercontroller setpopovercontentsize:cgsizemake(450.0, 300.0)]; [popovercontroller presentpopoverfromrect:addbutton.frame inview:self.view permittedarrowd...

mouseevent - jQuery countdown pause and repeat -

i'm trying code feature page, i'm not able put pieces :-( all want simple counter counts 0 , show message (.confirmation). if disrupt (move mouse or touch keyobaord) counter pauses , show different message (.warning) , after few seconds repeat counting begining. ufff... i've element monitoring user action , conter don't know how add together: //monitors user action $('.warning, .confirmation').hide(); $(document).bind('mousemove keydown', function() { $('.warning').show().delay(2000).fadeout(500); }); //counts example 5 seconds (this value in <span></span> in html section) var sec = $('#box span').text() var timer = setinterval(function() { $('#box span').text(--sec); if (sec == 0) { $('.confirmation').show(function() { $(document).unbind(); }); clearin...

Sql query in ASP.NET -

i using following query update record in asp.net, what's wrong it? dim updatesqlstring string = "update subscriber_communication set([[marketing_rec_id]=?, [currently_own]=?,[purchase_date]=?, [interested_in_owning]=?, [product_of_interest]=?," & _ "[time_frame_to_own]=?, [referred_by]=?, [campaign_code]=?,[last_update]=?, [record_created_on]=?, [comments]=?, [comment_date]=?, [community_id]=?," & _ "[certification]=?, [subscriber_type]=?, [unsubscribe_comment]=?" & _ "where [communication_id]=" & communication_id using conn new sqlconnection(connstring) using cmd new sqlcommand(insertsqlstring, conn) cmd.commandtype = commandtype.text cmd.parameters.addwithvalue("marketing_rec_id", marketing_rec_id) cmd.parameters.addwithvalue("currently_own", currently_own) cmd.parameters.addwithvalue("purchase_date", purchase_da...

Changing shape of textview in Android framework -

i working on android frameworks. need modify shape of textview such should have rounded corners. can please me issue? xml file saved @ res/drawable/gradient_box.xml: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startcolor="#ffff0000" android:endcolor="#80ff00ff" android:angle="45"/> <padding android:left="7dp" android:top="7dp" android:right="7dp" android:bottom="7dp" /> <corners android:radius="8dp" /> </shape> this layout xml applies shape drawable view: <textview android:background="@drawable/gradient_box" android:layout_height="wrap_content" android:layout_width="wrap_content" /> this applicatio...

How can I update a source file (with classes) in interactive python -

simple python question. when in interactive mode, i'm test imported file, let's use: from foo import foo but in same time edit code. how can update script once loaded interactive python? when try reimport it, nothing happens , i'm still on old files. thanks help. edit: ok, understand reload(modulename) works fine, but... if i'm trying reload class methods? it's written in documentation: if module instantiates instances of class, reloading module defines class not affect method definitions of instances — continue use old class definition. same true derived classes. but there's no word how update class methods. idea? the answer's here how reload code of method of class object in python? no more question works fine :) did take @ question? reloading changed python file in emacs python shell libraries in python path can updated reload(modulename).

asp.net mvc 3 - Calling another Controller post method -

i using asp.net mvc 3 website. i have created partial view has "previous, next , save" buttons. calling partial view on master page. my requirement on ever view must able call different save methods in different controllers passing respective model data controller actions. example i have 4 step data input, have different controller each step. if on step 1 , click save form values should go step1controller 's action method, if on step 2 post should call step2controller something this: public actionresult save(genericmodel model) { //use reflection find out model type //call appropriate controller action model return redirecttoaction("create", new { controller = "conference", action = "create" }); } this save method called save button on master page . how can achieve this? are forms on separate actions on controllers? if so, set form action on each page point relevant controller. form 1 is ...

iphone - how to implement two different animations on same sprite in cocos2d -

i'm confused on using animations in cocos2d... i've sprite has 3 types of animations, smiley laughs, cries , winks eyes... , have separate sprite sheets each of these animations... how able use these animations on same sprite... can me please??? regards, suraj it easier have animations on same sprite sheet, as, if sprite using ccbatchnode it's draw method, you'd have remove child 1 sheet, , readd another. in ccsprite subclass, set ccaction's instance variables. in initialization method, write actions , store them instance variables. then when want use animation, tell sprite run it. e.g. nsmutablearray *smileframes = [nsmutablearray array]; [smileframes addobject:[[ccspriteframecache sharedspriteframecache] spriteframebyname:@"character_smile.png"]]; [smileframes addobject:[[ccspriteframecache sharedspriteframecache] spriteframebyname:@"character_smile2.png"]]; [smileframes addobject:[[ccspriteframecache sharedspritefram...

Semantic HTML markup for menu button (html5) -

what best way markup menu button? idea have button text "add" fold out , show options can add. i <menu> html5 tag label attribute doesn't sit me mean text show if piece of js has been loaded places text (ok use css generated content, doesn't work in ie7/8). i thought <dl><dt>add</dt><dd>...</dd></dl> construction don't think covers wanted semantics. do have ideas? you can place actual element inside label , still maintain proper relationship between two. for example: <label for="elementname"><element name="elementname" attribute="" attribute="">element label</element></label> similar how 1 markup radio buttons. attempt sort of approach first, however, simple unordered list might looking for, rather definition list, definition list need specify dt , dd each item.

how to create help system in java -

we developing new web application , must integrate in it. know opensource application can integrate in our system or better develop center scratch? using java 1.6. must related articles, forms,... thx some years ago, worked eclipse system . eclipse not needed integrate in project. helpfiles based on .html pages. unfortunatly dont know if continue developing it, @ time provided aspects expect system. there lot examples out there on how integrate in project, possible, maybe there better frameworks today.

Help: HOWTO Test Android App from within Emulator with Different Mobile Web Broswer Engines? -

i have developed mobile application using jquery mobile. have working in emulator using default web browser engine. now, want test app using different browsers engines available on mobile devices. have seen accomplished other developers, such opera, chrome, or safari. happening these different browsers being pointed android emulator running application. can provide link on how accomplished may follow steps? have searched net , can seem find solid information explains enough me follow. thank reading post. you can use emulator browse web , go websites browser packages install other apps in virtual phone. alternatively can use ddms transfer .apk files virtual mobile phone, , install them without using internet on emulator. then, when have application associated specific file type or operation, typically android asks 1 want use, popup, , allows set default 1 file type/action.

c# - bind drop down to grid view -

i have 1 drop down list containing list of items. each item further connecting different table. there gridview show selected table selecetd item in drop down list. how possible? show selected table f gridview.datasource = tablecollection[dropdownlist.selectedvalue];

c# - Non client painting on aero glass window -

Image
now im customizing title bar of application. aim add 1 button on title bar. im previous question people have adviced me way can customize non client area. thats works except 1 small thing - glowing ! can draw glowing in nonclient area i cannot make spreads out of window . cant find resource subj. i looked this sample , made own test app investigating non client drawing facilities. screen shot of app's window: so can see system button glows out of windows when clipped borderframe. for example, skype's window have 4 custom buttons in title bar , can "glow" out of window frame: can advise me find out way draw button's glowing out of window? in advance! [edit] thank answers! skype cheats it, , has little sliver along top of window; can draw it. you can see process explorer spyxx: see also msdn: custom window frame using dwm