Posts

Showing posts from September, 2011

.net - Crash Instantiating System.Xml.Serialization.XmlSerializer in C# -

we're seeing crash when instantiating instance of system.xml.serialization.xmlserializer class in c# library. crash occurs in constructor, when tries add duplicate key dictionary. i've included stack trace below. this crash occurring on 1 machine, , repairing our installation of .net 3.5 didn't help. has else seen similar issues? system.argumentexception unhandled message="item has been added. key in dictionary: 'mainbuild' key being added: 'mainbuild'" source="mscorlib" stacktrace: @ system.collections.hashtable.insert(object key, object nvalue, boolean add) @ system.collections.hashtable.add(object key, object value) @ system.collections.specialized.stringdictionary.add(string key, string value) @ system.codedom.compiler.executor.execwaitwithcaptureunimpersonated(safeusertokenhandle usertoken, string cmd, string currentdir, tempfilecollection tempfiles, string& outputname, string& er...

c# - Get current System.Web.UI.Page from HttpContext? -

this 2 part question. first,does httpcontext.current correspond current system.ui.page object? and second question, related first, why can't use following see if current page implements interface: private iwebbase findwebbase() { if (httpcontext.current iwebbase != null) { return (iwebbase)httpcontext.current.; } throw new notimplementedexception("crawling iwebbase not implemented yet"); } the general context controls need know whether executing sharepoint webpart, or part of asp.net framework. i have solved problem requiring control pass reference itself, , checking page property of control, i'm still curious why above not work. the compiler error is: cannot convert system.web.httpcontext ...iwebbase via reference conversion, boxing conversion, unboxing conversion, wrapping conversion or null type conversion. no, msdn on httpcontext.current: "gets or sets httpcontext object current http request." in other wo...

Delphi Network programming -

i have classic client/server (fat client , database) program written in delphi 2006. when conditions met in client, need notify other clients quickly. until has been done using udp broadcasts, no longer viable clients connect outside lan , udp broadcast limited local network. i'm aware of indy libraries not sure of components use , how structure it. i'm guessing i'll need have server clients connect receive , distribute messages...? samples out there me started? are there other component sets or technologies should @ instead/as well? the simple answer standard protocols available in delphi (and other tools) don't allow notification in reverse. looked project wanted use soap. assume client asks server, server responds , that's it. for me, solution remobjects sdk. allows send notifications clients, , notification can have data (just client server). myself use supertcp connection, works others too. can still offer soap interface clients must use it, ...

Opening Word (from Outlook VBA) in Safe Mode -

i have word document attachment email need data out of pass url. i'm saving attachment local temp file, opening document, , using word object model pull data out of tables in document. i'm having couple of problems when opening document in vba: firstly it's slow because have corporate macro stuff loads when word opens; , secondly if there messages ping when word opens (such document recovery stuff), code hangs , word never closed. so, question can open word in safe mode vba nothing bare bones document available (because that's need)? or, there better way of controlling word gets around issues i'm having? perhaps use shell open in safe mode, say: "c:\program files\microsoft office\office11\winword.exe" /a then use getobject instance. more details: dim wd object dim strword string, strdoc string dim intsection integer dim inttries integer on error goto errorhandler strword = "c:\program files\microsoft office\office1...

asp.net - Do I need to copy the .compiled files to the production server? -

i'm using deploy project deploy asp.net web application. when build deploy project, .compiled files re-created. do need ftp them production web server? if small change need copy web site again? from own research, .compiled files must copied production server, not needed copied every time from rick strahl excellent blog: the output merge utilitity can combine markup , codebeside code single assembly, still end .compiled files required asp.net associate page requests specific class contained in assembly. however, because file names generated fixed don’t need update these files unless add or remove pages. in effect means in situations can update single assembly update web. source

javascript - How to add a script onLoad? -

i have add javascript onload on tag : have form , want disable input @ load. how can symfony please ? have forms, can't add in tag of layout you can use view.yml add js script on views containing forms. this: yourviewsuccess: javascripts: [yourscript.js] if want use onload or onready, see link : http://docs.jquery.com/how_jquery_works#launching_code_on_document_ready

how do you add a named range to worksheet using php pear spreadsheet excel writer -

is posible using excel_spreadsheet_writer create name such as $workbook = new spreadsheet_excel_writer(); $worksheet = &$workbook->addworksheet('checknames'); $worksheet->writename(0, 0, 'answertoeverythig', '42'); $worksheet->write(0, 1, 'double ='); $worksheet->writeformula(0, 2, '=answertoeverythig * 2'); $workbook->send('checknames.xls'); $workbook->close(); and dispay 84 in cell c1 as recommended cypher i've tried phpexcel internal server error on following $prices_sheet->setcellvaluebycolumnandrow(4, $row, '=if(round_up=0, (c'.$row.'+d'.$row.'), 0.01 )'); changing formula '=if(0=0, (c'.$row.'+d'.$row.'), 0.01 )' stops error. therefore phpexcel has problems resolving formulas using named ranges. found http://phpexcel.codeplex.com/thread/view.aspx?threadid=209472 i'm not sure how spreadsheetexcelwriter , can done ...

