Posts

Showing posts from January, 2013

testing - Cabal Configure fails on Configuring test (Windows) -

i new haskell , trying install yesod on windows machine using cabal. when try yesod devel build failure, saing must run configure first. then when run cabal configure fails following message: resolving dependencies... configuring test-0.0.0... cabal: test sharing name of exe found. consider bug. i using latest haskell platform (2012.2.0.0). apparently there's bug in cabal, , can't have test executable same name regular executable. since test executable named test , , regular executable has same name project, appear test no longer valid name yesod project. if name else, should work. could file bug report on github prevent people using name test ?

asp.net mvc 3 - Request.Form[] return's null -

i used file controller , allow user upload file name @using (html.beginform("attachfile", "coursework", new { enctype = "multipart/form-data" }, formmethod.post)) { @html.hiddenfor(model => model.prtfmaster.iconfilename, new { @id = "filename" }) <input type="file" name="file" id="file1"/>} on controller write this: public actionresult uploadprtfassgmnt(formcollection form,httppostedfilebase file,coursework cwork) with i'm able fetch uploaded file name inside function if try value this: string filename = request.form["filename"]; it returning null. can me this? please

vba - How to Launch an Excel macro from command line (Without Worksheet_Open Event)? -

is possible launch excel macro command line? i don't want use worksheet_open event , open excel file. i need launch specific macro exists in excel workbook. use windows powershell, has excellent com interop support. i have workbook c:\testbeep.xlsm macro called "test". transcript: ps c:\> $app = new-object -comobject excel.application ps c:\> $wb = $app.workbooks.open("c:\testbeep.xlsm") ps c:\> $wb.name testbeep.xlsm ps c:\> $app.run("test") ps c:\> $app.quit() optionally can add in $app.visible = $true make window visible.

blackberry:position of field in the screen -

i want open popup screen in same position of label. want method return position of field in screen. , use these position popup. public void sublayout(int width, int height){ super.sublayout(width,height); setposition(x_postion_of_label,y_postion_of_labe); } int xpos=labelfield.getleft() ; & int ypos=labelfield.gettop(); will give starting x , y positions of labelfield .

php - Time not updating correctly in mysql -

i trying add update sets users last activity, @ moment displaying 838:59:59 time in mysql, , not quite sure why. here query using on each page update it. mysql_query("update users set last_activity = ".time()." user_id = ".$user_id); any ideas why appreciate thanks mysql_query("update users set last_activity = now() user_id = ".$user_id);

create service using searchd command of Sphinx -

