Posts

Showing posts from April, 2012

user interface - Question about making a JAVA GUI of a certain format -

Image
i trying make gui looks this: i know how use borderlayout has space 5 buttons. north, west, center, east, , south. since need have 6 components on top line, approach can't work. i'm not sure how make can have more 1 component on top line. there other layouts can use or there way can manipulate borderlayout can put 6 components on top line? what need nest components inside of other components. example, top (north) should 1 jpanel . jpanel contain 6 components on top. the code may similar following: jpanel northpane = new jpanel(); northpane.add(new jlabel("principle: ")); northpane.add(principletextbox); ... , on mainpanel.setlayout(new borderlayout()); mainpanel.add(northpanel, borderlayout.north); the center component jpanel containing 2 center buttons. , south component jpanel containing single jlabel or jlabel . if don't have use borderlayout main panel, may easier use boxlayout .

asp.net - Error converting data type nvarchar to float -

here code: protected void button11_click(object sender, eventargs e) { string usr = membership.getuser(false).tostring(); int x, count = 0, avail_shares,num; float t_c, c_p, c_t,ret,com,t_r,pr; string comp = this.dropdownlist4.selectedvalue.tostring(); avail_shares = convert.toint32(this.textbox10.text); pr = float.parse(this.textbox15.text); t_c = float.parse(this.textbox14.text); c_p = float.parse(this.textbox12.text); c_t = float.parse(this.textbox131.text); ret = float.parse(this.textbox132.text); com = float.parse(this.textbox133.text); t_r = float.parse(this.textbox13.text); num = convert.toint32(this.textbox11.text); if (num > avail_shares) { this.label23.text = "you cannot sell more number of shares actuall have"; } else {

Threading excel -

can have multiple threads in excel. need counter show time elapsed. thread have loop update counter , sleep second. (hopefully) take care of excel freezing while calculating. along line, possible have excel update while calculates. updating, mean screen continue update, rather freezing. however, have not tested 2010 , have no idea whether still problem (it in 2007). the answer no.

Validation When Using MVVM (WPF) with a DDD-Based Model -

a common mvvm/wpf approach data-bind ui's controls directly underlying model object. model object may contain own validation logic (perhaps exposed via idataerrorinfo) or may validated helper class checks model object instance errors. in either case, @ times model have invalid data in , in invalid state. however, in ddd world, model never in invalid state. how suggest performing validation when using wpf , ddd? thanks, ben i don't think view in mvvm should binding directly domain model, should binding view model instead. view model can in "invalid" state can reflected through idataerrorinfo. later when user operation (e.g. save, ok, apply) applies underlying domain model should domain model enforce validity, can prevent apply not allowing operation in ui. although must i've found it's not easy without duplicating validation logic extent.

Remove Trailing Slash From String PHP -

is possible remove trailing slash / string using php? sure is, check if last character slash , nuke one. if(substr($string, -1) == '/') { $string = substr($string, 0, -1); } another (probably better) option using rtrim() - 1 removes all trailing slashes: $string = rtrim($string, '/');

Jquery or Javascript that display content based on the date HELP -

jquery or javascript displays content based on specifics date period so have 3 dates 12/3/2010 12/11/2010 12/20/2010 and div contents content 1 should displaying 12/3 12/11 content 2 should display 12/11 12/20 , content 3 should displaying 12/20 there after first, others said whole thing bad idea you're depending on client machine date/time , correct approach doing in server side. anyway, guess have reasons here jquery solution. have such html: <div class="datediv"><span class="daterange">1/1/2010 1/1/2011</span>i'll visible during 2010</div> <div class="datediv"><span class="daterange">1/1/2011 1/1/2012</span>i'll visible during 2011</div> <div class="datediv"><span class="daterange">1/1/2012 1/1/2013</span>i'll visible during 2012</div> put date range inside span inside each div class "daterange&quo

php - Is it possible to disable 'minify-cation' with Minify? -

within zf project i'm using minify lib merge , minify js, since it's old project, didn't wrote view helper handle minify , there no way manage zf. but it's difficult debug online because of obfuscation. i'd know if it's possible disable compression, obfuscation or whatever, , use minify merge scripts single file. any ideas ? look debug mode . if can't add &debug urls directly, temporarily add $_get['debug'] = '1'; /min/config.php file in development environment.

jquery - How do I add a fade in? -

how add fade in this? $(document).ready(function(){ var myquotes = new array(); myquotes[0] = "all connected... "; myquotes[1] = "the best way"; myquotes[2] = "your work discover"; myquotes[2] = "if success"; var myrandom = math.floor(math.random()*myquotes.length); $('#quotehome').html(myquotes[myrandom]); }); you can chain .hide() .fadein() , this: $('#quotehome').html(myquotes[myrandom]).hide().fadein();

java IO question -

im trying "submit" button save gui in text file, ive made gui , button listener etc im having trouble making method saves information gui text file. so far have public void save(){ file k1 = new file("documents/"+"newfile.txt"); try { k1.createnewfile(); filewriter kwriter = new filewriter(k1); bufferedwriter bwriter = new bufferedwriter(kwriter); bwriter.write(txtfield1.gettext().trim()); bwriter.newline(); bwriter.close(); } catch (ioexception e) { e.printstacktrace(); } } but doesnt seem work, nothing happens. there im missing? i think there easier way, example have jfilechoser open "save box" when "submit" button pressed there easier way create file (saving gui infomation in txt file) ? this continuation on previous question . should selected file , write of writer , printwriter . file file = filechooser.getselectedfile(); printwriter writer = new printwriter(file); try { writer.println(txtf

c# - CA2109 - ignore or not ignore - that is the question -

in program writing friend warning: ca2109. after looking @ msdn quite puzzled if need concern or not. msdn vs2008: http://msdn.microsoft.com/en-us/library/ms182312(v=vs.90).aspx msdn vs2010: http://msdn.microsoft.com/en-us/library/ms182312.aspx the difference between these 2 versions section taken vs2008 msdn doesn't exist in vs2010 msdn: note rule applies versions of before .net framework version 2.0. can suppress warning in .net framework version 2.0 , later versions. in these later versions, runtime automatically makes sure creator of delegate in callstack during stack walk security demand. any suggestions? edit: clarify after reading dgh answer - described in note in msdn2008 can ignore because compiler dealing this. question going on in vs2010 note doesn't exist. it potential security concern. if code still compiles , runs (which warnings shouldn't prevent), can ignore move on. however, if wish have highest possible level of security pr

iphone - Core Data: Illegal attempt to establish relationship + (null) context -

i parsing data on background thread, inserting new entities , setting relationships other existing entities. sometimes error: 'attempting establish relationship between objects in different contexts'. after reading more creating new managedobjectcontect in background thread , using insert new entities , setup relationships. careful use new managedobjectcontext in background thread. when need find existing entity setup relationship between existing object , 1 of these new objects, call [moc objectwithid:id] fetch existing object using new moc. however, still getting error. frustrated, started printing things out. noticed when print out managedobjectcontext property each nsmanagedobject, before setting relationship, '(null)' printed out. seems when problem occurs. can tell me doing wrong? why have (null) mocs on objects? thanks can give! the explanation trying link objects created in 1 context have not been merged other context. no changes mad

visual studio 2010 - Library issue in the project -

i getting strange errors , not able understand these errors mean when build project in visual studio gives me following errors can tells me these error means though there configuration issues doing socket programming , network programming. here bunch of error weill highly appreciated.... c:\program files (x86)\msbuild\microsoft.cpp\v4.0\microsoft.cppbuild.targets(990,5): warning msb8012: targetpath(e:\study\fwif\demola\ext-libs\libcommoncpp2-1.6.0\w32\debug\ccgnu2.dll) not match linker's outputfile property value (e:\study\fwif\demola\ext-libs\libcommoncpp2-1.6.0\w32\debug\capecommon14.dll). may cause project build incorrectly. correct this, please make sure $(outdir), $(targetname) , $(targetext) property values match value specified in %(link.outputfile). 1>c:\program files (x86)\msbuild\microsoft.cpp\v4.0\microsoft.cppbuild.targets(992,5): warning msb8012: targetname(ccgnu2) not match linker's outputfile property value (capecommon14). may cause project build incor

python - How do I assign incremental names to elements of a list? -

how assign incremental names in list? >>> cclist ['az <az@example.com>', 'cc777 <cc777@example.com>', 'user11 <user11@example.com>'] >>> in range(len(cclist)): mailtuple = parseaddr(cclist[i]) cc = mailtuple[0] print cc az cc777 user11 >>> >>> in range(3): name = "name"+str(i) print name name0 name1 name2 >>> i trying end name0 = az name1 = cc77 name2 = user11 so can refer these names later. how can this? basically, don't understand how write this: >>> in range(len(cclist)): mailtuple = parseaddr(cclist[i]) cc = mailtuple[0] "name"+str(i) = cc .... of course, not work. thanks! update thanks great answers! think list solution thomas k work in case; except not solve how print if cc recipients other 3: >>> ccnames = [] >>> in range(len(cclist)): mailtuple = parseaddr(cclist[i]) cc =

Control what red x does on window using wpf forms in c# -

i developing application in c# using wpf. control red x (close window) does. @ moment, press red x , closed current window , continues running rest of program. not want happen. instead when x pressed want whole program finish. can done? thanks help you want event handling on window.closed event, or override window.onclosed method , put code shutdown program in there. http://msdn.microsoft.com/en-us/library/system.windows.window.onclosed.aspx

design - Should terminal applications guess what the user wants? -

there small discussion git , doesn't default user. by default, colour disabled (generally set git config ), yet sends output pager application commands (such in git log ). one side no flags should enabled since gives user full control of application. contrary state when releasing new application, 1 should try , win users on possible many bells , whistles possible. this subjective question, in year 2010 should terminal applications start making usability decisions default or force users customize it. $ rm file.txt </dev/null want remove file.txt [y/n] tty not connected, guessing "no" so no; please avoid assumptions because can turn out exact opposite of expected. color in git diff disabled default, because pagers may not support it — case less, needs explicitly invoked -r option turn on escape sequence support.

c# - Greater time resolution using .NET Micro Framework on Netduino board (for dimming an LED)? -

i'm programming netduino board using .net micro framework 4.1 , want higher time resolution milliseconds. because i'm attempting dim led blinking fast. the issue sample code uses thread.sleep(..) takes number of milliseconds. sample code http://netduino.com/projects/ showing issue in question: outputport ledonboard = new outputport(pins.onboard_led, false); while (true) { ledonboard.write(true); thread.sleep(1); // << problem: can low 1 millisecond even if there's way accomplish dimming not using greater time resolution, i'm game. this doesn't answer question getting better time resolution, solve problem changing brightness on led . should using pwm module netduino. netduino basics: using pulse width modulation (pwm) great article on how use it.

php - Strip first word from a string -

i have script lets users post comments have setup @ begin of every comment user put in script puts in hate automactically how want work, user put in hating , comes out hating hating , users comment. have ideas on how can strip out hating or hates if first word in sentence inputted user? @ moment have set remove hating removes ever used in sentence not @ moment. here of code being used. if (strpos($content, 'hating') !== false) { $content = str_replace("hating", "", $content); } $query="insert posts set story='hating ".mysql_real_escape_string($content)."', time_added='".time()."', date_added='".date("y-m-d")."', active='$active', pip='".$_server['remote_addr']."'"; $result=$conn->execute($query); $pid = mysql_insert_id(); set story='hating " have set put in word hating , include in database when submitted. try:

python - Can someone help me with my PIL function? -

def pad_image(f, width=500, height=none): if height==none: height = width image = image.new("rgb", (800, 600), (0, 0, 0, 0)) image.paste(stringio(f), (0,0, 50, 50)) res = stringio() image.save(res, 'jpeg') res.seek(0) return res i trying paste image, f , in 500x500 white canvas. (in middle). this function far, i'm having lots of trouble. i'm having many problems, , haven't touched height/width part. traceback (most recent call last): file "resizer.py", line 23, in <module> thumbnail = tools.create_thumbnail(pic,300) file "../lib/tools.py", line 84, in create_thumbnail thumbnail_file = pad_image(thumbnail_file.read()) file "../lib/tools.py", line 92, in pad_image image.paste(f, (0,0, 50, 50)) file "/usr/lib/python2.6/dist-packages/pil/image.py", line 1085, in paste im = imagecolor.getcolor(im, self.mode) file "/usr/lib/python2.6/dist-

iphone - Network port listening -

i writing application (an instant messenger). know whether ios supports application listen particular ports incoming packet continuously (when application active not suspend). thanks. short answer: yes long answer: chris provided link how deal sockets using cfnetwork framework . i'd add hint cocoa-asyncsocket , light-weight object-orientated wrapper framework. true time-saver.

cocoa touch - 77 unsigned long const warnings when compiling in Debug (Objective-C) -

just wondering whether knows why getting 1 warning in debug (iphone simulator) , 77 warnings in debug (iphone device) when building application!? is there can modify in project settings other "symbols hidden default" (since didn't work) remove these warnings build? miss green build successful bar. ld: warning: unsigned long const& std::min<unsigned long>(unsigned long const&, unsigned long const&)has different visibility (default) in /users/fulvio/projects/zxing/iphone/zxingwidget/build/debug-iphoneos/libzxingwidget.a(qrcodereader-c190599c861bfe46.o) , (hidden) in /users/fulvio/projects/myapp/build/myapp.build/debug-iphoneos/myapp.build/objects-normal/armv7/scanviewcontroller.o (this relates second half of question) i recommend: gcc_inlines_are_private_extern = no gcc_symbols_private_extern = no you'll want identical settings every target/object/configuration. understand these switches before applying them, since may introduce

windows - How do 25-character product keys work? -

microsoft products , other products have product key 5 groups of 5 characters, this: abcde-12345-abcde-12345-vwxyz how product know if key valid? sort of cryptography? there library if want use kind of product key in code? you might want have @ this article on how implement serial number validation function. goes advanced techniques such how keep on top of keygens, leaked keys, etc. in short, there typically 3 underlying fields in such key: the actual serial number, article calls "seed" some verification data; part of verification data checked code a checksum, crc or other simple typo-proofing mechanism by implementing part of verification data checking in code, can things "genuine validation" (in case rest of verification happens on server) or trip keygens checking different subsets of validation data in new releases.

xml - How to customize a dynamic, programmatic layout - Android -

i dealing sample code using create app pulls in surveys server. layout rendering done in java rather in xml , having problem having labels , text editing boxes (for questions , answers, respectively) squishing eachother on same line rather sitting 1 on top of other on seperate lines default rendering in xml. i want have labels above text edit boxes both can stretch across screen , seen better. the code overall layout here: private boolean displayform() { try { scrollview sv = new scrollview(this); //need tablelayout here! final linearlayout ll = new linearlayout(this); sv.addview(ll); ll.setorientation(android.widget.linearlayout.vertical); ll.setbackgroundresource(r.color.background); int i; (i=0;i<theform.fields.size();i++) { if (theform.fields.elementat(i).gettype().equals("text")) { theform.fields.elementat(i).obj = new editsurvey(this,(theform.fields.el

asp.net - template field (button) of the grid executing on page refresh -

i have button template field in hierarchical grid , on button updating data when user hit browser refresh button executes ..whats solution.. here code behind protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { if (!page.ispostback) { if (e.commandname == "updatebilldata") { gridviewrow row = ((control)e.commandsource).namingcontainer gridviewrow; int index = row.rowindex; int billgenid = convert.toint32(gridview1.datakeys[index].value); dropdownlist ddmonths = (dropdownlist)row.findcontrol("ddbillingmonths"); textbox cunit = (textbox)row.findcontrol("txtcurrbillunits"); textbox amountbdue = (textbox)row.findcontrol("txtamountbduedate"); textbox advitax = (textbox)row.findcont

python - Libs for work with SSH -

counsel library work ssh. main requirement normal operation utility sudo. have tried , suffering: paramiko - can not sudo @ all, trying after call serve in stdin password, sudo wrote type: "no ttys present" pxssh - mmmmmm, slow, very slow, awkward fabric - can sudo in ideal world, there work different users , need send password ? have normal libraries work sudo, or not? rather force sudo work without tty, why not paramiko allocate tty? paramiko , pseudo-tty allocation

rest - need to make a restful web service call -

have built restful web services using resteasy, want call these web services... did bit of research , came across diff names jersey, restlet,resteasy client framework , few others.. confused 1 of these use.. 1 of these have big advantage on others.. thanks you can implement hello world applications see 1 easier you. i tried resteasy , jersey. coding style 90% same 2. however, simple application resteasy , jersey, returning simple response same uri, resulted: resteasy 20 times faster jersey when number of concurrent users goes up. although, not mean gonna time, may give idea. used default settings, maybe other settings needs changed better performance in jersey. jersey able handle maxium of 500 concurrent users, 10 requests each whereas resteasy able perform 2000 concurrent users, 10 per request. @ 500 concurrent users, resteasy performing 18 times faster jersey. you may want try simple demonstrates needs candidate frameworks see how perform. , in meantime

html - Convert Uppercase Letter to Lowercase and First Uppercase in Sentence using CSS -

how convert uppercase letter lowercase , first letter uppercase each sentences below using css? from: example sentence. to: example sentence. update: when i'm using text-transform: capitalize; result still same. there no sentence caps option in css. other answers suggesting text-transform: capitalize incorrect option capitalizes each word . here's crude way accomplish if want first letter of each element uppercase, it's near actual sentence caps: p { text-transform: lowercase; } p:first-letter { text-transform: uppercase; } <p>this example sentence.</p> <p>this example sentence. , another, entirely lowercase.</p>

c++ - Sending packet using libpcap speed limitation -

i wrote program captures ethernet packets nic (i.e eth0) @ high speed (about 1gbps) , forward traffic using pcap_sendpacket() nic (i.e eth1). while forwarder ethernet interface not connected computer nic, forwarding speed desired, when connect it, sending speed gets down awfully (from 900 mbps 100 mbps). can explain reason? os : kubuntu linux 10.10 language : c++ library : libpcap because destination nic 100 bbps interface :d :p

c# - Same code doing two different things on two different apps? -

if have code: class testbrowser : webbrowser { public testbrowser() { panel panel = new panel(); panel.dock = dockstyle.fill; controls.add(panel); } } should panel cover webbrowser , make invisible or not? expected behavior? ask because same code giving me 2 different results on 2 different apps , can't find why (the panel covers on 1 , invisible in other). if add new controls - add , id panel - define function change dock property value after adding controls panel contained in instance of testbrowser

c# - List Output Help -

how create list on click add data list stored session variable, on page retrieve variable , output them? have: page load: list <myclass> listname=new list < myclass > onclick: listname.add(3); listname.add(4); session[“ids”]=listname; second page ???? i need whole list , add output list can output (hopefully) ‘3’ , ‘4’. list<myclass> listnames = (list<myclass>)session[“ids”]; you can read on msdn: asp.net session state overview

Visual Studio acting strangely with Emacs keybindings -

i have bound alt + d edit.emacsworddeletetoend in visual studio. key binding starts alt + d , there no conflicts. however, when hit alt + d , on occasions (more acceptable) cursor moved across word end of instead of deleting it. can't find way reliable reproduce this. the equivalent happens alt + bkspce i've bound edit.emacsworddeletetostart , i.e., cursor moves on word. i'm using resharper 5 if should matter. any ideas?

scheme - What parts of R5RS are generally considered not worthwhile to implement? -

i have been looking around good, small scheme implementations. notice usual claim follow "almost all" of r5rs, never of it. parts of r5rs considered hard/not worthwhile? considered mistake of r5rs? if you're looking things under too-hard/not-worthwhile category, there several tricky details of implementing continuations in various places (and small implementations don't have support real continuations either). take @ (now outdated) chart sisc authors put together: http://sisc-scheme.org/r5rs_pitfall.php systems, while claiming implement "(most) everything", have few overlooked details that.

Django Celery beat crashes on start -

i have configured new server rabbitmq , celery. when try start celerybeat on machine starts few seconds , stops. have given right permissions log files , changed owners application user. have checked celerybeat.log file , no errors registered. i tried start way in project folder: ./manage.py celerybeat and got error: [2010-12-01 09:59:46,127: info/mainprocess] process shutting down could please point me in right direction here. first thing in opinion , launch show output in console , using base command celeryd. try python manage.py celeryd -b -l debug i know recent update of celery have problem log files if launch old version of python (less 2.6).

jsf 2 - JSF - Another question on Lifecycle -

today i'd know features on jsf lifecycle. let me start : 1 - phase 2:apply request values - during phase,each component in view search values in request , set new values them uhm, ok nice. so, view built due previous beans parameters. after, there partial view, generated request values. (right? later, in 3° phase, compared) . but, example, if values in request list absent during creation of last view? values null? 2 - phase 5: invoke application - once values of request has been set backing bean action events queued during apply request values phase processed. in our case submit buttons action method . this not clear @ all. @ moment have (on beans) values updated previous phase (if validation , apply request aren't failed). ok, happens? means the action events queued during apply request values phase processed ? means that, example, if action submit process finished? that's why ajax call, if not rendered in 2° phase, fail? or fails? 3 - phase 6: render respo

What is the best way to replace ExtJS-generated DOM elements with new ExtJS elements? -

i making php/extjs framework generates base extjs javascript on first page visit, via ajax calls manipulates dom. so need able replace specific dom elements created extjs new dom elements created extjs. in following example, want replace text in region_center 2 panels. however, renderto adds element, while applyto replaces content prevents me added e.g. 2 panels since second 1 replaces first one. how can manipulate extjs-generated javascript can replace regions of screen new content, e.g. in menu in 1 clicks on panels , center_region replaced new content? <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css"> <script type="text/javascript" src="ext/adapter/ext/ext-base.js"> </script> <script type

javascript - select <select> item by value -

i have <select id="x"> <option value="5">hi</option> <option value="7">hi 2</option> </select> i want javascript function enables me select , display <option> default 1 id. in other words, want setoption(5) , <option> value "5" displayed in combobox default . is possible? if can, es6... function setoption(selectelement, value) { return [...selectelement.options].some((option, index) => { if (option.value == value) { selectelement.selectedindex = index; return true; } }); } ...otherwise... function setoption(selectelement, value) { var options = selectelement.options; (var = 0, optionslength = options.length; < optionslength; i++) { if (options[i].value == value) { selectelement.selectedindex = i; return true; } } return false; } setoption(document.getelem

"Hg to Hg (Gateway) to SVN" compared to "Git to Git (Gateway) to SVN" -

question similar this (unanswered) , this one (same problem not involving git). the goal make hg front end svn period of time before transitioning hg. the setup should 1 depicted below (same in questions referenced above), i'm not sure exact topology of intermediate hg repositories. dev1 hg --> hg <--> svn dev2 hg -/ i know above setup works git , git-svn described in this comment : dev1 git --> git (bare) <--> git (bridge) <--> svn dev2 git -/ setup: either git svn init , or git svn clone svn repo. becomes “git/svn bridge.” fix of branches, tags, etc… here. svn/* refs considered remotes, if want tracking branches, check these remotes out , create appropriate local branches. also, check tags out, , create actual tags. must create local branches svn branches wish synchronize between git , svn. now, create new bare repository ( git init ) somewhere, , bridge, push branches bare repo ( git push –tags ). all git users

c# - Debugging is giving result but not getting populated -

i have function in 1 class public static dataset getalluppercasedtables() { //an instance of connection string created manage contents of connection string. using(var sconnection = new sqlconnection(configurationsettings.appsettings["connectionstring"])) { //to open connection. sconnection.open(); //query select tables having names in uppercased format. string selectuppercasedtables = @"select name sysobjects upper(name) collate latin1_general_bin = name collate latin1_general_bin , objectproperty(id,n'istable')=1 , objectproperty(id,n'ismsshipped')=0 "; //create command object using(var scommand = new sqlcommand(selectuppercasedtables, sconnection)) { try { //create dataset. dataset dsuppercasedtables =

android - Problem registering clicks on Button on CustomCursorAdapter in a ListView -

what trying catch button click inside listview managed customcursoradapter. when clicked need make button invisible , update value in database. here code using listactivity , cursoradapter. public class maintabview extends listactivity{ /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); filllistdata(); } private void filllistdata(){ databasenameshelper mydbnameshelper = new databasenameshelper(this); mydbnameshelper.opendatabase(); cursor cursor = mydbnameshelper.getcursorquerywithallthetaxistations(); startmanagingcursor(cursor); // desired columns bound string[] columns = new string[] { databasenameshelper.column_name, databasenameshelper.column_people}; // xml defined views data bound int[] = new int[] { r.id.name_entry, r.id.number_entry }; // create adapter using cursor pointing desired data layout information custom

winforms - c# tabcontrol - tabpage -

i trying add tab page programmatically tabcontrol. i can no problem, seems when add it, automatically sized 200px in width, , cannot work out how resize it. tabpage created in dll, , returned main client whereby added tabcontrol, when added 200px wide, , further controls add onto tabpage not show if positioned more 200px wide. any ideas? thanks. either change size property mytabcontrol.size = new system.drawing.size(400, 400); or height / width properties mytabcontrol.height = 400; mytabcontrol.width = 400; or dock property // size tab control take available space in parent container mytabcontrol.dock = dockstyle.fill;

log4j JDBCAppender rotate table name -

i have configured application uses log4j it's logging log mysql database. (using org.apache.log4j.jdbc.jdbcappender). i have perl applications log database well. perl apps setup name of database table changes every month (log_2010_11, log_2010_10 etc). @ end of each month, run reporting scripts on month completed, dump table external file (which gets compressed , archived), , drop table. way total size of logging database stays within sensible limits. i same log4j, there not appear log4j appender suitable purpose. is possible this: log4j.appender.sq=org.apache.log4j.jdbc.jdbcrollingappender log4j.appender.sq.driver=com.mysql.jdbc.driver log4j.appender.sq.url=jdbc:mysql://localhost:3306/logs_{%year}_{%month} thank you. i figured out how this: log4j.appender.sq=org.apache.log4j.jdbc.jdbcappender log4j.appender.sq.driver=com.mysql.jdbc.driver log4j.appender.sq.url=jdbc:mysql://localhost:3306/logs log4j.appender.sq.sql=insert accesslog_%d{yyyy_mm} (date, time

c# - Benefits Gained by Passing WebControls By Ref -

are there performance benefits gained passing objects webcontrols ref? i'm thinking of such things validation methods modify control's & feel (background-color, cssclass etc.) ... nope. benefit of passing reference type variable reference if want able change value of caller's variable, i.e. change object refers to. example: // creates new label if necessary, , sets text stuff public void foo(ref label label) { if (label == null) { label = new label(); } label.text = "stuff"; } personally try avoid ref possible: tends indicate method doing much.

php - How to make an anchor tag not go to a URL/Open a file -

i have webpage 2 frames. -left nav -right main content. have text-box here called "file_path" currently, have list of files on left hand side displaying anchors. want functionality if user clicks file on left hand frame, can grab value , put in text-box on right hand frame. able successfully, problem after getting value in right frame, left-frame opens file in section ... want prevent file being open. want pass value there. echo "<li><a href=\".$filepath.\" onclick=\"parent.right.document.getelementbyid('file_path').value='$filepath'\">$filepath</a></li>"; i tried merely putting onclick list item, way loose functionality, user feels link clickable. appears static text ... i'd rather have cursor change when user goes on anchor tag, not open file ... possible? echo "<li onclick=\"parent.right.document.getelementbyid('file_path').value='$filepath'\">$filep

javascript - Does WebKit have a clipping bug? -

Image
given region line-height , margins n , , region has height multiple of n , , scrolltop increased multiples of n find result expect in firefox, opera , netfront in chrome (windows), safari (mac) , latest webkit nightly (mac) there leakage , see partial lines. in actual project (which can't share) effect quite pronounced, in reduced test case, bottom of previous line can seen peaking out @ top of box. is possible avoid effect? bug in webkit rendering engine should reported? the reduced test case can seen below , as live example on website . click on document few times scroll , not dots @ top of box (which bottom of letters of previous line). <!doctype html> <html lang="en"> <head> <meta charset="utf-8"/> <title>scrolltop issue</title> <style> body { background-color: white; color: black; } #wrapper { width: 300px;

c++ - Parsing date/time strings problem -

i'm having problems finding algorithm parses wide range of date/time strings. need not handles common formats such yyyy-mm-dd etc, little more exotic such swedish long date format 'den 'd mmmm yyyy allows "den 1 december 2010". needs handle formats windows has been set to, i.e. if set swedish wouldn't expect handle french etc. i hoping mfc coledatetime's parsedatetime handle it, doesn't appear to. does know of versatile enough handle these various date formats? boost.datetime has flexible range of parsing options. see here initial example. can specify own input/output format using flags here . you use build factory class generates parser/streamer based on locale of system.

c# - Defining Constants by Scope -

i've been in habit of defining constants @ class level: public class myclass { private const int somenumber = 10; ... } but, worked believes if constant used specific method should defined in method: public class myclass { public void somemethod() { const int somenumber = 10; ... } } my argument preferring first if constant needed in other methods there no refactoring needed , makes easier update constants since they'll defined in same place. are there other pros/cons or there no real difference? if needs updating it's not constant. mean, don't refactor value of pi. things change belong in configuration file in opinion. that said, use class level public constants. i've never seen or used method-level constants. conceptually, method level constant makes little sense me.

android - Is there any way to make table columns equal to a fraction of the total width? -

so far in learning have come across spreading column sizes equally, giving one/two higher priority take space need, or setting size of column manually. i wondering if there anyway of setting column size in android fraction of total table size. want split sixths. 1/6 first column, 3/6 second column , 2/6 third. is there way this? you can using android:layout_span here example : <?xml version="1.0" encoding="utf-8"?> <tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchcolumns="*"> <tablerow android:layout_width="fill_parent" android:layout_height="fill_parent"> <textview android:background="#aa0000" android:text="1/6" android:gravity="center_horizontal"/>

windows - using a wild card in a script in a directory name -

i'm writing script in want copy file directory "start menu\programs\startup" in computer. problem - script several computers , reason in each 1 administrator has different name,so path "c:\documents , settings* administrator *\start menu\programs\startup" not suitable all. i'm looking way use wild card in directory name . like: "c:\documents , settings\administrator*\start menu\programs\startup", script work in computers. (the name unknown advance know start word 'administrator') any ideas? thanks, tamar there more clever ways, 1 way use for command. following: cd "c:\documents , settings" /d %%f in (administrator*) copy yourfile "%%f\start menu\programs\startup"

asp.net - Intercepting *.aspx -

i'm trying intercept every aspx requests. interception works, page stay blank. missing ? namespace website { public class class1 : ihttphandler { public bool isreusable { { return true; } } public void processrequest(httpcontext context) { } } } <system.webserver> <handlers> <add name="samplehandler" verb="*" path="*.aspx" type="website.class1, website" resourcetype="unspecified" /> </handlers> </system.webserver> you're intercepting page request, you're not doing it. if expect see sort of output, have perform kind of manipulation httpcontext being passed in. below couple of articles might decent reading when dealing httpcontext. in nutshell, if expect see response, have generate it. http://odetocode.com/articles/112.aspx what difference between httpcontext.current

c# - The authentication scheme ' NTLM' is not supported and other issues migrating from .asmx to wcf -

i switched .asmx web service wcf (both in .net 3.5), , getting the authentication scheme ' ntlm' not supported. the thing i've seen on google w3svc/ntauthenticationproviders setting had ntml instead of ntlm. don't have issue. okay - here summary of annoying wcf issues encountered while migrating helps someone. issue 1 - "this collection contains address scheme http. there can @ 1 address per scheme in collection." this caused, guess, web server having multiple web sites multiple host headers. solution found here: wcf service startup error "this collection contains address scheme http" . i added baseaddressprefixfilter: <servicehostingenvironment> <baseaddressprefixfilters> <add prefix="http://yoururl.blahblah.com/" /> </baseaddressprefixfilters> </servicehostingenvironment> issue 2: got the authentication scheme ' ntlm' not supported. error. struggled while

java - Adding Custom Messages to JUnit4 Style Exception Tests -

i have following test: @test(expected=arithmeticexception.class) public void dividebyzero() { int n = 2 / 1; } as seen here . i add message print if test fails. for instance if doing assertion test, following add message: @test public void assertfail(){ assert.fail("this error message want printed."); assert.assertequals(true, false); } the second example should print out "this error message want printed.". how set first example message text? i don't think can easily, this guy seems have partially worked way around it.

autocomplete - Showing an initially selected object in an ObjectAutoCompleteField on page load in Wicket -

i've followed wicket example guide objectautocompletefield working, , quite nicely. i have huge problem, though, , show set object in field when page loads. object retrieved model use form objectautocompletefield used. changing objectautocompletefield changes model attribute "connected" to, , subsequent changes in field shows appropriate label in place, not initial 1 when page loads—the thing shows edit link (to autocomplete functionality). i've looked around in documentation objectautocompletebuilder haven't found corresponding method set initial value explicitly on page load. i managed find solution looking through classes relating objectautocompletefield. the objectautocompletefield constructed build method in objectautocompletebuilder. so, calling readonlyrenderer method on builder, creating new objectreadonlyrenderer creating label inside getobjectrenderer, got objectautocompletefield render preselected object on page load. objectautocom

jquery - Can we open dialog within a dialog? -

i have button on clicking opens jquery dialog. inside jquery dialog have button on clicking should open yet dialog. 1st dialog open correctly 2nd dialog not opening. can tell me can problem? both dialogs non modal. still, 1st 1 gets opened 2nd 1 doesn't. thanks in advance :) yes it's possible. time. please post code can see what's wrong. make sure have "stack" property set true, so: var dialogoptions = { draggable: false, resizable: false, stack: true }; $('selector').dialog(dialogoptions); description jquery documentation: specifies whether dialog stack on top of other dialogs. cause dialog move front of other dialogs when gains focus. code examples initialize dialog stack option specified. $( ".selector" ).dialog({ stack: false }); get or set stack option, after init. //getter var stack = $( ".selector" ).dialog( "option", "stack" ); //setter $( ".sel

iphone - Updating/Inserting existing objects in NSFetchedResultsController -

i'm using nsfetchedresultscontroller uitableview displays list of folders , associated unread counts each item in folder. i'd insert/delete folders w/ animation tableview based on unread count during sync/refresh (on background thread utilizing nsmanagedobjectcontextdidsavenotification ). folders no unread items should fade out, , existing folders new unread items should fade in. currently using controller:didchangeobject:atindexpath:forchangetype:newindexpath: method not unless tableview reloaded, or app relaunched, not ideal. is nsfetchedresultscontroller not way this? initial idea create separate core data entity holds folders unread items, , add/remove folders that, seems hokey. my nspredicate looks like: any items.unread == 1 update: above nspredicate works fine , grabs objects expect to. problem if app launches , folderx has 0 unread items, not appear. if refresh (goes out , parses json file in background thread) , folderx has 25 unread items, not aut

c# - How can I create a collection of business objects from multiple elements in a XmlDocument -

i'm trying create collection of business objects following xml document using .net 4.0/c# <webservices errorfound="false" serverdatetime="30/11/2010 14:58:58"> <results> <users totalresults="5"> <username userid="2">john</username> <username userid="3">dave</username> <username userid="4">jim</username> <username userid="5">bob</username> </users> </results> </webservices> this class need create public class user { public string name { get; set; } public int id { get; set; } } each of users child elements should new instance of class. far have method accepts xmldocument. public static ienumerable<user> getuser(xmldocument xmldoc) { xmlreader reader = xmlreader.create(ne