cruisecontrol - phpUnderControl and PHPUnit always failing build with code 255 -

i have following build.xml file setup in phpundercontrol. <target name="phpunit"> <exec executable="phpunit" dir="${basedir}/httpdocs" failonerror="on"> <arg line="--log-junit ${basedir}/build/logs/phpunit.xml --coverage-clover ${basedir}/build/logs/phpunit.coverage.xml --coverage-html ${basedir}/build/coverage --colors ${basedir}/httpdocs/qc/unit/calculatortest.php" /> </exec> </target> for unkown reason build fails below message. phpunit: [exec] phpunit 3.4.15 sebastian bergmann. [exec] build failed /opt/cruisecontrol-bin-2.8.3/projects/citest.local/build.xml:30: exec returned: 255 i have run simple unit test manually within unit directory , phpunit returns. phpunit 3.4.15 sebastian bergmann. . time: 0 seconds, memory: 5.25mb ok (1 test, 1 assertion) does know why keeps failing build, when tests fin...

coding style - In C# (or any language) what is/are your favourite way of removing repetition? -

i've coded 700 line class. awful. hang head in shame. it's opposite dry british summer. it's full of cut , paste minor tweaks here , there. makes it's prime candidate refactoring. before embark on this, i'd thought i'd ask when have lots of repetition, first refactoring opportunities for? for record, mine using: generic classes , methods method overloading/chaining. what yours? i start refactoring when need to, rather first opportunity get. might of agile approach refactoring. when feel need to? when feel ugly parts of codes starting spread. think ugliness okay long contained, moment when start having urge spread, that's when need take care of business. the techniques use refactoring should start simplest. recommand martin fowler's book. combining common code functions, removing unneeded variables, , other simple techniques gets lot of mileage. list operations, prefer using functional programming idioms. say, use internal it...

c# - What is the assembly element in resx files for? -

the program i'm working on reads resx files , fails read 1 particular resx file has 2 assembly elements same name. ex. <assembly alias="system.windows.forms" name="system.windows.forms, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" /> <assembly alias="system.windows.forms" name="system.windows.forms"> are in same resx file. when parsing data element below latter assembly system.typeloadexception thrown. when delete latter one, there no exception thrown. that's error/problem, though it's hard know how got there without more info. remove second (not fully-qualified) assembly definition, , should work fine.

django - Choose test database? -

i'm trying run ./manage.py test but tells me got error creating test database: permission denied create database obviously doesn't have permission create database, i'm on shared server, there's not can that. can create new database through control panel don't think there's way can let django automatically. so, can't create test database manually , instead tell django flush every time, rather recreating whole thing? i had similar issue. wanted django bypass creation of test database 1 of instances (it not mirror tough). following mark's suggestion, created custom test runner, follows django.test.simple import djangotestsuiterunner class bypassabledbdjangotestsuiterunner(djangotestsuiterunner): def setup_databases(self, **kwargs): django.db import connections old_names = [] mirrors = [] alias in connections: connection = connections[alias] # if database test mirr...

unicode - international characters in Javascript -

