Posts

Showing posts from January, 2011

java - How can I measure/calculate the size a Document needs to render itself? -

i have javax.swing.text.document , want calculate size of bounding box document needs render itself. is possible? it trivial plain text ( height = line count * line height , width = max width on each line ) how can rtf, html or other document? this code might give ideas: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; public class textpaneperfectsize extends jframe { jtextfield textfield; jtextpane textpane; public textpaneperfectsize() { textfield = new jtextfield(20); textfield.settext("add text"); getcontentpane().add(textfield, borderlayout.north ); textfield.addactionlistener( new actionlistener() { public void actionperformed(actionevent e) { try { document doc = textpane.getdocument(); doc.insertstring(doc.getlength(), " " + textfield.gettext()...

c# - LINQ to Entities does not recognize the method 'Int32 -

public actionresult readxmldevices(int groupid) { var query = k in xmlentities.unassigneditems k.devoracc == true && k.group == groupid select k; var view_query = in query select new getfreedevices { marticlenumber = i.articlenumber, mfirmware = i.firmware, mgroup = i.group, mname = i.name, msoftware = i.softwareversion, sa = getnumberofdevices(i.articlenumber,2), sth = getnumberofdevices(i.articlenumber,3), sasth = getnumberofdevices(i.articlenumber,7) }; return partialview(view_query); } public int getnumberofdevices(string artno,int loc) { var num_dev = (from k in xmlentities.deviceview k.reserved == false && k.sold == false && k.locationna...

email - How do I send mail from a Ruby program? -

i want send email ruby application. there call in core language or there library should use? what's best way this? if don't want use actionmailer can use net::smtp (for actual sending) tmail creating emails (with multiple parts, etc.).

Unit testing ASP.NET MVC redirection -

how unit test mvc redirection? public actionresult create(product product) { _producttask.save(product); return redirecttoaction("success"); } public actionresult success() { return view(); } is ayende's approach still best way go, preview 5: public static void renderview(this controller self, string action) { typeof(controller).getmethod("renderview").invoke(self,new object[] { action} ); } seems odd have this, mvc team have said writing framework testable. [testfixture] public class redirecttester { [test] public void should_redirect_to_success_action() { var controller = new redirectcontroller(); var result = controller.index() redirecttorouteresult; assert.that(result, is.not.null); assert.that(result.values["action"], is.equalto("success")); } } public class redirectcontroller : controller { public actionresult index() { retu...

sql server 2005 - Connecting A Second Site To Current SQL Database -

ok - long story short. have e-comm site hosted on windows vps using sql server 2005, site been years , works fine. i trying set new site hosted on windows vps server share same database. both sites using classic asp , have put duplicate page each server has simple sql query display product name on screen. on new site 500 error listed below: get /testconnection.asp |49|800a0bb9|arguments_are_of_the_wrong_type__are_out_of_acceptable_range__or_are_in_conflict_with_one_another. line 49 in code is: rsproddetail.open sql, cnn, adopenforwardonly, adlockreadonly, adcmdtext as mentioned page identical on 2 servers. adovbs.inc there , path file include correct on new server. where next? have tried using rsproddetail.open sql, cnn, 0, 1, 1 to see if ado constants defined correctly ?

ssis - Framework for loading flat files into SQL Server -

i have import flat files sql server. far, i've used ssis packages , delphi programs job i'm getting more , more files load. many wide (more 90 fields) , have own specifics: fixed-width, delimited wide set of characters used field , row delimiter, use "always insert" pattern while others use "update or insert", etc. many of these files several gigabytes in size making harder handle them. now i'm starting wonder if there isn't better way handle this: tool dedicated doing kind of work used in rational way: ssis nice but, frankly, use of gui 99% of work makes impractical when dealing non-trivial tasks. would care suggest solution ? you may use format file bulk load. description: http://msdn.microsoft.com/en-us/library/ms189636.aspx

Using Jquery to expand all answers below question -

i trying work out how expand answers below question when .allopener span pressed. users can expand each answer individually, not @ once. tips appreciated. there many items on page. the allopener span button open remaining unhidden .text classes in item reveal answers question though has individually clicked expand on each. note, when pressed first time, some, or no answers may expanded. additionally, when pressed again, answers hidden. , if pressed time, answers expanded. if again, hidden. when, pressed, background of each answer's expand button change accordingly: ie turning on , off class .highlightc on each individual expand button, though toggling. jquery: $('.answeropener').click(function() { $(this).next().toggle(); //unhide/hide sibling text answer $(this).toggleclass("highlightc"); //alternate background of button return false; }); $('.allopener').click(function() { $(this).toggleclass("highlighti"); //toggles background of ...

ASP.NET Custom Controls and "Dynamic" Event Model -

ok, not sure if title accurate, open suggestions! i in process of creating asp.net custom control, still relatively new me, please bear me. i thinking event model. since not using web controls there no events being fired buttons, rather manually calling __dopostback appropriate arguments. can mean there lot of postbacks occuring when say, selecting options (which render differently when selected). in time, need make more ajax-y , responsive, need change event binding call local javascript. so, thinking should able toggle "mode" of control, can either use postback , handlle itself, or can specify javascript function names call instead of dopostback. what thoughts on this? am approaching raising of events control in wrong way? (totally open suggestions here!) how approach similar problem? edit - clarify i creating custom rendered control (i.e. inherits webcontrol). we not using existnig web controls since want complete control on rendered output. afai...

.net - How do I toggle Caps Lock in VB.NET? -

using vb.net, how toggle state of caps lock? from: http://www.vbforums.com/showthread.php?referrerid=61394&t=537891 imports system.runtime.interopservices public class form2 private declare sub keybd_event lib "user32" ( _ byval bvk byte, _ byval bscan byte, _ byval dwflags integer, _ byval dwextrainfo integer _ ) private const vk_capital integer = &h14 private const keyeventf_extendedkey integer = &h1 private const keyeventf_keyup integer = &h2 private sub button1_click( _ byval sender system.object, _ byval e system.eventargs _ ) handles button1.click ' toggle capslock ' simulate key press keybd_event(vk_capital, &h45, keyeventf_extendedkey or 0, 0) ' simulate key release keybd_event(vk_capital, &h45, keyeventf_extendedkey or keyeventf_keyup, 0) end sub end class

coding style - Best way to write a conversion function -

let's i'm writing function convert between temperature scales. want support @ least celsius, fahrenheit, , kelvin. better pass source scale , target scale separate parameters of function, or sort of combined parameter? example 1 - separate parameters: function converttemperature("celsius", "fahrenheit", 22) example 2 - combined parameter: function converttemperature("c-f", 22) the code inside function counts. 2 parameters, logic determine formula we're going use more complicated, single parameter doesn't feel right somehow. thoughts? go first option, rather allow literal strings (which error prone), take constant values or enumeration if language supports it, this: converttemperature (tempscale.celsius, tempscale.fahrenheit, 22)

iis 7 - Can't get ELMAH to works with ASP.NET MVC2 on IIS7.5 -

i try use elmah on asp.net mvc2 application, works fine on test server (casini x86) while using x86 version, when deploy on production server x86_64 version, 404 error when try access "elmah.axd" , no errors logged on iis (but logged in casini) here web.config <?xml version="1.0" encoding="utf-8"?> <!-- more information on how configure asp.net application, please visit http://go.microsoft.com/fwlink/?linkid=152368 --> <configuration> <configsections> <sectiongroup name="elmah"> <section name="security" requirepermission="false" type="elmah.securitysectionhandler, elmah" /> <section name="errorlog" requirepermission="false" type="elmah.errorlogsectionhandler, elmah" /> <section name="errormail" requirepermission="false" type="elmah.errormailsectionhandler, elmah" /> ...

sql server - Default integer type in ASP.NET from a stored procedure -

i have web page have hooked stored procedure . in sql data source, have parameter i'm passing stored procedure of type int. asp.net seems want default int32 , number won't higher 6. ok override asp.net default , put in 16 or there conflict somewhere down road? specification: database field has length of 4 , precision of 10, if makes difference in answer. if force example byte , number on 255 run risk of casting error (and exception thrown). if know not going higher 6 should not problem. if me, use normal int, not sure save if other few bytes making byte. risk of exception being thrown high , lose benefits making smaller.

c# - "Could not load type" in web service converted to VB.NET -

i wrote simple web service in c# using sharpdevelop (which got , love). the client wanted in vb, , fortunately there's convert vb.net feature. it's great. translated code, , builds. (i've been "notepad" guy long time, may seem little old-fashioned.) but error when try load service now. parser error message: not load type 'flightinfo.soap' assembly 'flightinfo'. source error: line 1: <%@ webservice class="flightinfo.soap,flightinfo" %> i have deleted bins , rebuilt, , have searched google (and stackoverflow). have scoured project files remnants of c#. any ideas? in vb.net, namespace declarations relative default namespace of project. if default namespace project set x.y, everithyng between namespace z , end namespace in x.y.z namespace. in c# have provide full namespace name, regardless of default namespace of project. if c# project had default namespace x.y, cs files still include namespace x.y dec...

Javascript object properties visible in console, but undefined? -

i'm having trouble figuring out how access object properties in javascript. have function returns object, , can see object , of properties when logged console in safari, can't property values other functions. example trying alert out 1 of properties returns 'undefined'. the function generates object getprofile : function() { fb.api('/me', function(response) { facebook.profile.user_id = response.id; facebook.profile.name = response.name; facebook.profile.firstname = response.first_name; facebook.profile.lastname = response.last_name; facebook.profile.gender = response.gender; }); fb.api('/me/photos', {limit: 8}, function(response) { facebook.profile.numphotos = response.data.length; (key in response.data) { var photourl = response.data[key].source; eval('facebook.profile.photo' + key + '= photourl'); } }); return facebook.profile; } trying use function in script functio...

php - Best way to initiate a download? -

on php-based web site, want send users download package after have filled out short form. site-initiated download should similar sites download.com, "your download begin in moment." a couple of possible approaches know about, , browser compatibility (based on quick test): 1) window.open pointing new file. - firefox 3 blocks this. - ie6 blocks this. - ie7 blocks this. 2) create iframe pointing new file. - firefox 3 seems think ok. (maybe it's because accepted once?) - ie6 blocks this. - ie7 blocks this. how can @ least these 3 browsers not object? bonus: there method doesn't require browser-conditional statements? (i believe download.com employs both methods conditionally, can't either 1 work.) responses , clarifications: q: "why not point current window file?" a: might work, in particular case, want show them other content while download starts - example, "would donate project?" update: have abandon...

smtp - How can I tell if I have an open relay? -

i'm trying work out if have open relay on server. how do that? i've tried http://www.abuse.net/relay.html and reports: hmmn, @ first glance, host appeared accept message relay. may or may not mean it's open relay. systems appear accept relay mail, reject messages internally rather delivering them, cannot tell @ point whether message relayed or not. what further tests can determine if server has open relay? eh? link tells you, register site , give address @abuse.net, valid 24 hours. enter address testing form. if abuse.net account receives test email, have open relay.

perl - How do I implement object-persistence not involving loading to memory? -

i have graph object (this in perl) compute transitive closure (i.e. solving all-pairs shortest paths problem). from object, interested in computing: shortest path vertices u -> v. distance matrix vertices. general reachability questions. general graph features (density, etc). the graph has 2000 vertices, computing transitive closure (using floyd-warshall 's algorithm) takes couple hours. caching serialized object (using storable , it's pretty efficient already). my problem is, deserializing object still takes fair amount of time (a minute or so), , consumes 4gb of ram. unacceptable application. therefore i've been thinking how design database schema hold object in 'unfolded' form. in other words, precompute all-pairs shortest paths, , store in appropriate manner. then, perhaps use stored procedures retrieve necessary information. my other problem is, have no experience database design, , have no clue implementing above, hence post. i'd...

jquery - Using remote JavaScript in Chrome Extensions -

is there way remote js file chrome extension? my manifest.json looks this: { "name": "my extension", "version": "0.1", "content_scripts": [ { "matches": ["http://*/*"], "js": ["jquery.js", "main.js"], "run_at": "document_end", "all_frames": true } ] } i want use 1 javascript api, limited usage on selected domain, can't insert loaded page in chrome this: $('head').append('<script src="http://example.com/myapi.js?key=%key%"></script>'); because js api alerted me, i'm using on url, haven't gave them. i want use functions remote js. api key can fortunately registered , used on localhost. but don't have clue, how solve problem - put remote js file able use it. i've got idea create "virtual dom" , perhaps it's not sol...

sharepoint - Getting user photo from SPUser using WSS Object model -

i trying retrieve user on sharepoint's user photo through wss 3.0 object model. have been browsing web solutions, far i've been unable find way it. possible, , if how? here code snippet should job done you. may need additional validation avoid exceptions (ensuring profile exists, ensuring image url exists, etc...): //get current profile manager userprofilemanager objuserprofilemanager = new userprofilemanager(portalcontext.current); //get current users profile userprofile profile = objuserprofilemanager.getuserprofile(true); //get user image url string imageurl = (string)profile[propertyconstants.pictureurl]; //do here imageurl

Should you use international identifiers in Java/C#? -

c# , java allow character in class names, method names, local variables, etc.. bad practice use non-ascii characters, testing boundaries of poor editors , analysis tools , making difficult people read, or american arrogance argument against? i stick english, because never know working on code, , because third-party tools used in build/testing/bugtracking progress may have problems. typing äöüß on non-german keyboard pita, , believe involved in software development should speak english, maybe that's arrogance non-native-english speaker. what call "american arrogance" not whether or not program uses international variable names, it's when program thinks "währung" , "wahrung" same words.

Why the difference in usage between 'clear' and 'unset' with Rebol lists? -

given list: a: [1 2 3 4 5] why clear a clear list , unset 'a unset it? have expected both clear , unset consistently take either a or 'a arguments. clear removes entries block referenced word a : a: [1 2 3 4 5] length? == 5 clear length? == 0 unset removes word a itself: a: [1 2 3 4 5] length? == 5 unset 'a length? ** script error: has no value ** near: length?

.net - DateTime.Now vs. DateTime.UtcNow -

i've been wondering principles of how 2 properties work. know second 1 universal , doesn't deal time zones, can explain in detail how work , 1 should used in scenario? datetime.utcnow tells date , time in coordinated universal time, called greenwich mean time time zone - if in london england, not during summer. datetime.now gives date , time appear in current locale. i'd recommend using datetime.now whenever you're displaying date human being - way they're comfortable value see - it's can compare see on watch or clock. use datetime.utcnow when want store dates or use them later calculations way (in client-server model) calculations don't become confused clients in different time zones server or each other.

How to convert Apache .htaccess files into Lighttpd rules? -

it's big problem convert mod_rewrite rules lighttpd format it case of going through 1 one , converting them. don't know of automated means, the docs - http://redmine.lighttpd.net/projects/1/wiki/docs:modrewrite - has regexes available, , examples. if there particularly problematical items, i'd edit question show them, , ask answers here.

java - How to create J2ME midlets for Nokia using Eclipse -

nokia has stopped offering developer's suite, relying on other ides, including eclipse. meanwhile, nokia changed own development tools again , eclipseme has changed. leaves documentation irrelevant. i want know take make simple hello-world? (i found out myself, q&a other people use) here's what's needed make simple hello world - get eclipse ide java. used ganymede. set up. get sun's wireless toolkit . used 2.5.2. install it. get nokia's sdk ( found here ), in case s40 6230i edition, , install choosing option integrate sun's wtk follow instructions @ http://www.eclipseme.org/ download , install mobile tools java (mtj). used version 1.7.9. when configuring devices profiles in mtj (inside eclipse) use nokia device wtk folder , not nokia's folder. set wtk root main installation folder - instance c:\wtk2.5.2; note wtk installer creates other folders apparently backward compatibility. get antenna , set location in mtj's propert...

Any recommendation for a good enough Winforms GUI design? -

i developing mid-size application vb2008. better test application following mvp/supervising controller approach. my question is: recommendations separate responsibilites? far i've come winform instance of controller , instance of class. controls updated via databinding the problem i'm not sure write responsibilites (let's validation, report creation, queries , on) inside class? in separate class? is there small example of clean winform class design point me? i suggest spend time reading jeremy millers ' build own cab ' series of posts feel might like/need implement application becomes more complex.

categories in Wordpress sidebar.php -

the sidebar.php shows <li> <?php wp_list_categories('show_count=1&title_li=<h2>categories</h2>'); ?> </li> so php file generates categories in sidebar (wrapped in a tags , number of posts)? the function located inside wp-includes/category-template.php you can find out function located looking @ wordpress codex - @ bottom of each page, there link function located. documentation wp_list_categores wp_list_categories function source code

pointers - To what use is multiple indirection in C++? -

under circumstances might want use multiple indirection (that is, chain of pointers in foo ** ) in c++? most common usage @aku pointed out allow change pointer parameter visible after function returns. #include <iostream> using namespace std; struct foo { int a; }; void createfoo(foo** p) { *p = new foo(); (*p)->a = 12; } int main(int argc, char* argv[]) { foo* p = null; createfoo(&p); cout << p->a << endl; delete p; return 0; } this print 12 but there several other useful usages in following example iterate array of strings , print them standard output. #include <iostream> using namespace std; int main(int argc, char* argv[]) { const char* words[] = { "first", "second", null }; (const char** p = words; *p != null; ++p) { cout << *p << endl; } return 0; }

Sql naming best practice -

i'm not entirely sure if there's standard in industry or otherwise, i'm asking here. i'm naming users table, , i'm not entirely sure how name members. user_id obvious one, wonder if should prefix other fields "user_" or not. user_name user_age or name , age, etc... prefixes pointless, unless have little more arbitrary; 2 addresses. might use address_1, address_2, address_home, etc same phone numbers. but static age, gender, username, etc; leave them that. just show if prefix of fields, queries might this select users.user_id users users.user_name = "jim" when be select id users username = "jim"

asp.net - Visual Studio 2005 says I don't have permission to debug? -

i new visual studio/asp.net please bear me. using vs 2005 , asp.net 3.5. have vs installed on production server. if set start option site "use default web server" when go debug website vs tries open site @ http://localhost:4579/project , returns 404. if set start option "use custom server" , specify correct path application (the way hit site outside) vs unable run debug , returns error "unable start debugging on web server. logon failure: unknown user name or bad password". running vs administrator on production server. thought maybe needed set user permissions in visual studio remote debugging monitor admin account there. checked iis , made sure application configuration/debugging "enable asp server-side script debugging" checked. web config set debug="true". missing something. edit >running windows server 2003 do this...instead of trying debug hitting f5 go tools attach process click view processes users ...

text editor - Hidden Features of Visual Studio (2005-2010)? -

visual studio such massively big product after years of working stumble upon new/better way things or things didn't know possible. for instance- crtl + r , ctrl + w show white spaces. essential editing python build scripts. under "hkey_current_user\software\microsoft\visualstudio\8.0\text editor" create string called guides value "rgb(255,0,0), 80" have red line @ column 80 in text editor. what other hidden features have stumbled upon? make selection alt pressed - selects square of text instead of whole lines.

c# - Why is a different dll produced after a clean build, with no code changes? -

when clean build c# project, produced dll different built 1 (which saved separately). no code changes made, clean , rebuild. diff shows bytes in dll have changes -- few near beginning , few near end, can't figure out these represent. have insights on why happening , how prevent it? this using visual studio 2005 / winforms. update: not using automatic version incrementing, or signing assembly. if it's timestamp of sort, how prevent vs writing it? update: after looking in ildasm/diff, seems following items different: two bytes in pe header @ start of file. <privateimplementationdetails>{ guid } section cryptic part of string table near end (wonder why, did not change strings) parts of assembly info @ end of file. no idea how eliminate of these, if @ possible... my best guess changed bytes you're seeing internally-used metadata columns automatically generated @ build-time. some of ecma-335 partition ii (cli specification metadata definit...

c - file format not recognized; treating as linker script -

i trying run c files downloaded here follows : gcc main.c docs_file.txt ksg_file.txt however, receive following error: /usr/bin/ld:docs_file.txt: file format not recognized; treating linker script /usr/bin/ld:docs_file.txt:2: syntax error collect2: ld returned 1 exit status i not sure problem is. update 1: i following errors while compiling: gcc main.c -o ksg /tmp/cc4h83rg.o: in function `main': main.c:(.text+0xa5): undefined reference `stree_new_tree' main.c:(.text+0xe0): undefined reference `stree_add_string' main.c:(.text+0x2a7): undefined reference `stree_match' main.c:(.text+0x38f): undefined reference `int_stree_set_idents' main.c:(.text+0x422): undefined reference `int_stree_get_parent' main.c:(.text+0x47b): undefined reference `int_stree_get_suffix_link' /tmp/cc4h83rg.o: in function `count_freq': main.c:(.text+0x96d): undefined reference `int_stree_set_idents' main.c:(.text+0x9a8): undefined reference `stree_get_num_leave...

php - Can I display html tags like links and span tags inside the description in RSS feed code? -

can display html tags links , span tags inside description in rss feed code using php rss feed not html document. answer should not use html elements inside rss feeds. @ least there no guarantee every implementations show them expect if any.

sql - Query with multi tables -

i have 4 tables: characters arena_team arena_table_member arena_team_stats. characters table has guid, name arena_team table has arenateamid, name, type arena_table_member table has guid(this same in characters table), arenateamid arena_team_stats table has arenateamid, rating, wins, wins2, played how list of arena teams character is? tried: $result=mysql_query("select characters.guid , characters.name , arena_team.arenateamid , arena_team.name , arena_team_stats.rating , arena_team_stats.wins , arena_team_stats.wins2 , arena_team_stats.played , arena_team.type characters , arena_team_stats , arena_team characters.name '%$q%' , arena_team.arenateamid = arena_team_stats.arenateamid order arena_team_stats.rating desc") or die(mysql_error()); but returns arena teams in arena_team table. looks you...

multithreading - Does Java have support for multicore processors/parallel processing? -

i know processors have 2 or more cores, multicore programming rage. there functionality utilize in java? know java has thread class, know around long time before multicores became popular. if can make use of multiple cores in java, class/technique use? does java have support multicore processors/parallel processing? yes. has been platform other programming languages implementation added "true multithreading" or "real threading" selling point. g1 garbage collector introduced in newer releases makes use of multi-core hardware. java concurrency in practice try copy of java concurrency in practice book. if can make use of multiple cores in java, class/technique use? java.util.concurrent utility classes commonly useful in concurrent programming . package includes few small standardized extensible frameworks, classes provide useful functionality , otherwise tedious or difficult implement. here brief descriptions...

How do I reorder the fields/columns in a SharePoint view? -

i'm adding new field list , view. add field view, i'm using code: view.viewfields.add("my new field"); however tacks on end of view. how add field particular column, or rearrange field order? view.viewfields spviewfieldcollection object inherits spbasecollection , there no insert / reverse / sort / removeat methods available. i've found removing items list , readding them in order i'd works (although little drastic). here code i'm using: string[] fieldnames = new string[] { "title", "my new field", "modified", "created" }; spviewfieldcollection viewfields = view.viewfields; viewfields.deleteall(); foreach (string fieldname in fieldnames) { viewfields.add(fieldname); } view.update();

Best way for a dll to get configuration information? -

we have developed number of custom dll's called third-party windows applications. these dlls loaded / unloaded required. most of dlls call web services , these need have urls, timeouts, etc configured. because dll not permanently in memory, has read configuration every time invoked. seems sub-optimal me. is there better way handle this? note: configurable information in xml file department can alter required. not accept registry edits. note: these dll's cater number of third-party applications, esentially implements external edms interface. vendors not accept passing required parameters. note: it’s a.net application , dll written in c#. essentially, there both thick (windows application) , thin clients access dll when need perform kind of edms operation. edms interface defined set of calls have implemented in dll , dll decides how implement edms functions e.g. clients, “register document” update db , others same call utilise third-party edms system. there no asp...

Specman: how to retrieve values of var which is stored in another var -

i have stored var name in var , want retrieve values original var. for ex: var var_a: list of uint = {1,3,2}; var var_a_str:string = "var_a"; //now want print var_a list of values using var_a_str. how can that? print $var_a_str; this called introspection or reflection. have use specman's rf_manager . search in docs. however, docs don't show methods unit has. if want see methods, run snippet of code: extend sys { run() { var rf_man : rf_struct = rf_manager.get_exact_subtype_of_instance(rf_manager); out(" rf manager:"); each (meth) in rf_man.get_declared_methods() { print meth; }; }; }; i'm not sure how iterate through list elements, can use snippet @ methods on reference object's instance members ( not subroutine's variable). extend sys { : list of uint; keep == {1;3;2}; run() { var variable_name := "a"; var rf_obj: rf_struct...

html - Is it important to i18n your img alt attributes? -

for of i18n, i18n alt attribute on img tags? worth it? well, guess if wanted site i18n'd, yes. it might headache, vision impaired people out there thanking :) also, using i18n javascript strings too?

c# 4.0 - Deselect text in a textbox -

i have windows form sets text property in textbox of string variable. when form ran, has of text in textbox selected. need try , figure out how keep happening. tried deslectall() method on textbox doesn't seem work. tried txtbox.selectnextcontrol(txtcostsummary, true, false, true, true); but kind of guessing on paramters needed set to, tweaking them doesn't seem make difference. understand i'm doing i'll make little more clear on how happening. public form1() { apple = new apple(); a.iwantthistext = "item 1: " + 50.00 + "\r\n"; txtbox.text = a.iwantthistext; } class apple { private string iwantthistext; public string iwantthistext { { return iwantthistext; } set { iwantthistext += value; } // appends there before } } everything works fine except part has printed information in textbox text in textbox selected, isn't thought happen, nor want happen. thanks ideas! try this: txt...

iphone - How to pass single touch events to super view in UIWebView? -

i using uiwebview display pdf. wanna handle touch events on webview. there 2 conditions, webview should handle double touch events , gestures, , wanna pass single tap/touch events super view. can 1 please tell me how differentiate touch events in uiwebview , how pass specific touch events super view? to touch events subclassing uiwebview , im overriding hittest method in subclass. if post not answering question, should check out this article . i took similar different approach: subclassed uiview, contains uiwebview (and other controls), , override hittest:withevent: method.

How to create a java progam to compile and run a list of java programs -

instead of using .bat file, how code can built java program compiling , executing list of java programs. on runtime.exec though perhaps not ideal solution, execute shell command separate process using runtime.getruntime().exec(somecommand) . there overloads takes parameters string[] . this not easy solution. managing concurrent process , preventing deadlock etc not trivial. related questions is java runtime.exec(string[]) platform independent? what purpose of process class in java? how can compile , deploy java class @ runtime? compiling class using java code using process java: executing java application in separate process running program within java code.. on draining process streams generally can't waitfor() process terminate; must drain i/o streams prevent deadlock. from the api : because native platforms provide limited buffer size standard input , output streams, failure promptly write input stream or read output stream of subpro...

Hidden features of Perl? -

what useful esoteric language features in perl you've been able employ useful work? guidelines: try limit answers perl core , not cpan please give example , short description hidden features found in other languages' hidden features: (these corion's answer ) c duff's device portability , standardness c# quotes whitespace delimited lists , strings aliasable namespaces java static initalizers javascript functions first class citizens block scope , closure calling methods , accessors indirectly through variable ruby defining methods through code php pervasive online documentation magic methods symbolic references python one line value swapping ability replace core functions own functionality other hidden features: operators: the bool quasi-operator the flip-flop operator also used list construction the ++ , unary - operators work on strings the repetition operator the spaceship operator the || ...

sed + replace only if match the first word in line -

the following sed command replaces old string new string. target replace old new if command word appears first word in line. how fix sed syntax in order replace old new if command first word in line? (note: command word location after spaces line beginning.) lidia sed "/^ *#/b; /command/ s/old/new/g" file command old old command after sed exe: command new new command "/^[ \t]*command/ s/old/new/g"

passwd: Authentication failure on redhat -

i have application (app1) can executed user root privileges not root. hence have created user root1 : adduser -u 0 -o -g 0 -g 0,1,2,3,4,6,10 -m root1 and when trying assign password user authentication failure. [root]# passwd root1 changing password user root1. new unix password: bad password: based on dictionary word retype new unix password: passwd: authentication failure i looked lot on google , tried lot of things suggested none of them resolved error. please me in resolving above error, can login system using root1 execute application(app1). thanks, the problem password. cannot change super user password easy , guessable "qwerty". also, red hat has a nice article password security.

configuration - Configure multiple sites with Varnish -

we have server needs serve multiple domains though varnish e.g. example1.com, example2.com , example3.com our current .vcl file looks this: sub vcl_recv { set req.http.host = "example1.com"; lookup; } how set correct req.http.host correct incoming request? you can support multiple frontend domains way: backend example1 { .host = "backend.example1.com"; .port = "8080"; } backend example2 { .host = "backend.example2.com"; .port = "8080"; } sub vcl_recv { if (req.http.host == "example1.com") { #you need following line if backend has multiple virtual host names set req.http.host = "backend.example1.com"; set req.backend = example1; return (lookup); } if (req.http.host == "example2.com") { #you need following line if backend has multiple virtual host names set req.http.host = "backend.example2...

c# - Panel AutoScroll position setting -

how set autoscrollposition bottom position? i tried panel.autoscrollposition = new point(0, panel.height); but didn't work. you can use panel's verticalscroll.maximum -property: panel.autoscrollposition = new point( math.abs(panel.autoscrollposition.x), panel.verticalscroll.maximum);

types - Operator sizeof() in C -

consider program main() { printf("%d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); } output gcc compiler is: 4 2 4 why so? assuming running on 32-bit system: sizeof character literal '3' 4 because character literals ints in c language (but not c++). sizeof "3" 2 because array literal length 2 (numeral 3 plus null terminator). sizeof literal 3 4 because int.

css - Printer Friendly page not working with IE8 -

i m trying pickup contents of div , open in new window using window.open user can print printer friendly page. have got code somewhere on net , made modifications. below code snippet function printpage() { var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; var content_vlue = document.getelementbyid("memo_data").innerhtml; var somestyle = '<style type="text/css"> #memotxt p {padding:0 0 0 0;margin:5px 0 0 0;}</style>'; var docprint=window.open("","sa",disp_setting); docprint.document.open(); docprint.document.write('<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>inter office memo</title>'); ...

Using restsharp in c# to consume last.fm services -

i'm trying connect last.fm rest services using restsharp. can deserialize simple data found @ example: http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=cher&api_key=xxxxxxxxxxxxxxxxxxxxxxx however, when reach images section artist: <artist> <name>cher</name> <mbid>bfcc6d75-a6a5-4bc6-8282-47aec8531818</mbid> <url>http://www.last.fm/music/cher</url> <image size="small">http://userserve-ak.last.fm/serve/34/48511693.png</image> <image size="medium">http://userserve-ak.last.fm/serve/64/48511693.png</image> <image size="large">http://userserve-ak.last.fm/serve/126/48511693.png</image> <image size="extralarge">http://userserve-ak.last.fm/serve/252/48511693.png</image> <image size="mega">http://userserve-ak.last.fm/serve/500/48511693/cher+tess.png</image> i struggling library map data...

.net - How do i specify a bold version of the theme's default font? -

i'm having problems cross theme compatibility in windows forms. if don't set font control on windows form, use system font correct typeface , size. if want make font bold , hard codes in rest of system font values current theme you're programming with. instance: system::windows::forms::label^ label1 = gcnew system::windows::forms::label(); this->label1->autosize = true; this->label1->location = system::drawing::point(9, 12); this->label1->name = l"lblexample"; this->label1->size = system::drawing::size(44, 13); this->label1->tabindex = 3; this->label1->text = l"example text"; if change properties of via properties editor bold = true, adds in line: this->label1->font = (gcnew system::drawing::font(l"microsoft sans serif", 8.25f, system::drawing::fontstyle::bold, system::drawing::graphicsunit::point, static_cast<system::byte>(0))); is there way of using default font, making bold? f...

group by - I'm having problem with SUM() in MySQL -

i want fetch balanceamt of particular customer attended particular attender. criteria customer may buy more 1 items. each bought items has been recorded individually. @ cases ' attender ' value null. here's query: select customer, attendedby, sum(balanceamt) billing group customer having attendedby='attender' , customer='customername' my problem i'm getting value summed not attended ' attender ' (i.e., including null value). me it.. thanx in advance.. i have feeling haven't gotten question right, write select statement this select customer, sum(balanceamt) billing attendedby='attender' , customer='customername' group customer i not sure assignedto is. if want sum on customer, assignedto be: select customer, assignedto, sum(balanceamt) billing attendedby='attender' , customer='customername' group customer, assignedto

Android: Accessing the Google Products Search within your Android-Application -

i wanna use gdata apis within android application. being more specific wanna give user ability search keywords, use gdata api search products within googleproducts these keywords , parse xml back. i know how parse xml files via org.xml.sax.helpers.defaulthandler guess not suppose use such handler rather rely on gdata api parse xml me. my problem dont know how integrate api in app. there similiar topic within stackoverflow ( hier ) not @ satisfied answer gave. giving information "look @ our announced version 2.1.0-alpha of gdata java library supports android" doesnt quite me integrate gdata in app. i appreciate if give step-by-step guide how integrate gdata api within app, including code examples make search-request , parsing results google products. after days of research found solution: google gives introduction on how access items saved on google base ( hier ).surprisingly don't need implement google data base apis or access google product, can quer...