Posts

Showing posts from January, 2010

Using the Eco template engine with Rails -

eco embedded coffeescript templating language. resembles erb. there way can use server-side templating language in rails app? the ultimate goal use partials written in eco on both client , server. i noticed rails 3.1 support this. sam stephenson published ruby-eco , hooked sprockets use it. means using .eco in view templates work. link commit

regex - Remove anchor, but not arguments, via JavaScript -

i want change following example url http://www.mydomain.net/site?argument1=test1&argument2=test2#anchor to http://www.mydomain.net/site?argument1=test1&argument2=test2 with javascript. how best that? edit: 'anchor' , other text elements, meant generic elements. anchor text. sorry. if you're trying change current location's anchor, it's better change window.location.hash : window.location.hash = ''; in browsers avoid reload of page url changes.

No actions available for my custom Drupal trigger -

i writing drupal module (filemaker) , defined custom triggers. triggers show fine, 'no available actions trigger.' @ admin/build/trigger/filemaker. any idea how make actions available trigger? thanks in advance. /** * implementation of hook_hook_info(). */ function filemaker_hook_info() { return array( 'filemaker' => array( 'filemaker' => array( 'create' => array( 'runs when' => t('after creating filemaker record'), ), 'update' => array( 'runs when' => t('after updating filemaker record'), ), ), ), ); } /** * implementation of hook_filemaker(). */ function filemaker_filemaker($op, $node) { $aids = _trigger_get_hook_aids('filemaker', $op); $context = array( 'hook' => 'filemaker', 'op' => $op, 'node' => $node, ); actions_do(array_keys($aids),...

SVG to HTML/CSS -

well have svg file named 7.svg . how can display image html or css in index.html ? well can in 3 different ways. using <embed> tag <embed src="7.svg" width="300" height="100" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" /> using <object> tag <object data="7.svg" width="300" height="100" type="image/svg+xml" codebase="http://www.adobe.com/svg/viewer/install/" /> using <iframe> tag <iframe src="7.svg" width="300" height="100"> </iframe> tell me 1 works out you. please run on differnt browsers , let me know. html 5 info: since using html 5 wanna check out this: http://www.whatwg.org/specs/web-apps/current-work/#svg still under work , partially implemented in firefox, safari, opera (xhtml5 serialization only) https://developer.mozilla.org/en/svg_in_htm...

c# - public variable not accessible -

in 1 namespace (ventosa.graphics) have public class named model namespace ventosa.graphics { public class model : graphicsresource { public model(...) { ... } ... } } then in project try access class model player = new model(...); but line creates error. c# recognizes model exists, claims isn't accessible due it's protection level. shouldn't making public mean it's accessible everywhere? and yes, base class graphicsresource public. this happens in few other places in project too, classes derived. edit: exact error message (in german): der zugriff auf "ventosa.graphics.model" ist aufgrund der sicherheitsebene nicht möglich. translated english, says: "ventosa.graphics.model" inaccessible due protection level. you describe should not be. i'd suggest try reproduce problem in simplest way possible. won't able to. add sample, making more , more production code, until trigge...

asp.net mvc 3 - client validation using jQuery validate for currency fields -

i have problem using jquery.validate on asp.net mvc 3 app. at least in spain use "," split number decimals. ok, using server side validation, if put like: 12.55 when server validate it, says value not valid. if put: 12,55 works. so far good, if use jquery validate, says 12,55 invalid , 12.55 valid one. so, client pass validation server not, or client doesnt pass server would. so... can change locale kind of validation? thank you. ps : how server knows want validate using "," , not "."? don't remember if specified somewhere. probably should include localization files: http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/localization/messages_es.js http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/localization/methods_de.js in germany 1 uses same rules numbers, can use methods_de.js or include jquery.extend(jquery.validator.methods, { number: function(value, element) { return this.optional(element) || ...

"cannot find symbol method add(java.util.Date)" -

i'm getting error "cannot find symbol method add(java.util.date)", although i'm passing declared date. missing? import java.util.*; import java.text.simpledateformat; import java.text.*; class entry { date date; entry(date adate) { date = adate; } } public class td { public static void main(string[] args) { list<entry> entries = new arraylist<entry>(); dateformat df = new simpledateformat("yyyy-mm-dd"); date adate = df.parse("2011-02-27"); // date adate = new date() fails entries.add(adate); system.out.println(entries.get(0)); } } are sure want not entries.add(new entry(adate)); ? seems purpose of entry class. and speaking, if declare list list<entry> , should store entry instances in it, not date . also, error says "cannot find symbol method add(java.util.date) " . so, it's not date class that's missing. it'...

actionscript 3 - Alternative for getDefinitionByName -

in past, there simple trick , include flex mxmlc module adding following line flash-cs4 makefile: -include-libraries “/absolute/path/to/my/assets/assets.swc” this gave ability use getdefinitionbyname , helper function access embedded swc asset-library (instead of creating hand-written classes assets). unfortunately, has stopped working since flash-cs4 . know solution? unfortunately, workaround have found explicitly refer each of asset classes somewhere in code. may create dummy class this: public class assetsexporter extends sprite { public static function export() { assetclass1; assetclass2; //etc trace( "debug assetsexporter.export()" ); } } specify class document class in flash ide, compiled resulting swc. in main code of application call assetsexporter.export(); after doing able use getdefinitionbyname().

gzip - How to read from zipped xml files in Scala code? -

how access xml data files directly zipped file in scala program? there direct ways programmatically unzip , read contents in scala code? here couple of ways of doing in 2.8.1: cat > root.xml << eof <root> <id>123</id> </root> eof zip root root.xml and in repl: val rootzip = new java.util.zip.zipfile("root.zip") import collection.javaconverters._ val entries = rootzip.entries.asscala entries foreach { e => val x = scala.xml.xml.load(rootzip.getinputstream(e)) println(x) } or like: val rootzip = new java.util.zip.zipfile("root.zip") import scala.collection.javaconversions._ rootzip.entries. filter (_.getname.endswith(".xml")). foreach { e => println(scala.xml.xml.load(rootzip.getinputstream(e))) }

ipad - objective-c super rich text field for a notebook application -

i trying create new ipad application notebook. want allow user edit font, size, color, bold italic or underline separate word in field, or edit of letters in word. is there easy way it? or should go hard way , every word style changed should go in invisible uitextfield ? please me, need school. thank you! elad. you want learn core text api's maybe of source html -> core text control discussed @ http://www.cocoanetics.com/2011/01/rich-text-editing-on-ios/ might of assistance. there session on core text in wwdc 2010 videos.

c# - Control.DataBindings.Add breaks with period in data member name -

i trying add binding using control.databindings.add(). issue having data member name has period , space in it("foo. bar"). when try add binding pass in string "foo. bar" 1 of arguments , exception "cannot find datamember "foo.". is there syntax need use pass datamember name in when has period in it? tried adding "[]" around name no dice. thanks in advance. after digging around find solution problem discovered if make datasource collection (even of 1 item) .net 4.0 implmentation work.... arraylist list = new arraylist(); list.add(mydatasource); binding binding = new binding(propertyname, list, "dotted.path.name"); control.databindings.add(binding); hope helps....

c# - Unity Game Engine Tutorial? -

my game 2d rts, , wondering if knew of tutorial unity, or if well-versed in syntax of tell me have done wrong. so, have camera object, , player object, both tagged. player object has sprite on it, , set rigidbody. script goes follows: using unityengine; using system.collections; public class aisciript : monobehaviour { private bool thisisplayer = true; private gameobject objplayer; private gameobject objcamera; //input variables (variables used process , handle input) private vector3 inputrotation; private vector3 inputmovement; //identity variables (variables specific game object) public float movespeed = 100f; // calculation variables (variables used calculation) private vector3 tempvector; private vector3 tempvector2; // use initialization void start() { objplayer = (gameobject)gameobject.findwithtag("player"); objcamera = (gameobject)gameobject.findwithtag("maincamera"); if (gameobject.tag == "player") { thisisplaye...

java - How do you get the last character of a string? -

i've being trying last character of string nothing works except charat(strlength - 1) . need declare static variable , convert array one. lone story short it's not working me reason: /** * note java console applications need run through java runtime * running "java -jar jarfile.jar" in command line. * java console applications can not previewed in compilr ide, applets can. */ public class ispalindrome { public static boolean status = true; static string word; static int strlength = word.length(); public void setword(string word) { ispalindrome.word = word; } public string[] getword() { string[] word = new string[] {"nothign", "super"}; return word; } /** * main entry point application * @return */ public static void main(string[] args) { if (status == false ) { system.out.println("you didn't entered palindrome...

iphone - Cocos2d CCSpirte runAction problems -

i using cocos2d , have loop create bunch of sprites, , running action on every sprite in forloop, when run simulator cant see action ..some1 please me ccaction * action = [ccsequence actions:[ccfadein actionwithduration:2],nil]; for(nsinteger lp = 0;lp<49;lp++) { float sizer = [[numberofelement objectatindex:lp]floatvalue]; ccsprite *_bar = [ccsprite spritewithfile:colorofbar rect: (cgrectmake(10,20,5,sizer*30))]; _bar.position = ccp(5+9.5*lp,((sizer*30)/2)+25); [self addchild:_bar z:1]; [_bar runaction:action]; } you need create action instance each node. for(nsinteger lp = 0;lp<49;lp++) { float sizer = [[numberofelement objectatindex:lp]floatvalue]; ccsprite *_bar = [ccsprite spritewithfile:colorofbar rect:(cgrectmake(10,20,5,sizer*30))]; _bar.position = ccp(5+9.5*lp,((sizer*30)/2)+25); [self addchild:_bar z:1]; ccaction * action = [ccsequence actions:...

SQL Server Foreign Keys across database boundaries - techniques for enforcement -

i have 2 separate sql server 2005 databases (on same server) security database main application database the security database has user table needed authenticate. - the application database has person table extended user details. there 1-1 mapping between security database user table , application database person table. i want enforce mapping between user , person table. i'm assuming foreign keys can't mapped across databases wondering enforce integrity of relationship. cross database foreign keys indeed not supported msg 1763, level 16, state 0, line 2 cross-database foreign key references not supported. if want enforce referential integrity on database side have rely on triggers. (which don't recommend) to make code more maintainable create synonyms tables want check referential integrity on. create synonym mytable otherdatabase.dbo.mytable; this make "manual" checks easier, can not create foreign keys on synony...

.net - Add reference to VS 6.0 C++ help! -

i cs student in intern. supervisor busy , said use site if have questions. i need modify vs6.0 c++ program. have made c# class library comvisible. in visual basic 6.0 recongnizes type library , works how supposed to. made visual basic 6.0 test type library, need implement class library vs6.0 c++ program. i need on following: how add type library (tlb) or dll reference or reference method vs6.0c++ (i can't find article on how add it) tlb easy add in visual basic 6.0 translate simple code c++ uses comvisible library. have local variable: public ls new pcbcomvisiblelibrary also have in method: dim work boolean work = ls.post(text1.text, text2.text) label1.caption = work here can find several ways that: http://www.codeproject.com/kb/dll/loadingdll.aspx . know posting link not nice, in case article on codeproject explains want , there's little more say. i think problem falls case1 of article.

In GWT, how do I control how a widget is decorated to show it's got the focus? -

in general terms, how control in gwt decoration gets put on widget, e.g. textbox, show it's widget that's focussed? google chrome example illuminates focussed widgets sort of orange border round corners, it's not same border can control border instruction in css. (border: 3px black inset or whatever). specifically, i've got html widget wrapped in focuspanel. want focuspanel respond keypresses, does, want invisibly, without orange border mentioned in google chrome when focuspanel.setfocus(true);. thanks! neil you can remove red border setting css outline 0 . see: how remove focus on disclosure panel's header ?

asp.net - Impersonation with .net v4 -

i have .net v4 web app uses impersonation our web server , database server on separate physical servers. when attempt run application receive server error not load file or assembly '######' or 1 of dependencies. access denied. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.io.fileloadexception: not load file or assembly '######' or 1 of dependencies. access denied. looking @ stack trace seems application doesn't have access to c:/windows/microsoft.net/framework/v4.0.30319/temporary asp.net if grant impersonation user permissions on folder application works fine. if compile application down 3.5, uses .net 2 runtime , don't have give impersonation user permissions on folder "temporary asp.net" in .net 2 framework folder. so question why have give permissions on folder .net v4, less works fine? ...

css - print stylesheets - how to print all pages of paginated content? -

i'd use css specify stylesheet printing (instead of "print friendly view"). problem web site has long article content paginated. when printing paginated article using css, current single page gets printed instead of whole article. is there way control printing when user prints "all pages" view printed instead of single page? sometimes need create custom output, printing. same stylesheet, content on 1 go instead of paginated. i put parameter "printmode=1" or something, load content hidden iframe on same page , print in there.

actionscript 3 - Why do we not have splice in array collection? -

from know whole idea behind having collection classes introduce wrapper methods handy developers. then why arraycollection in flex not seem have methods array has. arraycollection not have copy, concat, join or splice methods return new array need copy manually? or missing in here? thanks. you're right, methods not there. there no published reason decision, can find. if had guess, , wild guess, business side of things prevailed when adobe made call. it's impossible guess of dozen of factors - examples include not having enough developers flesh out each data structure, or not enough time before last release, or not enough pressure clients kind of work, or not enough testing/support/maintenance resources.

Strip new lines in PHP -

i've been working phrases past couple of days , problem seem facing stripping new lines in html before printing it. anybody have idea how remove every new lines html using php? str_replace(array("\r", "\n"), '', $string)

c# - Sharepoint Web Part restrict to zone -

is there way restrict web part zone? know can restrict using allowzonechange flag, possible make sure web part can added zones? have web parts viable in wide column (zones), want make sure no 1 tries add web parts narrow columns (zones). there way of accomplishing this? if stick in quick add group same name "wide" one, it'll show @ top of list default when tries add web part in zone. however, show normal further odwn list when tries add zone. however, don't think it's possible @ - only method can think of, off top of head (somehow, maybe through modifyin page layout directly) add code event handler spwebpartmanager.webpartadded check webpart , zone, , remove if added in wrong zone. however, i've never tried this, nor know if work - feel free give try though. blog if work! have @ info on event itself. http://msdn.microsoft.com/en-us/library/ms157584

html - Make element move by using Javascript -

i trying make webpage when click link, link moves diagonally every 100 milliseconds. so have javascript, right when click link nothing happens also, know of javascript ide can use make sure have no errors in code? ps: know why elements dont stretch fit whole 200px 200px of div element? links small when should same width parent div element. edited new advice, although still wont move. <script language="javascript" type = "text/javascript"> <!-- var block = null; var clockstep = null; var index = 0; var maxindex = 6; var x = 0; var y = 0; var timerinterval = 100; // milliseconds var xpos = null; var ypos = null; function moveblock() { if ( index < 0 || index >= maxindex || block == null || clockstep == null ) { clearinterval( clockstep ); return; } block.style.left = xp...

testing - Where are the Assertion Methods list from Django TestCase? -

i googled find assert methods list. seems documentation hidden. know is? it uses standard python unittest, http://docs.python.org/library/unittest.html#assert-methods , extended django-specific asserts can found here .

wolfram mathematica - Passing parameters stored in a list to expression -

how can pass values given expression several variables? values these variables placed in list needs passed expression. your revised question straightforward, simply f @@ {a,b,c,...} == f[a,b,c,...] where @@ shorthand apply . internally, {a,b,c} list[a,b,c] (which can see using fullform on expression), , apply replaces head , list , new head , f , changing function. operation of apply not limited lists, in general f @@ g[a,b] == f[a,b] also, @ sequence does f[sequence[a,b]] == f[a,b] so, instead f[ sequence @@ {a,b}] == f[a,b] which while pedantic seeming can useful. edit : apply has optional 2 nd argument specifies level, i.e. apply[f, {{a,b},{c,d}}, {1}] == {f[a,b], f[c,d]} note: shorthand apply[fcn, expr,{1}] @@@ , discussed here , specify other level description need use full function form.

c++ - expected duration between kill and the ability to reap with waitpid -

i have linux app must spawn child process on request 1 of exec() functions. if child process has not finished before it's time spawn again, app must kill previous instance before starting new one. with kill(pid, sigterm); i'm keeping pid of previous instance , using waitpid(pid, &status, wnohang) to reap process. it seems there's extremely long time window (possibly hundreds of milliseconds) between issuing kill call , being able reap process waitpid. what cause this? thought unless child process set signal hander (this 1 doesn't) killed virtually immediately. on 200mhz arm9 still ... seems odd me. the process may catch sigterm in order perform own cleanup before shutting down. even if doesn't, don't know how long it'll take os shut down process. trying rely on things fool's errand.

SQL Server date function -

i need week number of giving date. ex jan 1 = week no 1, jan 8 - week 2 this.. 1 me out pls. you should try this: declare @dt datetime select @dt='02-21-2008' select datepart( wk, @dt) this should return weeknumbers want. sql server starts counting 1st of january. if want return iso weeknumbers, need bit more scripting. nice howto listed in site: http://www.rmjcs.com/sqlserver/tsqlfunctions/isoweeknumber/tabid/207/default.aspx msdn : datepart (transact-sql) in response robin's comment: but need in such way, jan 1 7, should return 1, jan 8 17 should return 2 this.. hope u got impression in case write this. select (datepart(dy, '2011-01-01') / 7) + 1 --returns 1 select (datepart(dy, '2011-01-02') / 7) + 1 --returns 1 select (datepart(dy, '2011-12-31') / 7) + 1 --returns 53 i don't know how sql server 2008 responds iso_week , wk parameter got sql 2005 instance available @ moment.

ruby on rails - how to only :include based on a conditional statement -

i'm trying grab posts , comments belong_to post based on conditional: ie. # grab posts include comments have been approved. post.all(:include => :comments, :conditions => ['comments.approved = ?', true]) update july 20, 2011 10:11 est to clarify, i'm trying grab posts , comments of post specific user. def grab_posts_and_only_comments_from(user) {:include => [:comments], :conditions => ['comments.user_id = ?', user.id]} end updated july 20, 2011 11:34 est answer in comment of checked answer. post.includes(:comments).where("comments.approved = ?", true) the documentation on feature improved in edgeguides. check out section 12.2 here .

WPF: How do I know if Binding RelativeSource found an ancestor -

i'm using binding relativesource findancestor mode binding not working. how debug , see if able find ancestor? use snoop edit: can of course use usual debugging mechanisms , snoop best. can navigate control , if binding failed tells so

javascript - find Absolute path of "Desktop" location using PHP -

how absolute path of "desktop" location using php? in php? no means, php serverside. you'll have use javascript, don't think allowed access file system javascript, no dice there either.

events - Javascript receive onmousedown of a disabled select tag -

i have form 2 radiobuttons: [radio1] [radio2] [select] <input type="radio" id="radio1" name="radio" checked/> <br/> <input type="radio" id="radio2" name="radio"/> <select id="select" onmousedown="test()" disabled="disabled"> <option>aaa</option> <option>bbb</option> </select> the desired behaviour when radio1 ticked, selectbox disabled. when radio2 ticked, user able select selectbox (hence enabled). i have necessary event code in radio1 , radio2 handle enabled/disabling selectbox, , works nicely. however, wanted additional behaviour: click selectbox, radio2 should ticked , selectbox enabled: function test(){ document.getelementbyid('radio1').checked=false; document.getelementbyid('radio2').checked=true; document.getelementbyid('select').disabled=false; } however, test() never gets ...

problem with php and mysql -

i trying connect db not on same server script. it doesn't work, why? mysql_connect('twstg.com', 'myuser', 'mypass'); $data = mysql_query("select * websites order rand() limit 1"); while($info = mysql_fetch_array( $data)) { $url = $info['url']; echo $url; } (this big comment, update answer appropriate when more data provided) what's error you're getting, can't expect magically know that. there many things go wrong, whether it's in connection, query, or loop (if there no results). you can check error doing this: mysql_connect(..) or die(mysql_error()); $data = mysql_query(); die(mysql_error()); if there no errors that, you're still missing call mysql_select_db() . wouldn't required if, example, doing select * database.websites , you're not :)

asp.net - Maximum Request Length Exceeded Not Redirect on Error Page -

i followed these links: catching "maximum request length exceeded" and asp.net - how show error page when uploading big file (maximum request length exceeded)? to display error page handle uploading files exceeding maxrequestlength in web.config but problem is, not redirected error page (the message says webpage cannot displayed ). not know i'm missing. here's code @ global.asax : void application_error(object sender, eventargs e) { if (ismaxrequestlengthexceeded(server.getlasterror())) { this.server.clearerror(); this.server.transfer("~/error.html"); } } private bool ismaxrequestlengthexceeded(exception ex) { exception main; httpunhandledexception unhandledex = (httpunhandledexception)ex; if (unhandledex != null && unhandledex.errorcode == -2147467259) { main = unhandledex.innerexception; } else { main = unhandledex; } httpexception httpexce...

java background transparent -

i have gif image wich contains colored shape, , transparent background i replace shape's color 1 want (the color palet gif 2 colors : transparent , white in case). i've created filter wich correctly replace white red (this test) however i'm encountering issue method imagetobufferedimage, removes transparency , replace black (don't know why). so i've done far : import java.awt.color; import java.awt.graphics2d; import java.awt.image; import java.awt.toolkit; import java.awt.image.bufferedimage; import java.awt.image.filteredimagesource; import java.awt.image.imagefilter; import java.awt.image.imageproducer; import java.awt.image.rgbimagefilter; import java.io.file; import javax.imageio.imageio; public class testpng { public static void main(string[] args) throws exception { file in = new file("bg.gif"); bufferedimage source = imageio.read(in); int color = source.getrgb(0, 0); image image = makecolortrans...

delphi - Get progress value and status of a MSI installation -

i creating delphi application execute msi silent installation . want progress value of msi , installation status , show on delphi applcation and want close msi if button in delphi application clicked. i using delphi application because no installation software gives facilities want to progress value, must use msisetexternalui function part of windows installer api , parse installmessage_progress string, can read more info here parsing windows installer messages . jedi-apilib has translation of headers of api in jwamsi unit.

java - Create array of regex match(multiline) -

i want create array of regex match string text bellow. .title1 content of title1. content of title1. ..title2 content of title2 content of title2 and desired array below array[0] = ".title1 content of title1. content of title1." array[1] = "..title2 content of title2 content of title2" and bellow code. arraylist<string> array = new arraylist<string>(); pattern p = pattern.compile("^\.[\w|\w]+^\.", pattern.multiline); matcher m = p.matcher(textabove); if(m.matches()){ m.reset(); while(m.find()){ array.add(m.group()); } } but code, array[0] contains ".title1" "." before ".title2", , couldn't array[1] since m.find() doesn't match, , when use ^\.[\w|\w]+ instead of regex pattern above, array[0] contains everything. how can acheive array? don't stick regex, solution welcome. you're pretty close - try regex instead: ^\..*?(?=(^\.|\z)) in java, be" "^\\...

javascript - Get first h1 heading and open \\<server_name>\h1.html in new tab -

i 2 tabs following code - 1 says [object window] , other displays page want. what rid of first useless tab? is there way bookmarklet open http:///getting_started_txt_(random_alphanumeric_code_here).html ?. ...i need open page matches h1 part of offline file name file name begins , gibberish. the offline files @ end "getting_started_txt_23468j5jg86458jm34858.html". bookmarklet must file filename begins "h1 underscores" , after it. possible? window.open('http://en.wikipedia.org/wiki/' + document.getelementsbytagname('h1')[0].innerhtml.replace(/<[^>]+>/g, '').replace(/ /g, '_') + '_txt_'); so if have page open first heading h1 "getting started", bookmarklet should open new tab url http://(server_name)/getting_started_txt_(random_alphanumeric_code_here).html . note there 1 file on server matches getting_started_txt part , rest of file name can anything. something shou...

unix - Conditional creation of file from existing files -

i have requirement here: shell script having multiple files process , suppose if having data file in following format: h:asdsa_20110221010224_0018020110221010224asdfdgda qweeret 11594 1 xxct5 500 1 11594 1 xxct5 500 1 t:2 or 11594 1 xxct5 500 1 11594 1 xxct5 500 1 i need create new file out of above data files based on following condition: a. if data file having first line starting h: , last line ending t:, new file should be(without row starting h: , t): 1 1594 1 xxct5 500 1 ...

rounding - How to round up a number in Javascript? -

i want use javascript round number. since number currency, want round in these examples (2 decimal points): 192.168 => 192.20 192.11 => 192.20 192.21 => 192.30 192.26 => 192.30 192.20 => 192.20 how achieve using javascript? built-in javascript function round number based on standard logic (less , more 5 round up). // precision 10 10ths, 100 100ths, etc. function roundup(num, precision) { return math.ceil(num * precision) / precision } roundup(192.168, 10) //=> 192.2

jquery - Vertical animation on menu -

i'm making dropdown menu , it's working slideup/slidedown functions jquery api. - if want vertical animation instead can't find functions in api that. can enlighten me :)? possible? html <ul> <li><a href="">hvem</a></li> <li><a href="">hvad</a> <ul> <li class="first-item"><a href="">produkter</a></li> <li><a href="">leveringer</a></li> </ul> </li> <li><a href="">hvordan</a> <ul> <li class="first-item"><a href="">reklame</a></li> <li><a href="">pr</a></li> <...

java - Android custom view layout issues -

short , sweet summary: when changing class view -derived viewgroup -derived, height and/or width params passed onsizechanged not consistent class when used inside of linearlayout. there additional information need supply when using viewgroup super class achieve consistent results? long version: i have created custom view-derived visual control i'm using custom button. derive view , add layouts this: class declaration: public class gamebutton extends view { xml: <linearlayout android:layout_width="fill_parent" android:layout_height="0dip" android:orientation="horizontal" android:layout_weight="1"> <com.myname.myapp.controls.gamebutton android:id="@+id/button1" android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1" /> i want little fancier contro...

some questions in load jquery.ajax -

function contentdisp() { $.ajax({ url : "a2.php", success : function (data) { $("#contentarea").html(data); } }); } <input type="button" value="click" onclick="contentdisp();">&nbsp;<span style="color:blue;"> <textarea id="contentarea" rows="10" cols="50"></textarea> i'm new learning jquery.ajax now. found tutorial on web. these code control jquery.ajax when click button, load content a2.php div#contentarea . have questions: whether js code can add jquery(document).ready(function() if want open page, load html(data) @ onece, not click callback? whether jquery.ajax can load div's content form a2.php , not whole page? similar jquery.load $("#contentarea").load("a2.php #content"); . thanks. if put ajax call in document ready run , load content immediately. how default tab on jquery tabs works. ...

sql server 2005 - Reducing text in a text field -

i'm working on view selects large text field table. (no, not snapshots.) table contains errorlog web application provides access it. however, errorlog contains long texts cause column extremely wide. want select text field, any word longer 20 characters must replaced first three, ellipse (...) , last 3 letters. example: - system.web.httpexception: client disconnected. ---> system.web.ui.viewstateexception: invalid viewstate. client ip: xxx.xxx.xxx.xxx port: xxxx user-agent: mozilla/4.0 (compatible; msie 7.0; windows nt 6.1; wow64; trident/4.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; infopath.3; .net4.0c; .net4.0e) viewstate: t89rigytoaletokughad85kzodro/ut3vlnd1qecsyf1t9ggnildrvbrn8l45svx8aszrs6zyengk8mkdporeci4j0x5ismi0deldf4nlknlloe4xaoomulj7htfrxavqyofsvzsvyhwpwclug26rjt4ybgr1ijygqwx9kvplidasdur0annmvd9fva8fi33ny7fuijxpkmpqkbykyjtagzu4piji88mmqwqdmnzmbxm965+bn+rsvtsxrgwzllhzfcrk0leccrzerqyncmmhupgm9yb1+uaprfeca...

javascript - jQuery toggle button opacity -

i trying toggle 2 buttons's opacity when user hovers on containing div, , when mouse out should go being hidden, @ moment doing try click on 1 of buttons, goes mad , starts toggling opacity on , off repeatedly, here code, javascript/jquery: $('#container').live({ mouseover: function() { $('.button').fadetoggle(); }, mouseout: function() { $('.button').fadetoggle(); } }); html: <div id="container"> <div class="button"></div> <div></div> <div class="button"></div> </div> thanx in advance! ps: sorry title, forgot change it, showing , hiding buttons fade effect , not toggling opacity. the mouseover , mouseout events bubble, meaning fire of element's children. you should handle mouseenter , mouseleave , not bubble.

c# - Chain of events / Proxy to original object -

i have class inherited context bound object. class has attribute on properties. when property changed, postprocess(imessage msg, imessage msgreturn) raise event , event again new property same attribute fired. second change should call postprocess , not happening. because, object second property changed not original .net object marshalbyrefobject / contextboundobject / proxy object . query how cast proxy original object. tried casting , synchonizationattribute , not help. let know events executing in async manner not block code execution, , both proxy , original object exist in same app domain. i tried 2 object, 1 holding reference of second, , when property of first changed, try change property of second, did not invoke postprocess . basically need make tree various objects depending on property of other objects. , when 1 property changed, should trigger watcher, , spread chain untill no watcher found. trying contextboundobject. sample: public class powerswitch : objectb...

jquery - swfObject causing "Object doesn't support" error in __flash__addCallback function -

so, have been stuck on problem time , has caused lot of frustration. have found lot of people on many forum pages have scoured share same problem no 1 has gave clear answer why error being thrown , how fix it. i using swfobject 2.2 embed background video onto page working on , ie7/ie8 throwing error: "object doesn't support property or method" due line 48 character 3. upon opening developer tools see code causing error, found this: function __flash__addcallback (instance, name) { instance[name] = function () { return eval(instance.callfunction("<invoke name=\""+name+"\" returntype=\"javascript\">" + __flash__argumentstoxml(arguments,0) + "</invoke>")); } } i tried finding going wrong in code , commented out besides: swfobject.embedswf('http://localhost/flash/player.swf', 'video_player', '100%', '100%', '9.0.0'); this element swfobject lo...

Starting to us ProjectLocker - new to SVN -

i have never used svn, familiar sm (source safe looong time ago). project web-based project hosted isp (hosting.com). group i'm working using dreamweaver, , found tutorial using svn, have i'm sure basic questions... 1) best way files isp projectlocker? (initial check in) 2) save file locally, upload (put) dw. need put projectlocker, separate put server? 3) can explain how can manage versioning? i know these wide open questions. if has m rtfm solution please advise. i'm trying in @ "for dummies" level "bible" resource can go later. pretty need in terms of dreamweaver svn functionality in adobe's using subversion dreamweaver tutorial. you'll need files isp down local path on machine before committing them svn. the process of committing source control independent of publishing web server. you'll (hopefully) commit subversion compared publishing hosting provider. you might find the 10 commandments of source control man...

Coverage by intersecting smaller genomic interval data over larger genomic intervals using R -

i want intersect 2 genomic intervals in r. , want coverage stats of smaller interval on larger interval. the larger interval data data frame .... chr start end name val strand chr7 145444998 146102295 ccds5889.1 0 + chr7 146102406 146167735 ccds5889.1 0 + chr7 146167929 146371931 ccds5889.1 0 + the smaller interval more 2 million rows . chr start end name val strand phylop chr7 145444386 145444387 ccds5889.1 0 + 0.684764 chr7 145444387 145444388 ccds5889.1 0 + 0.684764 chr7 145444388 145444389 ccds5889.1 0 + 0.684764 chr7 145444389 145444390 ccds5889.1 0 + 0.684764 the interval data in 2nd (from) , 3rd (to) columns in both data frame. the situation similar to large interval: [-----] [-----] [--------------] [-------------------] small interval: ||| |||| ||||||||||| |||||||| |||| || ||||||||| || |||||||| i want know how of each of...

Android Compatibility Package doesn't include Activity.getFragmentManager() -

i started trying add fragments android app, based on 2.1, using android compatibility package came out on march 3rd. included library project, , started moving code activity-based class fragment-based one, noticed fragment examples google seem rely on fact activity class in 3.0 (honeycomb) has new method getfragmentmanager(). seems integral hook fragment system. i've tried inside compatibility package library included activity implementation has getfragmentmanager(), can't find it. know can find getfragmentmanager() can include fragments honeycomb compatibility, or if not know how can include fragments without using fragmentmanager? you need extend fragmentactivity instead of normal activity . able call getsupportfragmentmanager() works same way getfragmentmanager() .

c# - WCF VS. Sockets -

i know of wcf or .net sockets more efficient , more recommended in game developpment scenario. here different parts of game : -a client/server communication play on internet -peer peer on local network. i know technology use on these parts (wcf on both, socket on both, wcf on 1 , socket on other...) , why, if possible. the game involved doesn't require high communication frequency (3-4 per second enough). the purpose of wcf save developers writing code different transport protocols , has large number of features thats why slower sockets. plus wcf service oriented applications. dont think games fall category. but mention 3-4 requests per second, wcf might better option flexible , save lot of development time. some points: the bindings start net* meant used between .net applications. (both client , server wcf) if of 1 not wcf: can use bindings not start net prefix. basichttpbinding, wshttpbinding etc. these slower net* bindings lot of overhead there. y...

c# - Directory.CreateDirectory from [TestMethod] behaves strangely -

i'm in dark on one... i've created batch processing code, , have several tests setup directory structure before calling method tested. problem can illustrated by [testmethod] public void stupidtest() { directory.createdirectory("./xxx"); assert.istrue(directory.exists("./xxx")); //new fileinfo( "./xxx/yyy.txt").create().close(); } when last line commented out, tests runs perfectly, in "out" folder of testresults, no folder created. when last line included, test runs well, , both xxx folder , yyy.txt file exist in "out" folder test run. if last line of test included in body, test fails, complaining non-existant path. i found references mentioning file system virtualization, , test app not having enough permissions create folders in "out" folder. any appreciated! can try , use processmonitor (from ms download site,free), , record of activities of process, , can...

phpmyadmin - What's wrong with this simple MySQL CREATE TABLE statement? -

it's simple create table statement i'm writing in phpmyadmin. ok, know easy way in phpmyadmin have full control. here's statement: create table profile ( id int not null auto_increment, primary key(id), type int(1) not null, view int(1) not null default '1', ver int(1) not null default '2', email not null varchar(32), password not null varchar(16), first varchar(32), last varchar(32), site varchar(64), address varchar(32), city varchar(32), zip int, state char(2), country varchar(50), text, datereg int(20) ) engine=myisam default charset=utf8; i replaced view int(1) not null default '1', ver int(1) not null default '2', email not null varchar(32), password not null varchar(16), with view int(1) not null default 1, ver int(1) not null default 2, email varchar(32) not null , password varchar(16) not null , and worked

ios4 - iPhone app uses 150 MB memory and still no low memory warning! -

i have questionary application, navigation based create , push tableviews eachtime nib. there no leakage , in instruments live bytes seems around 2-3 mb. i tested in real device (jailbroken ios4 iphone), when go through deep in navigation (around 200 page pushes) can see memory usage goes upto 150 mb! when navigate root freed, isnt weird behavior? (around 800 kb each nib view , no big data or images in it) the weird thing is, put alerts didreceivememorywarning , didunloadview methods, , yet didnt receive memory alerts! -why never memory warning , viewdidunload app uses 150 mb , more of memory? -application works memory usage problem apple store? something funky going on. try following code check os version of how memory app uses -(void) report_memory { struct task_basic_info info; mach_msg_type_number_t size = sizeof(info); kern_return_t kerr = task_info(mach_task_self(), task_basic_info, ...

ruby on rails 3 - module which generated a bad name for a method -

so have module have used name "log" 1 of internal methods. the problem is, module has "extend self" line. if call module in script load rails environment, everytime keyword "log" used (i.e rails.application.config.paths.log, or config.paths.log) method inside module getting invoked instead of original file looking for. is there way mymodule.module_eval , somehow rename method name , route local calls inside module called "log" new method? otherwise rails , module don't play nice together. any appreciated! found answer. privatized bad method inside module using module_eval nososmartmodule.module_eval private :log end

ios - UILabel not getting what I write to it -

tricky write subject this. guess basic question can't seem find answer. code shows wanna , uilabel don't show anything, first line add works fine, not when try write out array: -(ibaction)getsonghistory:(id)sender { [historylabel settext:@"test write\n test write line"]; nsarray *pastmusicarray = [pastsongs gethistory]; for(int t=2; t<[pastmusicarray count]; t++) { nsstring *temprow = [pastmusicarray objectatindex:t]; //nslog(@"%@", temprow); [historylabel settext:temprow]; [historylabel settext:@"\n"]; } } the nslog put out right stuff. gong on here, not seeing? seems me problem setting full text each time , last settext: @"\n" invisible string. try appending instead of setting text. like: historylabel.text = [nsstring stringwithformat:@"%@%@", historylabel.text,@"texttoappend"]; this append @"texttoappend" current text value in label. update: notice i'm using...

Android Text not fitting into the List -

i make simple list choice multiple selection option, using array of string. text of list item long , wrapped 2-5 lines. text not being fit list item boundary if exids more 2 rows. boundary of list item overlapping text . please let me know how adjust height of list item accoding lenght of text. thanks you need cut off text if long or wrap adjusting font? if need adjust font may following question, faced , answer written me in it... textview text shrink given width

JQuery fallback function for CSS3 placeholder -

the following function should ensure if device not have css3 abilities should set value instead. not work. there no value present in non css3 browsers. here fiddle. http://jsfiddle.net/x9zzp/2/ // search input placeholder $(document).ready(function(){ if(!modernizr.csstransitions) { $('#gensearch').val($('#gensearch').attr('plaeholder')); $('#gensearch').click(function() { $(this).val(''); }); $('#gensearch').blur(function() { if($(this).val() == '') { $(this).val($(this).attr('plaeholder')); } }); } }); any ideas, marvellous spelling mistake, thats annoying. sorry everybody. $(document).ready(function(){ if(!modernizr.csstransitions) { $('#gensearch').val($('#gensearch').attr('placeholder')); $('#gensearch').click(function() { $(this).val(''); }); $('#gensearch').blur(functi...

vb.net - How to do get a row from database in VB? -

hi want create application in vb. , have created forms, , in meantime want 1 form connect database(lets form name, db). have created , connected oracle. in form (db) want search oracle table id(which have been manually created me using sql commands). , if id matches user entered input, other details of id(say name, address) should appear in form! how this? idea, i'm newbie in vb, kindly me! if put code snippet :) please me how this? for introduction on connecting oracle db vb .net take @ tutorial . technique described in article simple , fast technique getting started, production applications recommend mapper such nhibernate . once have performed sql select statement against oracle db need copy data have read object pass ui layer: dim dr oracledatareader = cmd.executereader() ' vb.net dim userobject new user() dim name string = dr.read() dim address string dr.read() userobject.name = name userobject.address = address once have read required data memory use d...

Squirrel sql client session timeout -

it not related whatever version is, working find out how change (of course increase) session timeout value of squirrel sql client. because bored of getting kind of exception "last packet sent server .. ago" any appreciated. you can keep connection alive doing following: on aliases->modify selected alias (pencil icon)-> properties-> connection (tab) check enable keep-alive and enter simple query, in postgresql use select 1; , in oracle should select 1 dual;

python - Changing the type of a field in a collection in a mongodb database -

the type of field in collection in mongodb database unicode string. field not have data associated in of documents in collection. dont want type string because,i want add subfields python code using pymongo. the collection has many records in it.so, possible change type of field dictionary in python documents in collection ? please thank you i'm not sure mean "the type of field ... string" , "this field ... not have data". mean field exists in documents, set empty string or null ? in either case, mongodb "schemaless," means won't enforce particular schema on documents, not documents in collection have same structure. if using framework requires declare schema (mongoengine, mongokit, etc), you'll have make according changes in use of framework, , we'll need know framework you're using. if you're using pure pymongo, can change document see fit. suppose have document like: {name: "dcrosta", address: n...

Git submodules: can you make local, un-committed edits? -

i've got git submodule in project consists of set of configuration files, need tiny bit of tweaking on per-project basis. is possible submodules, or doing things wrong way here? don't want commit changes submodule's repository, they're project-specific. any tips or pointers appreciated. edit: note these local edits local project, , project needs retain these changes when gets deployed server (using git , fabric). it possible make local changes, it's not feasible. git notice submodule has changes, , show you. cannot commit changes submodule in supermodule, because changes not pushed somewhere. when tries checkout submodule, git complain, because can't find commit has recorded submodule. if it's per project , not per-machine difference, can create branch in submodule repository project specific changes made. these changes can commited submodule , pushed. you have decide if want these changes part of submodule repository, way can git. ...

Trying to write a sorting program with ruby - stack level too deep (system stack error) -

i'm reading chris pine's book "learn progam" (it's ruby). right i'm trying write program sorts words. unfortunately i'm stuck with: stack level deep (system stack error) in line 16 , which, if googled correctly means there infinite loop, don't know why. here's code: words = [] wordss = [] word = 'word' = 0 k = 0 def sortw array = 0 if (array.length == 1) || (array.length == 0) else sort array, [], [], end return array end def sort unsorted, unsort, sorted, k = 0 # error should here, according command prompt while < unsorted.length while (unsorted[i] < unsorted[k]) if k < unsorted.length k = k + 1 elsif k == unsorted.length sorted.push unsorted[i] else unsort.push unsorted[i] end end = + 1 sort unsorted, unsort, sorted, end if unsort.length != 1 = 0 sort unsort, [], sorted, else sorted.push unsort[0] end return sorted end pu...

c# - MVC3 Json function hide specific Properties -

is there way in mvc3 set properties json function outputs? ie. properties on model have attribute tells json function not output them. it looks scriptignoreattribute want. decorate whatever property don't want serialized it.

php - unable to connect mysql db with this code -

$hostname='example.com'; $username='someuser'; $password='password'; $dbname='adatabase'; $usertable='my_table'; mysql_connect($hostname,$username,$password); @mysql_select_db($dbname) or die( "unable select database"); i'm using read-only username here. when test script, error "unable select database". any clue? don't use fixed strings die() message...they're useless diagnosis. well, don't supress errors @ . mysql_connect($hostname,$username,$password) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); using you'll exact reason things failing.

c++ - Qt4: Making fullscreen window impossible to get around (a lock screen)? -

my application os lock screen (like gdm's lock screen or kde's), i'm trying make function one. i trying make application's window hover above all other windows , disable/intercept keyboard shortcuts ( alt-tab , ctrl-alt-d , etc.) cause disappear. is there way this? i'm 100% sure there is, lock screens guis exist, can't find place look... i don't know how qt, looking called grabbing . can grab pointer input device keyboard . edit: looking in qt4 docs, have tried use qwidget::grabmouse ? looks function want.

Silverlight Forms Authentication -

i have forms authentication in silverlight app working. checking if login successful. how user credentials user? logged in , ui? private void checkforlogin() { authentication.authenticationserviceclient proxy = new authentication.authenticationserviceclient(); proxy.isloggedincompleted += new eventhandler<authentication.isloggedincompletedeventargs>(proxy_isloggedincompleted); proxy.isloggedinasync(); } void proxy_isloggedincompleted(object sender, authentication.isloggedincompletedeventargs e) { if (e.result) { //get user credentials here: } else { var loginwindow = new loginwindow(); loginwindow.closed += new eventhandler(loginwindow_closed); loginwindow.show(); } } void loginwindow_closed(object sender, eventargs e) { loginwindow loginwindow = (loginwindow)sender; bool? result = loginwindow.dialogresult; if (result.hasvalue ...

sql - Return list of emp # NOT in a query, Access 2007 -

have table of list of problems people can have. these people id'd number. these people can have number of problems (usually 5-10). want list of people tobacco not appear problem them. solution going to make query of people have tobacco problems, , query query statement return numbers not in tobacco query. done? close? query list of people have tobacco problems select distinct person.personid tblkentuckycounties inner join (tblcomorbidity inner join (person inner join tblcomorbidityperson on person.personid = tblcomorbidityperson.personid) on tblcomorbidity.id = tblcomorbidityperson.comorbidityfk) on tblkentuckycounties.id = person.county ((not (tblcomorbidity.comorbidityexplanation)="tobacco")); query want return people not in first query select person.personid expr1, [tobacco query].personid [tobacco query] inner join person on [tobacco query].personid = person.personid; i not savvy on access sql dialect, want left join , not inner join . left...