i working on web application, transfer data server browser in xml. since i'm danish, run problems characters æøå . i know in html, use "&amp;aelig;&amp;oslash;&amp;aring;" æøå . however, chars pass through javascript, black boxes "?" in them when using æøå , , "&aelig;&oslash;&aring;" printed is. i've made sure set utf-8, isn't helping much. ideally, want work special characters (naturally). the example isn't working included below: <!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <script type="text/javascript" charset="utf-8"> alert("&aelig;&oslash;&aring;"); alert("æøå...

visual studio 2008 - What is the worker process for IIS7? -

i'm trying 'attach process' debugging in visual studio 2008 , can't figure out process attach to. help. indeed still w3wp.exe - you'll need check ' show processes in sessions ' option show though. (it caught me out while too.)

PHP SQL Pagination -

i can't seem desired result query: select * `messages` `msgtype` = '0' , `status` = '0' order `datesent` desc limit 20, 0 basically, i'm trying show 20 results per page, query returns nothing. (for record, instances in database have msgtype , status 0) edit: removing limit part gives me results not divided , paginated want edit v2 limit should followed offset, # of records (i dumb) limit 20, 0 means: start @ row 21, return 0 rows, answer correct. did mean: limit 0, 20

.net - How do I make a ListBox refresh its item text? -

i'm making example hasn't yet realized controls listbox don't have contain strings; had been storing formatted strings , jumping through complicated parsing hoops data out of listbox , i'd show him there's better way. i noticed if have object stored in listbox update value affects tostring , listbox not update itself. i've tried calling refresh , update on control, neither works. here's code of example i'm using, requires drag listbox , button onto form: public class form1 protected overrides sub onload(byval e system.eventargs) mybase.onload(e) integer = 1 3 dim tempinfo new numberinfo() tempinfo.count = tempinfo.number = * 100 listbox1.items.add(tempinfo) next end sub private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click each objitem object in listbox1.items dim info numberinfo = dire...

Spell Checking Service with python using mod_python -

what best available method developing spell check engine (for example, aspell_python ), works apache mod_python ? apache 2.0.59+rhel4+mod_python+aspell_python seems crash. is there alternative using aspell_python ? looks rhel4 culprit. works on fedore 7 (the version of apache newer , there no crash)

Python Regex Question -

i have end tag followed carriage return line feed (x0dx0a) followd 1 or more tabs (x09) followed new start tag . something this: </tag1>x0dx0ax09x09x09<tag2> or </tag1>x0dx0ax09x09x09x09x09<tag2> what python regex should use replace this: </tag1><tag3>content</tag3><tag2> thanks in advance. here code need: >>> import re >>> sample = '</tag1>\r\n\t\t\t\t<tag2>' >>> sample '</tag1>\r\n\t\t\t\t<tag2>' >>> pattern = '(</tag1>)\r\n\t+(<tag2>)' >>> replacement = r'\1<tag3>content</tag3>\2' >>> re.sub(pattern, replacement, sample) '</tag1><tag3>content</tag3><tag2>' >>> note \r\n\t+ may bit specific, if production of input not under control. may better adopt more general \s* (zero or more whitespace characters). using regexes parse xml , htm...

java - How to Set Multiple Components Visible on a JFrame? -

when add more 1 component on jframe , component added last displayed , rest not displayed , issue visibility ? import java.awt.graphicsenvironment; import java.awt.point; import java.awt.*; import javax.swing.jframe; import javax.swing.jbutton; import javax.swing.jlabel; public class centeringawindow { public static void main(string[] args) { jframe awindow = new jframe("this window title"); point center = graphicsenvironment.getlocalgraphicsenvironment().getcenterpoint(); int windowwidth = 400; int windowheight = 150; jbutton item1=new jbutton("hiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"); jbutton item2=new jbutton("how ?"); awindow.add(item1); awindow.add(item2); jlabel label1=new jlabel("label 1"); awindow.add(label1); jlabel label2=new jlabel("label 2"); awindow.add(label2); //center align jframe awindow.setlocationrelativeto(null); awindow.setdefaultcloseoperation(jframe.exit_on_close); awindow.setvisible(tru...

.net - Anyone using WPF for real LOB applications? -

anyone using wpf real lob applications? we have seen clever demos of wpf showing videos mapped onto 3d elements. these great real world of line-of-business applications make majority of developers efforts. wpf nice eye candy? while discussing it, smart guys building amazing apps: lawson smart office brings wpf goodness enterprise igt’s next-generation ui wpf billy hollis on getting smart wpf

Rails model validators break earlier migrations -

i have sequence of migrations in rails app includes following steps: create basic version of 'user' model create instance of model - there needs @ least 1 initial user in system can log in , start using it update 'user' model add new field / column. now i'm using "validates_inclusion_of" on new field/column. worked fine on initial development machine, had database these migrations applied. however, if go fresh machine , run migrations, step 2 fails, because validates_inclusion_of fails, because field migration 3 hasn't been added model class yet. as workaround, can comment out "validates_..." line, run migrations, , uncomment it, that's not nice. better re-order migrations user creation (step 2) comes last, after columns have been added. i'm rails newbie though, thought i'd ask preferred way handle situation :) the easiest way avoid issue use rake db:schema:load on second machine, instead of db:migrate...

compact framework - Where can I find a QR (quick response) Code component/API for Windows Mobile? -

i looking 3rd party solution integrate qr code reader in windows mobile applications (.net compact framework). component should integrate reader (camera) , decoder (algorithm) . i tried out quickmark reader, can called outside application , communicates using windows messages. works quiet well, doesn't give me every option need (e.g. has installed etc.). are there other solutions may have missed? open source? tested on different devices? here open source c# port of java qr code library .

Predefined Dialog templates in VB.NET? -

in vb.net there library of template dialogs can use? it's easy create custom dialog , inherit that, seems there templates sort of thing. i need simple save/cancel, yes/no, etc. edit: messagebox not quite enough, because want add drop-down menus, listboxes, grids, etc. if had dialog form ask pre-defined buttons, each of returned modal result , closed form, add controls , buttons there. why not create own template? i've done several types of forms, not dialogs. great way give jump-start. create basic dialog, keeping generic possible, save template. here article you: http://www.builderau.com.au/program/dotnet/soa/save-time-with-visual-studio-2005-project-templates/0,339028399,339285540,00.htm and: http://msdn.microsoft.com/en-us/magazine/cc188697.aspx

asp.net - Is is possible to use the AsyncFileUpload from the AjaxControlToolkit in a .Net 2.0 project? -

the title pretty says all. have project political reasons cannot moved later version of .net , love have drop-in control uploading files better old fileupload control. i'd use asyncfileupload control, it's not in latest version of toolkit supported in 2.0 framework. i've looked @ of flash based controls, integrating them trigger full regression test of project i'm on (multiple weeks). we've lived fileupload control because our files small, error handling when file gets larger won't unacceptable longer. -- edit -- found uploadify. @ first didn't think work, checked out forums way. found link http://www.uploadify.com/forum/viewtopic.php?f=7&t=142&p=8620&hilit=asp.net#p8620 works great. can whatever want in upload handler. i'm adding answer whoever follows: i found uploadify. @ first didn't think work, checked out forums way. found link http://www.uploadify.com/forum/viewtopic.php?f=7&t=142&p=8620&hi...

linux - How do you reliably get an IP address via DHCP? -

i work embedded linux systems want ip address dhcp server. dhcp client client use ( dhcpcd ) has limited retry logic. if our device starts without dhcp server available , times out, dhcpcd exit , device never ip address until it's rebooted dhcp server visible/connected. can't 1 has problem. problem doesn't seem specific embedded systems (though it's worse there). how handle this? there more robust client available? the reference dhclient isc should run forever in default configuration, , should acquire lease later if doesn't 1 @ startup. i using out of box dhcp client on freebsd, derived openbsd's , based on isc's dhclient, , out of box behavior. see http://www.isc.org/index.pl?/sw/dhcp/

java - Should I use EJB3 or Spring for my business layer? -

my team developing new service oriented product web front-end. in discussions technologies use have settled on running jboss application server, , flex frontend (with possible desktop deployment using adobe air), , web services interface client , server. we've reached impasse when comes server technology use our business logic. big argument between ejb3 , spring, our biggest concerns being scalability , performance, , maintainability of code base. here questions: what arguments or against ejb3 vs spring? what pitfalls can expect each? where can find benchmark information? there won't difference between ejb3 , spring based on performance. chose spring following reasons (not mentioned in question): spring drives architecture in direction more readily supports unit testing. example, inject mock dao object unit test business layer, or utilize spring's mockhttprequest object unit test servlet. maintain separate spring config unit tests allows isola...

iphone - NSOperationQueue and ASIHTTPRequest -

i'm writing test cases wrapper class written around asihttprequest . reasons can't determine, test cases complete failure before asihttprequest finishes. here's how program flow works. start in test case. init http engine object, instruct create new list create new asihttprequest object , set up. add request operation queue. wait until queue empty check see if delegate methods called , fail test if weren't. now, of time works fine , test passes, of time fails because delegate methods called after operation queue returned control wait method. test case // set flags 'no' - (void)setup { requestdidfinish = no; requestdidfail = no; } - (void)testcreatelist { nsstring *testlist = @"{\"title\": \"this list\"}"; jkengine *engine = [[jkengine alloc] initwithdelegate:self]; nsstring *requestidentifier = [engine createlist:jsonstring]; [self waituntilenginedone:engine]; nsstring *responsest...

version control - How do I create a readable diff of two spreadsheets using git diff? -

we have lot of spreadsheets (xls) in our source code repository. these edited gnumeric or openoffice.org, , used populate databases unit testing dbunit . there no easy ways of doing diffs on xls files know of, , makes merging extremely tedious , error prone. i've tried converting spreadsheets xml , doing regular diff, feels should last resort. i'd perform diffing (and merging) git text files. how this, e.g. when issuing git diff ? we faced exact same issue in our co. our tests output excel workbooks. binary diff not option. rolled out our own simple command line tool. check out excelcompare project . infact allows automate our tests quite nicely. patches / feature requests quite welcome!

dot - Graphviz size/pagesize attribute seemingly ignored -

how 1 set size of output image in graphviz via dot format? i'm using quickgraph , this technique render graphviz. in example below, i'm trying set maximum size of rendering. i've tried lots of variations on size (interpreted inches or pixels) , pagesize, both, each. doesn't matter. thing has effect resolution. i can't tell if it's mode don't have set (i.e. mode = "fixedsize"), if it's bad syntax coming out of quickgraph or if it's bug in graphviz. doubt second , third heavily, i'm throwing out there. digraph g { size="(20,20)", resolution=72, bgcolor="#c6cfd532" 0 [fontcolor="#2f4f4fff", style=filled, label="resource a('a')", color="#9fae8dff", fillcolor="#c4d6b6ff"]; 1 [fontcolor="#2f4f4fff", style=filled, label="resource b('b')", color="#9fae8dff", fillcolor="#c4d6b6ff"]; 2 [fontcolor="#2f4f4fff...

java - How to show/hide a column at runtime? -

Image
i'd show/hide column @ runtime based on particular condition. i'm using "print when expression" conditionally show/hide column (and it's header) in report. when column hidden, space have occupied left blank, not particularly attractive. i prefer if space used in more effective manner, possibilities include: the width of report reduced width of hidden column the space distributed among remaining columns in theory, achieve first setting width of column (and header) 0, indicate column should resize fit contents. jasperreports not provide "resize width fit contents" option. another possibility generate reports using jasper api instead of defining report template in xml. seems lot of effort such simple requirement. in later version (v5 or above) of jasper reports can use jr:table component , truly achieve (without use of java code using dynamic-jasper or dynamic-reports). the method using <printwhenexpression/> under <jr:...

PDF: hyperlink/position -

is there "console way" find out position , target of hyperlinks within pdf-documents? popular tools converting pdf-to-* end text or broken html documents. that's why wonder if there way know (exact position) within pdf can find link , pointing to. looking forward helpful reply. , kind regards you didn't specify language/platform, here .net solution: docotic.pdf library (disclaimer: work bit miracle) can used retrieve hyperlinks in document. may retrieve bounding box, text , other properties of link. please take @ " extract text link target " sample.

javascript - What's the effect of adding 'return false' to a click event listener? -

many times i've seen links these in html pages: <a href='#' onclick='somefunc(3.1415926); return false;'>click here !</a> what's effect of return false in there? also, don't see in buttons. is specified anywhere? in spec in w3.org? the return value of event handler determines whether or not default browser behaviour should take place well. in case of clicking on links, following link, difference noticeable in form submit handlers, can cancel form submission if user has made mistake entering information. i don't believe there w3c specification this. ancient javascript interfaces have been given nickname "dom 0", , unspecified. may have luck reading old netscape 2 documentation. the modern way of achieving effect call event.preventdefault() , , specified in the dom 2 events specification .

theory - Simple basic explanation of a Distributed Hash Table (DHT) -

could 1 give explanation on how dht works? nothing heavy, basics. ok, they're fundamentally pretty simple idea. dht gives dictionary-like interface, nodes distributed across network. trick dhts node gets store particular key found hashing key, in effect hash-table buckets independent nodes in network. this gives lot of fault-tolerance , reliability, , possibly performance benefit, throws lot of headaches. example, happens when node leaves network, failing or otherwise? , how redistribute keys when node joins load balanced. come think of it, how evenly distribute keys anyhow? , when node joins, how avoid rehashing everything? (remember you'd have in normal hash table if increase number of buckets). one example dht tackles of these problems logical ring of n nodes, each taking responsibility 1/n of keyspace. once add node network, finds place on ring sit between 2 other nodes, , takes responsibility of keys in sibling nodes. beauty of approach none of other nod...

formatting - How can I format numbers as dollars currency string in JavaScript? -

i format price in javascript. i'd function takes float argument , returns string formatted this: "$ 2,500.00" what's best way this? you can use: var profits=2489.8237 profits.tofixed(3) //returns 2489.824 (round up) profits.tofixed(2) //returns 2489.82 profits.tofixed(7) //returns 2489.8237000 (padding) then can add sign of '$'. if require ',' thousand can use: number.prototype.formatmoney = function(c, d, t){ var n = this, c = isnan(c = math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "", = string(parseint(n = math.abs(number(n) || 0).tofixed(c))), j = (j = i.length) > 3 ? j % 3 : 0; return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + math.abs(n - i).tofixed(c).slice(2) : ""); }; and use with: (123456789....

osx - Cocoa - Force Quit all other applications -

is there way force quit other applications cocoa app? if kills app if doesn't matter supposed quit too. it has force quit since dont want dialogue boxes saving or poping up. thanks! , cocoa in desktop osx. not iphone. look @ nsworkspace method runningapplications , class nsrunningapplication .

Using jQuery to find ID of containing element -

<li id="someid"> <div id="div1">text</div> <div id="div2">text x 2</div> <div id="div3">text x 3</div> <span> <div> <ul> <li class="menuitem">menu item</li> </ul> </div> </span> </li> in short, i'm trying find id "someid" when class "menuitem" clicked. code below doesn't seem cutting it. $('.menuitem').click(function(){alert($(this).closest('li').attr('id'));}); instead of .closest('li'). use .parents('li'). ( note plural ) it mentioned @ closest() documentation ..

c# - Can I Override with derived types? -

as far know not possible following in c# 2.0 public class father { public virtual father somepropertyname { { return this; } } } public class child : father { public override child somepropertyname { { return this; } } } i workaround problem creating property in derived class "new", of course not polymorphic. public new child somepropertyname is there solution in 2.0? features in 3.5 address matter? this not possible in .net language because of type-safety concerns. in type-safe languages, must provide covariance return values, , contravariance parameters. take code: class b { s get(); set(s); } class d : b { t get(); set(t); } for get methods, covariance means t must either s or type derived s . otherwise, if had reference object of type d stored in variable typed b , when called b.get() wouldn't object representable s -- brea...

vim - What is in your .vimrc? -

vi , vim allow awesome customization, typically stored inside .vimrc file. typical features programmer syntax highlighting, smart indenting , on. what other tricks productive programming have got, hidden in .vimrc? i interested in refactorings, auto classes , similar productivity macros, c#. you asked :-) "{{{auto commands " automatically cd directory file in autocmd bufenter * execute "chdir ".escape(expand("%:p:h"), ' ') " remove trailing whitespace in file autocmd bufread,bufwrite * if ! &bin | silent! %s/\s\+$//ge | endif " restore cursor position before augroup jumpcursoronedit au! autocmd bufreadpost * \ if expand("<afile>:p:h") !=? $temp | \ if line("'\"") > 1 && line("'\"") <= line("$") | \ let jumpcursoronedit_foo = line("'\"") | \ let b:doopenf...

.net - Generated asynchronous method calls in C# - AOP? -

i working on wpf application uses businesslogic layer (currently single dll) in created bl methods called directly ui. each bl manager resolved unity (thinking on switching mef though...). bl classes implements specific interface have of course apropriate methods. now, want create (or rather generate) new asynchronous-aspect-like assembly (or more...) should have similar methods/operations defined in original assembly (the same parameters...) , callback delegate parameter. want async methods generated framework out there... besides usual call to: user userbo = resolve().login("name", "pass"); i'd use similar with: resolve().login("name", "pass", delegate(object, someargs e) { user userbo = e.args....}; now, want assembly generated instead of writing new eventargs , delegates each method. aware postsharp in aop task, coulnd't find regarding code generation mechanism in new dll asynchronous methods. is there way achieve using t...

javascript - jQuery Tips and Tricks -

syntax shorthand ready-event roosteronacid line breaks , chainability roosteronacid nesting filters nathan long cache collection , execute commands on same line roosteronacid contains selector roosteronacid defining properties @ element creation roosteronacid access jquery functions array roosteronacid the noconflict function - freeing $ variable oli isolate $ variable in noconflict mode nickf no-conflict mode roosteronacid data storage the data function - bind data elements tenebrousx html5 data attributes support, on steroids! roosteronacid the jquery metadata plug-in filip dupanović optimization optimize performance of complex selectors roosteronacid the context parameter lupefiasco save , reuse searches nathan long creating html element , keeping reference, checking if element exists, writing own selectors andreas grech miscellaneous check index of element in collection redsquare live event handlers tm replace anonymous fu...

php - Safe file upload without https (ssl layer) -

i'm php developer , know little when comes https/ssl, offer client safest possible way of uploading file webpage (i.e. webftp part of client service on page). which way should look? thank in advance, clarify question if needed. i'll disappoint you, without https or other form of encryption, data passing on wire plaintext - holds ftp. (in other words, it's practically impossible verify data server has received came client, , hasn't been modified.) valid (and accepted) https certificates cheap , relatively simple use, plus it's optimal solution available in terms of safety*simplicity (switch urls http https, no other configuration required end user). valid ssl certificate, client reasonably sure they're communicating site , data encrypted while in transit. in other words, there safer (but more complicated) alternatives (such encrypted vpn), , there simpler (but less safe) alternatives (such plain http). https done right right combination of s...

javascript cookie problem -

i new javascript. today tried function found on internet: function get_cookie ( cookie_name ) { var cookie_string = document.cookie ; if (cookie_string.length != 0) { var cookie_value = cookie_string.match ( '(^|;)[\s]*' + cookie_name + '=([^;]*)' ); return decodeuricomponent ( cookie_value[2] ) ; } return '' ; } if call function once, works; if call function twice, it's not working. function onloadthis() { var t = get_cookie('t'); // if add one, not working var s = get_cookie('s'); // more code } both cookies exist. there workaround make work, or can 2 variable merged in cookie? thank help. you try instead different regexp: not var cookie_value = cookie_string.match ( '(^|;)[\s]*' + cookie_name + '=([^;]*)' ); bu...

sed - Join string to the left side of output -

how can join string left side output? for example: want join parameter="file/" remark: file=/dir1/dir2/ (file has value) echo aaa bbb | awk '{print $2}' | sed .... will print /dir1/dir2/bbb assuming input good, should enough. sed "s|\(.*\)|$variable\1|"

svn - TortoiseSVN: Show status of multiple working folders in parent folder -

i have repository configured this: \util_1 \branches \tags \trunk \util_2 \branches \tags \trunk ... now, on local disk have: \dev \utils \util_1 \util_2 in util_xx folders trunks. if enter utils folder, tortoisesvn shows status icons each util. unfortunately, utils folder contain them doesn't have status icon. it's not checkout folder can't see there changed in unless enter it. looking @ dev folder shows nothing it. happened didn't checkin , since i'm not regular developer repo, forgot file there month. is there way make tortoisesvn show cumulative status of child folders in parent folder? you could install svn server locally, set 'utils' repo keep date 'externals' links each of util_1, util_2, etc., ... , don't know sure if work because don't know if tortoisesvn shows status of external children in icon of parent. you should change folder hierarchy align actual repository hierarchy. thi...

Why would a server not set a HTTP Response Code? -

i'm asking in generalities - why server not set , return headers and/or status codes? can't think of reason this. perhaps i'm overlooking something. the status-code required part of http response. by definition, reason server not provide status-line is not http server. rfc 2616, section 6: response . or said in less pedant way: if this, server hopelessly buggy , should run away screaming.

iphone - Hidden features of Objective-C -

objective-c getting wider use due use apple mac os x , iphone development. of favourite "hidden" features of objective-c language? one feature per answer. give example , short description of feature, not link documentation. label feature using title first line. method swizzling basically, @ runtime can swap out 1 implementation of method another. here explanation code. one clever use case lazy loading of shared resource: implement sharedfoo method acquiring lock, creating foo if needed, getting address, releasing lock, returning foo . ensures foo created once, every subsequent access wastes time lock isn't needed more. with method swizzling, can same before, except once foo has been created, use swizzling swap out initial implementation of sharedfoo second 1 no checks , returns foo know has been created! of course, method swizzling can trouble, , there may situations above example bad idea, hey... that's why it's hidden feature...

c - Underscore function -

i'm here looking @ c source code , i've found this: fprintf(stderr, _("try `%s --help' more information.\n"), command); i saw underscore when had @ wxwidget, , read it's used internationalization. found horrible (the least intutive name ever), tought it's weird wxwidget convention. now find again in alsa source. know comes from? it comes gnu gettext , package designed ease internationalization process. _() function string wrapper. function replaces given string on runtime translation in system's language, if available (i.e. if shipped .mo file language program).

c# - How do I get the contents of an XML element using a XmlSerializer? -

i have xml reader on xml string: <?xml version="1.0" encoding="utf-8" ?> <story id="1224488641nl21535800" date="20 oct 2008" time="07:44"> <title>press digest - portugal - oct 20</title> <text> <p> lisbon, oct 20 (reuters) - following of main stories in portuguese newspapers on monday. reuters has not verified these stories , not vouch accuracy. </p> <p>more html stuff here</p> </text> </story> i created xsd , corresponding class deserialization. [system.xml.serialization.xmlrootattribute(namespace="", isnullable=false)] public class story { [system.xml.serialization.xmlattributeattribute()] public string id; [system.xml.serialization.xmlattributeattribute()] public string date; [system.xml.serialization.xmlattributeattribute()] public string time; public string title; public string text; } i create instance of cla...

What was the strangest coding standard rule that you were forced to follow? -

when asked this question got definite yes should have coding standards. what strangest coding standard rule ever forced follow? and strangest mean funniest, or worst, or plain odd. in each answer, please mention language, team size was, , ill effects caused , team. i hate when use of multiple returns banned.

jquery - Returning JSON data to view page in ASP.NET MVC -

i'm working on mvc project , using jquery in view page data controller. public jsonresult checkupdate() { dt = dt.addseconds(-100); iqueryable<tweet> _tweet = ttr.checktime(dt); return json(_tweet, jsonrequestbehavior.allowget); } this method in controller gets data repository class , returns json view page, uses jquery it. when run program , inspect in firebug, shows me error is: a circular reference detected while serializing object of type 'tweettrafficreport.models.user' my question is is correct return json data iqueryable type how can use json data in view page , not error above thanks ur :) the circular reference bet because of fact have tweet object reference inreplyto iqueryable isnt big issue casting each tweet jsoncapabletweet hanselman http://nerddinnerbook.s3.amazonaws.com/part11.htm however lolok @ way twitter http://search.twitter.com/search.json?callback=foo&q=twitter thats pretty nice json return, ...

iis - Setting up a new team work environment for asp.net -

we own small company , develop asp.net websites. here our work procedure: have server @ company sql server 2008 , iis 7.5 installed on it. our projects including database , website pages on server. connect server , edit files using ftp, change web page can seen @ once. programmers (less 10 programmers) connect server using visual studio 2010. now want include source control system in our work. problem including scm in our work requires changing our way of working. does have advise on setting working environment? thanks in advance. you first need decide on type of scm going use - centralized or distributed. one centralized scm tfs - ms , integrates vs. believe there express (basic) version free, other editions quite expensive. an easy , free centralized scm start subversion - can install svn server on server , setup client each developer. a distributed scm not have server - popular 1 git . do read on of these before deciding. have figure out workflow team....

vb.net - Find an item in an List(Of T) by values x, y, and z -

i have following setup: class property x string property y int property z string end class class collofa inherits list(of a) end class what item property in collection can say: dim c new collofa c.item("this", 2, "that") i have tried implementing following in collofa: class collofa inherits list(of a) default public overridable shadows readonly property item(byval x string, byval y integer, byval z string) ' want like: ' foreach item in me see if matches these 3 things end end property end class i know predicates, struggling how set criteria of predicate (i.e. passing x, y, , z). has implemented similar? here's 2 ways came accomplish question. 1 way uses linq query syntax filter; second uses custom object hold predicate parameters , uses object perform filter. using linq syntax in item property: default public overridable shadows readonly proper...

Change default number formatting in R -

is there way change default number formatting in r numbers print way without repeatedly having use format() function? example, have > x <- 100000 > x [1] 100,000 instead of > x <- 100000 > x [1] 100000 well if want save keystrokes, binding relevant r function pre-defined key-strokes, fast , simple in of popular text editors. aside that, suppose can write small formatting function wrap expression in; instance: fnx = function(x){print(formatc(x, format="d", big.mark=","), quote=f)} > 567 * 43245 [1] 24519915 > fnx(567*4325) [1] 2,452,275 r has several utility functions this. prefer "formatc" because it's little more flexible 'format' , 'prettynum'. in function above, wrapped formatc call in call 'print' in order remove quotes (") output, don't (i prefer @ 100,000 rather "100,000" ).

What is the SQL MODE in MYSQL (or any RDBMS)? -

what sql mode in mysql (or rdbms)? best option have sql mode , why? if have layman explanation example great! thank in advance ;-) the sql mode affects how mysql behaves in situations. example, affects happens if try insert overlong content text type column. let's have column char(10) character set ascii not null , , try insert 'abcdef abcdef' . that's 13 characters, long. if current sql mode includes strict_trans_tables or strict_all_tables , mysql not insert value give error message. if neither of these on, mysql truncate string 10 characters, i.e. 'abcdef abc' , , insert that. there lots of other behaviours affected sql mode. example. i use traditional , shorthand for, well, link given dcp tell you. basically, makes mysql less forgiving when send invalid input, find preferable because if send mysql that's not valid i'd rather know it, rather have mysql fudge , not tell me it's done so.

java - learning Spring's @RequestBody and @RequestParam -

i'm editing web project uses spring , need adding of spring's annotations. 2 of ones i'm adding @requestbody , @requestparam . i've been poking around little , found this , still don't understand how use these annotations. provide example? controller example: @controller class foocontroller { @requestmapping("...") void bar(@requestbody string body, @requestparam("baz") baz) { //method body } } @requestbody : variable body contain body of http request @requestparam : variable baz hold value of request parameter baz

c# - MessageBox.Show-- font change? -

i'm using messagebox class show errors users, , while might not right behavior, it's convenient. touchscreen application, however, need 'ok' button larger (curse inordinately large fingers!). i think if increase font size in dialog box, should ok. there way that? or really, there way increase dialog size? thanks as far i'm aware can't, 'normal' dialog boxes using default system font settings. roll own best way forward. it's trivial do, , fun! , can build in things standard dialog doesn't support (without pinvoke magic) such centering in middle of screen etc.

visual studio 2008 - Detect .NET Framework 3.5 SP1 Dependency (cmp. 3.5 w/o SP1) -

i'm using 3.5 sp1 on machine, while our customers use 3.5 without sp1. don't know way in vs2008 target solution or project 3.5 without sp1, 3.5 sp1 have installed. if use functions or constructors not available in 3.5 w/o sp1 code not work properly. that is, want detect @ compile time not work without sp1. so far have done testing (in vm or separate machine) see if application breaks, , break when we've used parts of api not available until sp1. problem breaks when code runs (at runtime), not when assembly loaded. one solution have machine vs2008 w/o sp1 , try compile project. i'd prefer tool me detect dependency 3.5 sp1 (due use of new api, or whatever), either analyzing source code, or assemblies produce. my google powers has not been strong enough question, hints? i had same problem, , found solution. our application, call system.threading.waithandle.waitone(int32) got in trouble. more details on how references api's introduced in service ...