make index on 1 sphinx compatible xml document.it runs success fully. make service using searchd command.following command make service searchd --install --config "path config file" --servicename "servicename" --port "portnumber". if sphinx config file put inside sphinx directory service create , start successfully. if config file not inside sphinx directory service created can not start successfully. should change inside searchd block in config file? according the documentation (http://sphinxsearch.com/docs/current.html#ref-searchd) parameters specified when creating service called when starting service. --install installs searchd service microsoft management console (control panel / administrative tools / services). other parameters specified on command line, --install specified become part of command line on future starts of service. example, part of calling searchd, need specify configuration file --config, , specifying --inst...

ruby on rails - ActiveRecord::ConnectionNotEstablished with PostgreSQL 9.1.3 and RoR 3.2.5 -

i installed postgresql homebrew: $ brew install postgresql i installed pg gem with: $ gem install pg -- --with-pg-config= '/usr/local/var/postgres/postgresql.conf' i changed app's database.yml development:   adapter: postgresql   encoding: unicode   database: rails_dev   pool: 5   username: vise890   password: test:   adapter: postgresql   encoding: unicode   database: rails_test   pool: 5   username: vise890   password: production:   adapter: postgresql   encoding: unicode   database: ddb port: 5432   pool: 5   username: postgres   password: admin however, whenever load page error: activerecord::connectionnotestablished i can connect db pgadmin (u:vise890 p:{none}) , see databases. i doing example3 ruby on rails tutorial if want check whole thing: sample app github branch thanks in advance guys! ok, nevermind. started scratch , worked. here's the walkthrough in case interested

java - Execute Batch with only one query? -

my general question is : inefficient/bad practice call preparedstatement.executebatch() if there's 1 query in batch? i'm writing generic method java helper library execute query. there's javabean called helperquery holds list of arrays javabean called queryparameter holds type (like string , blob , int , etc.) , value. queryparameter used fill helperquery 's preparedstatement . in many cases, there 1 array of queryparameter s. my specific question is : should handle things differently if there's 1 array of queryparameter s or ok handle things same regardless of how many queryparameter s there are? executebatch " super " method preparedstatement 's parent statement returns int[] indicates success/failure of executed queries , executequery returns resultset . therefore, idea have 2 totally different method calls developer can handle them differently. recommend: an executequery(helperquery helperquery) method return associate...

Advanced SQLite Update table query -

i trying update table b of database looking this: table a: id, amount, date, b_id 1,200,6/31/2012,1 2,300,6/31/2012,1 3,400,6/29/2012,2 4,200,6/31/2012,1 5,200,6/31/2012,2 6,200,6/31/2012,1 7,200,6/31/2012,2 8,200,6/31/2012,2 table b: id, b_amount, b_date 1,0,0 2,0,0 3,0,0 now query data need in 1 select: select a.*,b.* left join b on b.id=a.b_id a.b_id>0 group b.id id, amount, date, b_id, id, b_amount, b_date 1,200,6/31/2012,1,1,0,0 3,400,6/29/2012,1,1,0,0 now, want copy selected column amount b_amount , date b_date b_amount=amount, b_date=date resulting in id, amount, date, b_id, id, b_amount, b_date 1,200,6/31/2012,1,1,200,6/31/2012 3,400,6/29/2012,1,1,400,6/29/2012 i've tried coalesce() without success. experienced have solution this? solution: thanks answers below, managed come this. not efficient way fine 1 time update. insert first corresponding entry of each group. replace select id, amount, date (select a.id, a.amount, b.id bid inner join b...

java - Iterate Generic type<User> of ArrayList -

i trying values arraylist. i have user type bean class below.. class user{ public string link; public string url; user(string l,string u){ this.link=link; this.url=url; } setters , getters below.. here trying write class main. public class listclass{ public static void main(string args[]){ list<user> list = new arraylist<user>(); list.add(new user("link1","url1")); list.add(new user("link2","url2")); list.add(new user("link3","url3")); //here want iterate both links , urls 1 one iterator it=list.iterator(); // remaining code both link1 , url1 .. } i need output as: link1 url1 link2 url2 link3 url2 you can use for-in construct instead of iterator: for (user u : list) { system.out.println(u.link + " " + u.url); } if want use iterator: ...

MS-Access, form that adds info to a one to many relationship -

i have access table orders , sub-table itemid's. has 1 many relationship. i want create form adds itemid's selected order(already existing). this how expect like: order: [ ] itemid: [ ] measurement1: [ ] measurement2: [ ] [save-button] can me this? subforms politically correct way go if want users have access order screen. if users not need access order details directly, items, put combo-box order: [ [v]] which has control source query order id in orders table. link orders field in item table , store order subform would, without letting user see details of order. however, if want multiple items shown selected order, use subforms (having subform multiple-item)

php - Reverse Geocode On Google Maps api v3 -

i wonder whether may able me please. i using code shown below correctly plot markers retrieved mysql database on google map. <script type="text/javascript"> //sample code written august li var icon = new google.maps.markerimage("images/location-marker-2.png") new google.maps.point(16, 32); var center = null; var map = null; var bounds = new google.maps.latlngbounds(); function addmarker(lat, lng, info) { var pt = new google.maps.latlng(lat, lng); bounds.extend(pt); var marker = new google.maps.marker({ position: pt, icon: icon, map: map }); } function initmap() { map = new google.maps.map(document.getelementbyid("gmaps-canvas"), { center: new google.maps.latlng(0, 0), zoom: 6, scrollwhee...

sparql - Semantic web database of music festivals? -

i'm trying use dbpedia return list of major british music festivals (specifically ones defined in this wikipedia template ) , dates/locations on last twenty years, however, finding actual data (particularly regards dates) limited. anyone know of better resource dbpedia kind of task? alternately, there way of gathering data dbpedia i'm missing? i not know better rdf resources on british music festivals. but, when on specific topic generic data source dbpedia. if passionate specific "british music festivals" suggest build own rdf dataset , publish somewhere. other people same passion might come , you. if know website information need in html might able of need 'scraping'. there such website on 'british music festivals'?

zoom - Streetnames openstreetmaps more readable on Android -

Image
i've build android app offline map data using openstreetmaps , osmdroid. on device mdpi 320x480 pixels map looks ok, on device hdpi screen 480x800 pixels street names small , little bit harder read them. map data till zoom level 18, maximum download , use mapnik tile source, loaded zip-file sd-card. local maps defined region of brussels (belgium). a screenshot of mdpi device 320x480 pixels: a screenshot of hdpi device 480x800 pixels: if see these views in app on device mdpi map readable, in hdpi map street names smaller. is there way make street names more readable on hdpi device, user haves idea zooms 1 step further on map? because it's not possible go zoom-level 19, because there no openstreetmaps data it. little workaround solution easy , small implementation time/work ok me. zooming done swiping on map. if need code, let me know , i'll post it. thanks in advance. kr osmdroid works tiles static png images. can not change tile images. if want ...

osx - NSTextView: When to automatically insert characters (like auto-matching parenthesis)? -

i've got nstextview , i'm acting nstextstorage delegate, i'm getting callbacks textstoragewillprocessediting: , textstoragedidprocessediting: , , i'm using did callback change attributes on text (coloring words). what i'd add auto-matching of character pairs. when user types ( , want insert ) i'm not sure when or proper time this. from text storage delegate protocol, says will method lets change text displayed.. i'm not sure means or how can that. text system big , confusing. how should this? in open-source project, subclassed nstextview , overrode inserttext: handle insertion of matching characters there. can examine argument inserttext: see if want act on, call super perform normal insertion of text, call inserttext: again appropriate matching character string if needed. something this: - (void)inserttext:(id)insertstring { [super inserttext:insertstring]; // if insert string isn't 1 character in length, cannot...

Orbeon Forms Builder custom persistence API: Why does it call /crud/.../data/data.xml? -

i implementing own persistence layer orbeon forms. far have understood virtual hierachy of data , creating form form builder in application "myapp" name "myform" should cause form builder call /crud/myapp/myform/form/form.xhtml, passing newly created form http-put data. created spring method annotated with: @requestmapping(method = requestmethod.put, value = "/crud/{applicationname}/{formname}/form/form.xhtml") public void saveform(@pathvariable string formname, @requestbody string putdata) i expected method called form. method not called. instead method @requestmapping(method = requestmethod.put, value = "/crud/{applicationname}/{formname}/data/{uuid}/data.xml") public void saveinstance(@pathvariable string uuid, @requestbody string putdata) gets called. putdata contains full xhtml form. why happening? thought second url called saving instance, more <xforms:instance id="fr-form-instance"> part of form, once fill i...

java - How to improve the performance of the recursive method? -

i'm learning data structures , algorithms, , here question i'm stuck with. i have improve performance of recursive call storing value memory. but problem non-improved version seems faster this. can me out? syracuse numbers sequence of positive integers defined following rules: syra(1) ≡ 1 syra( n ) ≡ n + syra( n /2), if n mod 2 == 0 syra( n ) ≡ n + syra(( n *3)+1), otherwise import java.util.hashmap; import java.util.map; public class syralengthsefficient { int counter = 0; public int syralength(long n) { if (n < 1) { throw new illegalargumentexception(); } if (n < 500 && map.containskey(n)) { counter += map.get(n); return map.get(n); } else if (n == 1) { counter++; return 1; } else if (n % 2 == 0) { counter++; return syralength(n / 2); } else { counter++; return syral...

Convert POSIX->WIN path, in Cygwin Python, w/o calling cygpath -

i use python script, running in cygwin build of python, create commands issued native windows utilities (not cygwin-aware). requires conversion of path parameters posix win form before issuing command. calling cygpath utility nicest way this, since uses cygwin it's there do, it's little horrifying (and slow). i'm running cygwin build of python - code conversion present. seems there should cygwin/python specific extension gives me hook capability, directly in python, without having fire whole new process. this possible calling cygwin api using ctypes. below code works me–i using 64-bit cygwin dll version 2.5.2 on windows 2012, , works on cygwin versions of both python 2.7.10 , python 3.4.3. basically call cygwin_create_path cygwin1.dll perform path conversion. function allocates memory buffer (using malloc ) containing converted path. need use free cygwin1.dll release buffer allocated. note xunicode below poor man's alternative six (a python 2/...

sql server - Get the result from Select and Update the selected records in the same statement -

i want select few records database table , change value column 'pending' 'processing' n database. result select statement has go jms queue processing. using apache camel framework integration , ms sql server 2005 database. nice if can achieved single sql statement. you should able update , use output/output into feature return rows in result set http://decipherinfosys.wordpress.com/2007/05/25/using-the-output-and-output-into-clauses-in-sql-server-2005/

z3 - Z3_test_1.exe[2448] unhandled exception in Microsoft .net framework -

i wrote following program in visual studio 2010(version: 10.0.30319.1 rtmrel) c# language , version of .net framework 4.0.30319 rtmrel. there no errors or warnings when compiling, throw exception when running program. exception "z3_test_1.exe[2448] unhandled exception happened in microsoft .net framework", z3_test_1.exe program file name. z3 prover used in version z3 4.0 , in program used microsoft.z3.dll rather microsoft.z3v3.dll. using system; using system.collections.generic; using system.linq; using system.text; using microsoft.z3; //using microsoft.z3v3; namespace z3_test_1 { class program { static void main(string[] args) { using (context ctx = new context()) { realexpr c = ctx.mkrealconst("c"); boolexpr eqzero = ctx.mkgt(c,ctx.mkreal(0)); boolexpr gezero = ctx.mkge(c,ctx.mkreal(0)); boolexpr lttwo = ctx.mklt(c,ctx....

javascript - Regular expression returning some awkward value -

i have following javascript code: <script type="text/javascript"> //javascript starts var patt=/[<](\s+).*>(.*)<\/\1>/; var str='<a id="test">hi</a> <p></p>'; alert(str.match(patt)); alert(patt.exec(str)); </script> it expected to find tags in html document . ideally should return <a id="test">hi</a>, <p></p> . but returns <a id="test">hi</a>, ,hi . why happening? also question, what difference between str.match(patt) , patt.exec(str) , better use? var patt=/[<](\s+).*>(.*)<\/\1>/g; try specify global modifier (or stop @ first occurrence found). about second question mdn resource: https://developer.mozilla.org/en/javascript/reference/global_objects/string/match if regular expression not include g flag, returns same result regexp.exec(string). if regular expression includes g flag, method returns arra...

android - How get contacts info into sms broadcast receiver class? -

i have app works contacts info when cell phone receive sms, need contacts info sms receiver class create problem when sms receiver fetch contacts gave null pointer exception error because don't fetch contacts info, idea contacts info compare number of sms sender id other actions in app. here's code: public class smsbroadcastreceiver extends broadcastreceiver { private static final string sms_received = "android.provider.telephony.sms_received"; private static final string tag = "smsbroadcastreceiver"; private static activity mactivity; dbhelper mdbhelper; private context mcontext; private arraylist<contact> mcontactsarraylist; public string str4; private contactmanager acontactmanager; private arraylist<contact> ctnlist; @override public void onreceive(context context, intent intent) { //---get sms message passed in--- log.d("smsbroadcastreceiver", "yes calls...

sql server - How to update a datagridview using vb.net -

i using below mention code update , delete data datagridview. unable solve issue. delete working not update. public sub customerupdatebatch(byval dt datatable) dim connection sqlconnection = new sqlconnection(invoice.getconnect()) connection.open() try dim command sqlcommand = new sqlcommand("update_customer", connection) command.commandtype = commandtype.storedprocedure command.parameters.add("@c_id", sqldbtype.int, 16, "c_id") command.parameters.add("@c_name", sqldbtype.varchar, 50, "c_name") command.parameters.add("@c_address", sqldbtype.varchar, 50, "c_address") command.parameters.add("@c_tel", sqldbtype.varchar, 50, "c_tel") command.parameters.add("@c_fax", sqldbtype.varchar, 50, "c_fax") command.parameters.add("@c_mobile", sqldbtype.varchar, 50, "c_mobile") com...

java - calling a parameterized function in a preparedstatement -

i attempting use jdbc preparedstatement insert data sql server 2008 database. difficulty i'm running have point-in-time ids subject change, , need constant id based on other elements of insert. have written stored function perform lookup, myidlookup(x,y). i tried writing preparedstatement this: insert mytable (id,idelement1,idelement2,otheritem) values (myidlookup(?,?),?,?,?) i have seen examples using built in functions such now(), haven't seen using parameterized functions in preparedstatement. possible? thanks i think right way of doing write stored proc insert rows takes x , y , generates id calling myidlookup ad inserts row too. template may : stored proc insertrow (x, y, z) { id = myidlookup(x , y) insert table values (id, x , y, z) }

mongodb - Java driver equivalent for JavaScript shell's Object.bsonsize( doc )? -

i wondering java driver's equivalent mongo javascript shell's object.bsonsize( doc ) method? example, java code perform following: bobk-mbp:~ bobk$ mongo mongodb shell version: 2.0.4 connecting to: test primary> use devices; switched db devices primary> object.bsonsize( db.profiles.findone( { _id: "rek_0001" } ) ); 186 primary> object.bsonsize( db.profiles.findone( { _id: "rek_0002" } ) ); 218 primary> how perform same basic use case mongodb java driver. not obvious through javadocs. there's nothing quite clean what's available in shell, work: dbobject obj = coll.findone(); int bsonsize = defaultdbencoder.factory.create(). writeobject(new basicoutputbuffer(), obj));

asp.net mvc 4 - CSS Template Code Reading -

i'm new css , i'm trying read code comes default asp.net mvc 4 project template. can't figure out code generates little black bar goes across top of page. in html page there doesn't appear html code it, , can't find margins or padding in uppermost sections of page create it. the css code: http://textuploader.com/?p=6&id=8ddpk the .cshtml file defines layout: http://textuploader.com/?p=6&id=lcra7 the border-top body adds black bar @ top of page: html { background-color: #e2e2e2; margin: 0; padding: 0; } body { background-color: #fff; border-top: solid 10px #000; /* <-- adds border top of page */ color: #333; font-size: .85em; font-family: "segoe ui", verdana, helvetica, sans-serif; margin: 0; padding: 0; }

javascript - drag constraints in raphael.js and zoom -

i've had no problem getting basic zoom/pan effect raphael.js 2.0 using pan : set = ( // set of elements, contained in rectangle) var start = function () { set.obb = set.getbbox(); }, move = function (dx, dy) { var bb = set.getbbox(); set.translate(set.obb.x - bb.x + dx, set.obb.y - bb.y + dy); }, = function() { // stuff }; set.drag(move, start, up); and zoom : //before paper.setviewbox(0,0, 500,500, false); //after paper.setviewbox(0,0, 200, 200, false); but i'm having 2 big problems this. raphael-created svg object , not image... first, panning after zoom not 'smooth' : drag little , rectangle moves lot. movement gets worse farther go along. can scale drag somehow when have zoomed? second, how arrange panning zoomed rectangle doesn't let me move out of viewport? in jquery constraint, , i've tried playing set.translate function above include constraints i'm getting nowhere... any advice appreciated, or else...

java - CSV file, faster in binary format? Fastest search? -

if have csv file, faster keep file place text or convert other format? (for searching) in terms of searching csv file, fastest method of retrieving particular row (by key)? not referring sorting file sorry, mean looking arbitrary key in file. some updates: the file read-only the file can read , kept in memory there several things consider this: what kind of data store? make sense, convert binary format? binary format take less space (the time takes read file dependent on size)? do have multiple queries same file, while system running, or have load file each time query? do need efficiently transfer file between different systems? all these factors important decision. common case need load file once , many queries. in case hardly matters format store data in, because stored in memory afterwards anyway. spend more time thinking data structures handle queries. another common case is, cannot keep main application running , hence cannot keep file in memory. i...

c# - How to resolve a 'Bad packet length' error in SSH.NET? -

i'm trying upload files via sftp, using ssh.net . sftpclient.connect() throws sshconnectionexception message, "bad packet length 1302334341." code: static void main() { try { sftpclient sftp = new sftpclient(server, 22, userid, password); sftp.connect(); } catch(exception e) { console.writeline(e.message); } } i saw in discussion has encryption. i'm using aes, , have host key. don't understand how enter encryption, though. based on discussion, playing this: connectioninfo connectioninfo = new passwordconnectioninfo(server, 22, userid, password); connectioninfo.encryptions.clear(); connectioninfo.encryptions.add("aes","ssh-rsa 2048 11:22:34:d4:56:d6:78:90:01:22:6b:46:34:54:55:8a") i know that's not right set of arguments pass encryptions.add(), i'm little lost using library; can me figure out how set encryption (assuming that's problem)? solved, in this discussion . needed remove encryptions using for...

python - Subclasses in Django databases -

if have class foo(models.model): widgets = models.foreignkey('widgets.widget', related_name='widgets') i want save subclass, xwidget of widget database. ok, though foo.widgets of widget parent class not xwidget? when reading foo.widgets, if want find xwidgets filter way this? cheers yes, may save subclass foreign key referencing parent, because xwidget is-a widget . won't work in reverse, though. instance, if foreign key 'widgets.xwidget', couldn't save widget it.

SVG gradient fill doesn't work -

i'm trying add gradient background svg path. path black, instead. code i've got: <svg style="overflow: hidden; position: relative; " height="150" version="1.1" width="290" xmlns="http://www.w3.org/2000/svg"> ... <defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); "> <lineargradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%"> <stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1"></stop> <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1"></stop> </lineargradient> </defs> <path style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); " fill="url(#grad1)" stroke="none" d="m100,114l74,114l74,83l100,83z"></path> ... </svg> what miss...

sql - leave a column alone while replacing in mysql -

so suppose there's table: id column1 column2 1 333 4444 where id primary key and do replace table (id, column2) values (1, 55) this cause column1 become null...is there way specify query such leave whatever existing value of column1 when replace matches existing entry? use insert ... on duplicate key update : insert table (id, column2) values (1, 55) on duplicate key update column2 = values(column2)

c# - Should Type.GetType(string) be aware of dynamically generated types? -

i have app creates code using codedom compiler. can see generated assembly in memory. when call type.gettype(typename), returns null. find little bit confusing. what doing wrong? static void main(string[] args) { // fyi: code dummy class 1 instance method. string code = system.io.file.readalltext("codetocompile.cs.txt"); string errors = null; assembly asm = dynamiccompiler.compile(code, generateinmemory: true, generatedebuginfo: false, message: ref errors); // type generated assembly. know there one. type oneandonlytypeinassembly = asm.gettypes().first(); string typename = oneandonlytypeinassembly.assemblyqualifiedname; // tell type system return instance of type based on qualified name. // i'd expect work, since assembly loaded memory. type sametype = type.gettype(typename); if (sametype != null) { console.writeline("type found , equal={0}", oneandonlytypeinassembly.equals(sametype)); } ...

php - Retrieving (relating) two separate tags/attributes using a single XPath query? -

i xpathing domdocument file have. general pattern of domdocument follows: <h2> title info </h2> <div> .... </div> <p> ...</p> <div class = format_text> <p> <a href= "http://link..."><img src = "http://sourceofimageonline.com"></a> </p> </div> <h2> 2nd title</h2> <div> .... </div> <p> ...</p> <div class = format_text> <p> <a href= "http://link..."><img src = "http://sourceofimageonline.com"></img></a> <a href = "http://linkanother.."><img src = "http://sourceofimageonline.com"</img></a> </p> </div> the key return titles , src attribute images hyperlinks. essentially, render : title 1 img uri 1 title 2 img uri 2 img uri 3 ... .. now titles can retrieved using domdocument->getelementsbytagnames('...

c++ - beginner and cpp class -

i'm using code under "constructors , destructors" here basically, combine pointer construction under "pointers classes" (a little below) find neat. now works: int main () { crectangle * prect; //l2 crectangle rect (3,4); //l3 prect = &rect; //l4 cout << "rect area: " << (*prect).area() << endl; return 0; } my questions is, can replace l2-l4 more elegant method not requiring creation of rect on line 3? to create object without requiring automatic variables (such rect in code above) must use new operator. objects created new operator stored in free store , , new expression evaluates pointer newly created object. now, 1 go on , say, new operator answer , that's it, it's not: not answer question of replacing couple of lines more elegant solution, because wouldn't one. the rest of answer goes on tangent of how new used. unlike automatic objects, objects stored ...

asp.net mvc 3 - Greater Than or Equal To Today Date validation annotation in MVC3 -

has seen mvc3 data annotation date validation requires single selected date equal or greater current date? if there's third party add on that's cool too. i'm using dataannotationsextensions doesn't offer i'm looking for. there doesn't seem reference of on. so, hoping has solved before try reinvent wheel , write own custom validator. i've tried range requires 2 dates , both have constants in string format such [range(typeof(datetime), "1/1/2011", "1/1/2016")] doesn't help. , dataannotationsextensions min validator accepts int , double update solved thanks @buildstarted ended , works great server-side , client side script using system; using system.collections.generic; using system.componentmodel.dataannotations; using system.web.mvc; namespace web.models.validation { [attributeusage(attributetargets.field | attributetargets.property, allowmultiple = false, inherited = true)] public sealed class datemu...

javascript - Prevent script injection with innerHTML -

i have written micro-templating utility uses innerhtml inject html fragments in web page, based on user input (either plain text strings or html strings). my main concern risk of malicious script injection. script injected via script tag, or in inline event (img onload, div onmouseover example). is there way sanitize html string prevent such injections? also, there other script injection methods should aware of? if want safe, you'll sanitize templates both on client , server. don't write own anti-xss library malicious users bound know exploit haven't accounted for; there many nuances , unless you're xss expert, you're bound miss one. on client side, google caja has pretty nice html sanitization utility perform robust sanitization on html strings, cleaning malicious attributes or other areas nasty users can nasty things, xss attacks via injecting script tags. scrub attributes , kinds of other xss injection points ( object , applet tags, instan...

How do I simulate an "Edit" or "Destroy" button click in Rails 3.2 w/ MiniTest? -

how can write integration test editing item? "create" test looks this: "lets user create product" login_user click_link("products") click_link("new") fill_in "identifier", :with => "mystring" click_button "create" assert page.has_content?("product created") end and works great. confused how edit , destroy tests. index page provides list of products. first use factory create couple of products. in situation there multiple "edit" , "destroy" buttons. can't say: click_button "destroy" because there 2 of them. how tell 1 click? and if correct "destroy" button clicked, how hit "ok" button in javascript window pops up? assuming you're using webrat, can use "within" selector. the webrat "within" method takes css selector argument. supposing "destroy" button in div id ...

css - Detect support for transition with JavaScript -

i want serve different javascript files depending on if browser supports css3 transition or not. there better way detect transition support code below? window.onload = function () { var b = document.body.style; if(b.moztransition=='' || b.webkittransition=='' || b.otransition=='' || b.transition=='') { alert('supported'); } else { alert('not supported') } } modernizr detect you. use this link create custom download build contains css3 2d and/or 3d transitions. once it's run, can either test csstransitions class on html tag (css), or in javascript, test if modernizr.csstransitions true . more docs: http://modernizr.com/docs/#csstransitions

reconstituting a class full of data from MySQL BLOB object in python -

i'm using cherrypy , seems not behave nicely when comes retrieving data stored files on server. (i asked on , nobody replied, i'm on plan b, or c...) have stored class containing bunch of data structures (3 dictionaries , 2 lists of lists related) in mysql table, , amazingly, easier thought insert binary object (longblob). turned pickle file , inserted it. however, can't figure out how reconstitute pickle , rebuild class full of data now. database returns giant string looks pickle, how make string file-like object pickle.load(data) work? alternative solutions: how save class blob in database, or ideas on why can save pickle of class when go load later, class seems lost. in ssh / locally, works - when calling pickle.load(xxx) cherrypy errors. i'm plan d - if there's better way store collection of structured data fast retrieval without pickles or mysql blobs... you can create file-like in-memory object (c)stringio : >>> cstringio import s...

.htaccess - Codeigniter site replicated in subdirectory not displaying individual pages -

we have copied codeigniter website (from our root domain) subdirectory on same root domain (with config.php changes made , new database etc.). however, page links don't display individual pages yet browser reloads index.php page content (as if it's loading new page) , changes url in browser window correct page. this odd , i've spent hours pouring on it, i'm hoping here may able give me starting search point. for information, .htaccess in subdirectory is: rewriteengine on rewriterule ^test.php$ mod_rewrite.php rewritecond $1 !^(index\.php|resources|robots\.txt) rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l,qsa] if theres new codeigniter install in subdirectory used on root, need include name of sub directory in front of index.php parts of htaccess something this(the change on last line): rewriteengine on rewriterule ^$ /dev/index.php [l] rewritecond $1 !^(index\.php|images|css|js|...

redirect - error validations not showing in rails -

i have hit wall in displaying error messages. error validation messages don't show up. on users show template: <%= form_for([current_user, @pub_message]) |f| %> <%= render 'shared/error_messages', object: f.object %> <%= f.hidden_field :to_id, :value => @user.id %> <div class="micropost_message_field"> <%= f.text_area :content, placeholder: "any thoughts? questions? comments?", :id => 'public_message_text' %> </div> <%= f.submit "post", class: "btn btn-large btn-primary" %> <% end %> which goes pub_messages#create def create @pub_message = current_user.pub_messages.build @pub_message.to_id = params[:pub_message][:to_id] @pub_message.user_id = current_user.id @pub_message.content = params[:pub_message][:content] if @pub_message.save flash[:success ] = "your post has been sent" unless params[:pub_messa...

Is it good practice to create folder at root in SVN -

is practice create folders projects @ root in svn? or should folders created in trunk ? for instance, following setup alright? svn://servername/myproject or should be... svn://servername/trunk/myproject i understand both above options work looking best practice advice. thanks. if want follow convention, should put in trunk. won't cause problems svn if otherwise, trunk, branches , tags have meaning. if want read more along best practices, check this site out.

ASP.NET MVC3 simple commenting system --- displaying the comments -

trying add commenting system pages. able scaffold list view for comments on each page. i thought use scaffold code , place partialview changing return value partialview(db.comments.tolist()); , viewresult actionresult . it breaks @ @for (item in model) {....} null reference exception error . so...any idea on how this? ex: commenting system anywhere. @model ienumerable<_2nditeration.models.comment> @{ viewbag.title = "messages"; } <h2>messages</h2> <p> @html.actionlink("create new", "create") </p> <table> <tr> <th> uname </th> <th> email </th> <th> subject </th> <th> referrer </th> <th> created </th> <th> comment </th> <th></th...

assembly - HLA Hello, World - Assembler Error -

i've started going through randall hyde's "the art of assembly" start whetting palate. downloaded , installed hla 1.38 (which need 64-bit support) here , , wrote hello, world program described in both documentation listed there , in book above. program helloworld; #include ("stdlib.hhf"); begin helloworld; stdout.put("hello, world!", nl); end helloworld; when run hla helloworld.hla , following error message: helloworld.asm:66: error: ambiguous operand size or operands invalid 'push' the assembly line in question reads: pushd 0 ;/* no dynamic link. */ as green can assembly language, have no idea how make work. i'm assuming there's discrepancy between version of gas , hla 1.38. question remains: now? edit: tried compiling 'program', 'begin', , 'end' directives (removing possibility of being stdlib), , same result program nothing. i on 64-bit crunchbang linux. if want lea...

Creating a namespace-like organization in a google apps script library -

i looking building toolset using google apps script. problem far can tell in allows 1 level of organization. can create library called stopwatch , call methods stopwatch.start() , stopwatch.stop() pretty cool. what had in mind though more utils.stopwatch().start() , utils.timer.start() etc. think it's possible in javascript, in order keep breaking apps script autocomplete function needs added in format. below example example of doing wrong (gives error) perhaps saves time. it's based on this article. /** * stopwatch object. * @return {object} stopwatch methods */ function stopwatch() { var current; /** * stop stopwatch. * @param {time} time in miliseconds */ function timeinseconds_(time) { return time/1000; } return { /** * start stopwatch. */ start: function() { var time = new date().gettime(); current = timeinseconds_(time); }, /** * stop stopwatch. * @return {decima...

comparison - How to compare two ISO standard fingerprint templates? -

i have found digital persona finger fx open source project allows me supply finger print images (bitmap) , saves fingerprint minutiae data in iso/iec 19794-2:2005 format. https://github.com/fingerjetfxose/fingerjetfxose.git how compare 2 such iso/iec 19794-2:2005 templates? can suggest sample source code or article? sourceafis has partial implementation of iso/iec 19794-2 , comes examples in .net , java (experimental).

css - Absolute positioning not working Safari Mobile -

the search section in site www.anahatainternational.org displays correctly across ff, chrome, , safari. in safari mobile displays in middle of page. #search_section { position: absolute; right: 490px; top: 10px; z-index: 5; } thanks. i suggest making few changes layout of page make #search_section relative header. i have create skeletal structure it. http://jsfiddle.net/aacuy/ also remove left, top , position:absolute properties. there many classes in site me make changes using firebug , show result.

multithreading - Threading in c# to build a distributed DFS -

Image
i have been trying implement distributed depth first search in c#. have beem successful upto point have got synchronisation error. not able rectify error. trying make each node communicate 1 other using task parallel dataflow , thereby attain parallelism in dfs. below code: public class dfs { static list<string> traversedlist = new list<string>(); static list<string> parentlist = new list<string>(); static thread[] thread_array; static bufferblock<object> buffer1 = new bufferblock<object>(); public static void main(string[] args) { int n = 100; int m = n * 4; int p = n * 16; stopwatch stopwatch = new stopwatch(); stopwatch.start(); list<string> global_list = new list<string>(); streamreader file = new streamreader(args[args.length - 2]); string text = file.readtoend(); string[] lines = text.split('\n'); string[][] array1 = new string[lines.length][]; (int = 0; < li...