Posts

Showing posts from March, 2010

r - Use RJDBC MySQL -

i read out not easy run rmysql package see here , here . rather found site , asked self if possible use jdbc mysql driver here rjdbc package? , how setup it.

jquery - How to fix Sqlitelog (13) statement aborts at 68 error in phonegap android -

i fetching data local server , storing data in local table before working fine know showing error in logcat checked fetching data server while storing data in local database creates error 08-28 08:34:25.111: e/sqlitelog(4172): (13) statement aborts @ 68: [insert crm_dynamic_form(rc_group_id,dynamic_form_id,module_id,table_id,table_name,field_name,listorder,display_name,element_type,dynamic,mandatory,list_show,rowpos,columnpos,tab_i 08-28 08:34:25.121: d/cordovalog(4172): calling quotaupdater.updatequota newquota: 0 08-28 08:34:25.131: d/cordovalog(4172): droidgap: onexceededdatabasequota estimatedsize: 0 currentquota: 200000 totalusedquota: 200000 08-28 08:34:25.131: d/cordovalog(4172): calling quotaupdater.updatequota newquota: 0 08-28 08:34:25.141: e/sqlitelog(4172): (1) statement aborts @ 2: [rollback] cannot rollback - no transaction active 08-28 08:34:25.401: w/trace(4172): unexpected value nativegetenabledtags: 0 08-28 08:34:25.411: w/trace(4172): unexpected value native...

java - getting exception with ITEXT at BaseFont.createFont -

i trying create font basefont base = basefont.createfont("/users/imac/library/desktop/thsarpsk.ttf",basefont.identity_h,basefont.embedded); font font = new font(base, 18f); but have problem path locating font . i'm working on android platform on mac pc, tried many solutions, unable solve. below 1 of solution path of font on windows basefont.createfont("c:\\winnt\\fonts\\comic.ttf", basefont.winansi, basefont.embedded); i try adapt mac sent me exception java.io.ioexception:\users\imac\library\desktop\thsarpsk.ttf not found file or resource. i trying solve problem many days, please me.

c# - Run process on remote PC -

hey guys just wondering how can run process/kill process on remote machine using c# , have found solutions using psexec didn't work. or give me access remote pc cmd thanks. could try wmi.net so thread

swing - Java JTextArea KeyListener -

when pressed enter jtextarea starts new row , want doclick() method nothing else. how should that? textarea.addkeylistener(new keylistener(){ @override public void keypressed(keyevent e){ if(e.getkeycode() == keyevent.vk_enter){ button.doclick(); } } @override public void keytyped(keyevent e) { } @override public void keyreleased(keyevent e) { } }); use .consume() : consumes event not processed in default manner source originated it. public void keypressed(keyevent e){ if(e.getkeycode() == keyevent.vk_enter){ e.consume(); button.doclick(); } } documentation

c++ - How to decide on what unit tests to create for a rules-based system -

i've been reading lot unit testing , considering using c++ , tdd first time. problem have of examples see in creating tests, appear trivial when think how begin writing tests project i'm develop. may i'm missing point of unit tests, please let me know if case here. it's easy understand function that, example checks prime numbers. has simple input (the number test) , simple output (true or false). easy understand , create unit test here. now, let's take, example, firewall application has configuration file of rules , evaluation engine evaluate rules in particular order, specific inputs; details of network packet such ip, subnet, port, domain etc. without writing unit tests, think start writing parser parse rules config file classes , write rules engine compare given network packets rules in classes, stepping through rules in order parsed until match found. unit tests , tdd states before writing code, tests fail should written first. therefore, in case of ...

oracle - Catch a PL/SQL procedure's RETURN value in command prompt? -

currently i'm using %testvar%=sqlplus usr/password@schema @test.sql echo %testvar% where test.sql calls procedure using begin end block , , saves returned value in string variable named x , how return command prompt ? a procedure can return value through out parameter, function can return value can stored in variable. not sure how trying return value through procedure seems trying work better if had written function.

c# - Post <Li> Items with Json and Jquery to Web Method -

i trying pass <li> list web method using json , jquery. goal return list c# using session variable.my problem session return null. list never passes on web method. list: <div> <ol id="mycart"> <li>iphone</li> <li>ipod</li> <li>ipad</li> </ol> </div> <input type="button" id = "btngetcart" value="get cart" /> the json script: <script type="text/javascript"> $("#btngetcart").live("click", function () { var items = $('.mycart').find('li').map(function() { var item = { }; item.title = $(this).text(); return item; }); var json = json.stringify(items); $.ajax({ type: 'post', url: "webform4.aspx/getcart", data: "{json}", contenttype...

iterating in a array in C -

hey have of type eph_t *a; the type eph_t can see. array in c not know size of array nor know end element of array. there way, can go through whole array because want assign values of every element in array something. what can options consider? if not understand in question comment can inform you. if not know size of array unsafe iterate on it. time attempt read elements beyond last 1 undefined behaviour. there nothing safe can unless know size of array.

functional programming - Reduction in Lambda Calculus -

i have been studying lambda calculation , have many doubts reduction , substitution . alpha , beta reduction are? , when , why used ?. it great if tell resources on reduction , substitution in lambda caculus. beta reduction primary application rule used computation within lambda calculus. applied through substitution shown: if had lambda term: (\x.x) , value right of it: y then substitute bound variables right of (.) in lambda term. bound variables variables match variable left of (.), in case x. the reduction of form: (\x.x)y //y gets bound occurences of x right of period y where y bound occurrences of x in lambda expression. identity function. alpha "reductions" called alpha equivalences or alpha rewrite rules. state can change name of lambda term , bound variables without changing meaning of expression. for example using identity function above written lambda term (\j.j). wouldn't change outcome of our application shown: (\j.j)y //y...

java - Android. How to move object in the direction it is facing (using Vector3 and Quaternion) -

i'm using libgdx (quite new in fact) , android. , want move 3d object in direction facing (using speed). thinks it's basic question can't find straight nswer it. have quaternion representing object rotation(direction) , have vector3 representing object position. question how update position vector3 using info quaternion in order move object in direction represented quaternion. (an alternative extract roll pitch , yaw quaternion , new coords applying trigonometric calculations. think there must way achieve using vector3 , quat.) quaternion used specify rotation. first need specify direction when no rotation applied. example if want move along x axis when no rotation applied: vector3 basedirection = new vector3(1,0,0); make sure base direction normalized (length = 1),you can use nor() method safe: vector3 basedirection = new vector3(1,0,0).nor(); next you'll need rotate direction using quaternion: vector3 direction = new vector3(); quaternion rotat...

ios - How to get the correct autocomplete in XCode for a block variable? -

i have block thats stored instance variable in class typedef void ((^didselectword)(nsstring* word)); @property (nonatomic,strong) didselectword wordselected; and want xcode auto fillout block when type [uiview animatewithduration , xcode autocompletes block it. when autocomplete block fills out [self.suggestedsearchtermview setwordselected:(didselectword)wordselected instead of [self.suggestedsearchtermview setwordselected:^(nsstring *word) { is possible change make xcode understand how autocomplete block? ok did testing. apparently have 2 (far perfect) options: avoid typedef , declare property as @property (nonatomic,strong) void (^wordselected)(nsstring * word); as noted in comments, has drawback of skipping parameter name in autocompletion. explicitly add setter declaration in interface typedef void ((^didselectwordblock)(nsstring* word)); @interface yourclass : nsobject @property (nonatomic,strong) didselectwordblock wordselected; - (void)...

Trouble trying to restart my Java program -

after looking numerous ways restart java program within itself, while loop seemed easiest option. here's example of basic calculator program i'm trying with: import java.util.scanner; class { public static void main(string args[]){ boolean done = false; int oper; scanner input = new scanner(system.in); system.out.println("mcmackins calc v2.0 (now fewer crashes!)"); while (!done) { system.out.println("what operation? (0 quit, 1 add, 2 subtract, 3 multiply, 4 divide, 5 divide remainder, 6 average, 7 account interest):"); while (!input.hasnextint()){ system.out.println("enter valid integer."); input.next(); } oper = input.nextint(); switch (oper){ case 0: done = true; break; case 1: add addobject = new add(); addobject.getsum(); break; case 2: sub subobject = new sub(); subobject.getdifference(); break; case...

asp.net mvc 4 - TempData value not persisting if used in view -

i using tempdata["hdn"] = "1"; in controller if use this @{ var hdn = (string)tempdata["hdn"]; } in view tempdata["hdn"] value in getting null in post. if skip code in view persist in post. why happening? tempdata values cleared after read. if want value in controller after have read in view, need include in hidden field , read out form values. something like: <input type="hidden" name="hdn" value="@hdn" /> then in controller, can do: var hdn = request.form["hdn"] hth

angularjs - Editing model property inside ngRepeat, error undefined -

i'm quite inexperienced angularjs. i've read answers might related not clear enough me. my code- plunker i've created table using ngrepeat , want change websites name inside table after clicking save button . but error undefined . my code: var webapp = angular.module('webapp', []); //controllers webapp.controller ('websitesctrl', function ($scope, websites) { //$scope.x = new website('1','3343','32434','name','privkey','pubkey','userid'); $scope.websites = websites.get(); //this function displayes site details $scope.expandweb = function(website) { console.log('expand'); $scope.websitenew = angular.copy(website); $scope.showname = true; }; $scope.saveweb = function(websitenew) { $scope.website.name = websitenew.name; $scope.showname = false; }; }); //services webapp.factory('websites', functio...

c# - Get all last descendants of a base type? -

this question opposite of how find types direct descendants of base class? if inheritance hierarchy have, class base { } class derived1 : base { } class derived1a : derived1 { } class derived1b : derived1 { } class derived2 : base { } i need mechanism find sub types of base class in particular assembly @ end of inheritance tree. in other words, subtypesof(typeof(base)) should give me -> { derived1a, derived1b, derived2 } this have come with. not sure if more elegant/efficient solutions exist.. public static ienumerable<type> getlastdescendants(this type t) { if (!t.isclass) throw new exception(t + " not class"); var subtypes = t.assembly.gettypes().where(x => x.issubclassof(t)).toarray(); return subtypes.where(x => subtypes.all(y => y.basetype != x)); } and sake of completeness, repost answer direct descendants given here public static ienumerable<type> getdirectdescendants(this type t)...

winforms - C# While loop until button click -

i making program in winforms (c#) in ms visual studio 2012 i need code this code code code event button click user //start while loop.. { code code code code code code } (!button not click again) i know many talk multithreading think low level work now, if can avoid will. edit: ended using multithreading, answers helped me lot, @ time multithreading hard understand. you should pushing work background thread. reason because main ui thread being stopped during while loop means button won't accessible turn off. (i know said want avoid multiple threads reality you'll need use them in case). the easiest way use backgroundworker . handle lot of thread spawning side of things you. can perform while loop in dowork event handler of background worker. free ui thread means button clickable @ point can set flag stop loop.

html - How do I absolutely position a relatively positioned element? -

Image
let's have container, , want put 1 container yet another container that's full of other stuff. css code might this: .parent-container { width: 100%; position: relative; } .child-container { width: 600px; position: absolute; left: 25px; bottom: 100px; } however, .child-container includes absolutely positioned elements, position relatively .parent-container because .child-container doesn't have position: relative . question is, how can position .child-container 's children relatively itself, while still keeping correctly positioned in .parent-container ? p. s. wrapping .child-container in position: absolute 'd div , making .child-container position: relative should trick, hoping more... semantic. absolutely positioned elements should already relative parent. here's demo shows nested items within absolute positioning html <div class='parent-container'> parent <div class='child-cont...

PHP code to Track Seeds and Peers of torrent by its hash -

i have torrent hash example 3ba918bf6b648bb6bec6aac716f1855451016980 , there api size , seeds , , peer of torrent.just these 3 info enough .and dont want scrape illegal .i want permenant. i have googled , checked stackoveflow.i did not find info torrent info via hash . bitsnoop have api this. though can't size. http://bitsnoop.com/info/api.html http://bitsnoop.com/api/trackers.php?hash=3ba918bf6b648bb6bec6aac716f1855451016980&json=1

JQuery Dialog not displaying buttons -

i'm initializing dialog box in document.ready() function put ok button doesn't render on page. straight forward thing, not sure what's going on. $(document).ready(function(){ //var popupwindow = window.open('p360tradingvideos.asp','p360tradingvideos','height=400,width=510,status=no,toolbar=no,menubar=no,resizable=no,location=no,scrollbars=no'); $("#videoplayerdiv").dialog({ position: "center", resizable: true, autoresize: true, draggable: false, modal: true, buttons: { "ok": function(){ $(this).dialog("close"); } } }); }) and here div <div id="videoplayerdiv"> <div id="videotable"> <table> <tr> <td><b>trading videos</b></td> </tr> <tr> <td>--></td><td><a href=...

javascript - Jwplayer for element inside kendo Editor -

i have used kendoui ,in html editor of kendoui add custom tool audio integration , audio using jwplayer , when creating player div inside editor gives error uncaught typeerror: object #<object> has no method 'setup' i want create jwplayer dive inside of kendo editor possible ? if yes how ?

d3.js - minimal cubism.js horizon chart example (TypeError: callback is not a function) -

i'm having devil of time going code found on d3 , cubism api pages altering things work need them do... i'm trying follow steps horizon graph listed here https://github.com/square/cubism/wiki/horizon don't have cube or graphite data source. so i'm trying make minimal example metric mbostock's answer here using other data sources cubism.js and/or random-value-returning metric example here https://github.com/square/cubism/wiki/context i guess on context api page, explains parameters context.metric(), don't understand part "...and callback function when results available". have following on server , when view/refresh in browser "typeerror: callback not function" in browser's console: <body> <div class="mag"></div> <script type="text/javascript"> var mycontext = cubism.context(); var myhoriz = mycontext.horizon() .metric(funct...

angularjs - What is the minimum work to get Angular working in a ASP.NET MVC/WEB Api template -

i transitioning on using angular , web api together. mvc/web api templates in visual studio have root path point homecontroller.cs returns view.. how root path point angular html file? concept of server side routing need go away somehow ? confused , have not found info on how transition mvc/web api template using angular , do files template creates.. far understand is create web api template in vs create index.html page in root directory contains ng directive other angular html pages , serves sort of master page them then guess need rid of asp.net mvc routing works in old school webforms type of way of specifying file default file? let me take stab @ using same stack of asp.net mvc, webapi , angularjs. assuming creating spa. first , foremost, keep web api out of picture. it's applicability limited sending data in different formats, there no view concepts in it. you can use both server side routing , angular routing serve views user. can in fact complement e...

html - How can I get things properly contained in a wrapper div? -

at cjshayward.com/index_new.html , there wrapper div around body's content, 1000 pixels wide, , works intended top 100 or pixels in chrome , firefox. next down page jquery ui set of tabs, containing fixed-width accordion , close jquery.load()ed plain old, simple html. however, on "browse library" tab (but not "about author"), presently open , contains fixed-width accordion, below 100 or 150px down, area under tabs appears have same width window; has correct left margin, , horizontally scrolls apparently equal distance right. furthermore, body background tile not display; whole width white, specified wrapper div's interior. how can "browse library" tab display intended (like "about author" tab does)? thanks, you're absolutely positioning way , that's ruining flow of things. i'll go through list of edits can make work. /* #accordion , #details floated, we'll need clear #tabs. add property. */ #tabs...

sql - Reverse Crosstab Query in Access -

in access 2013, table has following structure: name |city |q113 |q213 peter |london |20 |30 sandra |paris |40 |50 i want "reverse crosstab query", getting following: name |city |period |value peter |london |q113 |20 peter |london |q213 |30 sandra |paris |q113 |40 sandra |paris |q213 |50 i tried union query, using sql: select [name], [city] ,'q113' [period], [q113] [value] [database] union order [name] , [city] , [period] however, isn't working, keep getting error: "invalid sql statement expected; 'delete','insert', 'procedure', 'select' or 'update' googling error didn't much, guess there wrong code above? please help. you missing query after union all : select [name], [city] ,'q113' [period], [q113] [value] [database] union select [name], [city] ,'q213' [period], [q213] [value] [database] order [name], [city], [perio...

How can I encode French characters in objective-c? -

i using google translate in french , letters of result come me symbols. after research, learned because of encoding need because not find enough information. here code: - (void)performtranslation:(nsstring *) inputstr { nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults]; nsstring *outlang = [defaults objectforkey:@"outlanguage"]; nsstring *inlang=@"tr"; nsstring *textescaped = [inputstr stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; nslog(@"textescaped=%@",textescaped); nsstring *url = [nsstring stringwithformat:@"https://www.googleapis.com/language/translate/v2? key=aizasyax5dsikm1j-qkc0qkzpynwhgfjypoc84g&q=%@&source=%@&target=%@",textescaped, inlang, outlang]; nslog(@"req : -%@-", url); nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:url]]; [[nsurlconnection alloc] initwithrequest:request delegate:self]; } - (void)connection:(...

android - Bitmap.recycle() - "IllegalArgumentException: Cannot draw recycled bitmaps" -

in documentation, titled " managing bitmap memory " can find following statement: caution: should use recycle() when sure bitmap no longer being used. if call recycle() , later attempt draw bitmap, error: "canvas: trying use recycled bitmap". so, means "no longer"? i call setimagedrawable(drawable) in fragments oncreateview(...) method. , call recycle() on drawable's bitmap in fragment's onstop(). when user leaves fragment launching activity bitmap recycled. when user comes previous fragment, oncreateview() called again, resulting in new call "setimagedrawable(drawable)". , throws: illegalargumentexception: cannot draw recycled bitmaps so, still seem in "no longer" context. when new bitmap, not recycled? after fragment , activity have been destroyed? so, means "no longer"? no longer means not going use same reference of bitmap. as told recycling bitmaps on onstop(), try inside onst...

javascript - JQGrid onSelectRow event and jquery.simplemodal.js modal dialog -

i trying show modal window using jquery.simplemodal.js jquery plugin everytime click on row of jqgrid. after doing it, once user click "yes" on modal window show document on iframe using info retrieved row, if click "no" iframe shows form edit info related document. idea keep iframe content blank until user clicks on 1 of buttons. accomplish using jqgrid onselectrow event follows: onselectrow: function () { var id = $("#tabresbusubi").getgridparam('selrow'); var row = $('#tabresbusubi').jqgrid('getrowdata', id); viewdocument = false; myconfirm('open document view?', function () { viewdocument = true; }); if (viewdocument) { $('#ifrshowpdf').ready(function () { $('#divloading').css('display', 'none'); }); $('#i...

php - Interpolating variables in HEREDOCs -

this question has answer here: reference - error mean in php? 29 answers i'd interpolate variables heredoc string, giving me errors, code this: $htmlviewappointments .= <<<eot <tr><td>$obj['year']</td></tr> eot; use: $htmlviewappointments .= <<<eot <tr><td>{$obj['year']}</td></tr> eot;

android - OutOfMemory Error when trying to rescale a Bitmap -

im trying scale bitmap make fit because device wont show images > 2048. i found solution app crashes when choose/take pic. that piece of code: (inside onactivityresult) currimageuri = data.getdata(); path=(getrealpathfromuri(currimageuri)); drawable d = drawable.createfrompath(path); image.setvisibility(view.visible); mphoto=drawabletobitmap(d); bitmap sized = mphoto; if(mphoto.getheight()>=2048||mphoto.getwidth()>=2048){ sized = bitmap.createscaledbitmap(mphoto, (int)(mphoto.getwidth()*0.8), (int)(mphoto.getheight()*0.8), false); } image.setimagebitmap(sized); logcat: 08-28 22:48:14.873: e/androidruntime(12047): fatal exception: main 08-28 22:48:14.873: e/androidruntime(12047): java.lang.outofmemoryerror 08-28 22:48:14.873: e/androidruntime(12047): @ android.graphics.bitmap.nativecreate(native method) 08-28 22:48:14...

pascal - Write string variable to the clipboard -

i'm going admit, right off bat, i'm pascal-inexperienced, least. so, can appreciated. :) as part of larger program, need write string variable clipboard. i've created new project in lazarus (version 1.0.12) can try figure out how without complications caused extra, unnecessary code, have included below: program vartoclipboard; uses clipbrd; var texttocopy:string; begin texttocopy := 'test text pascal'; clipboard.astext := texttocopy; end. using above code, along required lclbase dependency, i'm getting following error in cmd when running compiled exe: an unhandled exception occurred @ $000000000043d45e : eaccessviolation : access violation $000000000043d45e clipboardregisterformat, line 98 of ./include/lclintf.inc $000000000043c35b predefinedclipboardformat, line 185 of lclintf.pas $0000000000415b0c tclipboard__setastext, line 452 of ./include/clipbrd.inc $0000000000401802 main, line 12 of vartoclipboard.lpr accor...

php - [SOVLED]PDO/MySQL Prepared Statement Injection Semi Colon -

i wondering why in prepared statement characters formular user input aren't escaped expect be. here code @ particular part: if( isset( $_post['key'] ) && strlen($_post['key']) <= 15) { $sql = "select titel, date, content news content :content or titel :title"; if( $stmt = $pdo->prepare($sql) ) { $temp = "%".$_post['key']."%"; // not manually escaped here $stmt->bindparam(':content', $temp); // should escape!? $stmt->bindparam(':title', $temp); // should escape!? $stmt->execute(); $stmt->bindcolumn("titel", $title, pdo::param_str); $stmt->bindcolumn("datum", $date, pdo::param_str); $stmt->bindcolumn("inhalt", $content, pdo::param_str); while( $stmt->fetch() ) { echo "<span class='head'>".$title." :: ".$date."</span>...

html - How can I set a background pattern to begin repeating from the center of my page? -

Image
i want background repeat-x @ top of page, want begin repeating center, not across whole page. example this: one way use ::after pseudo selector this: body::after { content: ''; position: absolute; left: 50%; right: 0; top: 0; bottom: 0; z-index: -1; background: url('http://i.imgur.com/2xpv3gf.png') repeat-x left top; } fiddle: http://jsfiddle.net/vf4rm/

android - Trouble with Drawing a Bitmap on a Canvas -

i trying draw image onto canvas, , while program compiles , behaves expect to, error log shows there nullpointerexception associated drawbitmap() method below. strange image still drawn canvas. issue , how should go resolving it? my code: public class progressbar extends view { string packagename; public progressbar(context context) { super(context); packagename = context.getpackagename(); } public progressbar(context context, attributeset attribs) { super(context, attribs); packagename = context.getpackagename(); } @override protected void ondraw(canvas canvas) { super.ondraw(canvas); int resourceid = getresources().getidentifier("bar1", "drawable", packagename); bitmap bitmap = bitmapfactory.decoderesource(getresources(), resourceid); canvas.drawbitmap(bitmap, 35, 35, null); } @override protected void onmeasure(int widthmeasurespec, int ...

r - Why is dcast not working in reshape2? -

this paper published reshape package (wickham 2007) gave example: library(reshape2) ffm <- melt(french_fries, id = 1:4, na.rm = true) dcast(ffm, variable ~ ., c(min, max)) similarly, doesn't work in reshape2 appears work in wickham 2007 dcast(ffm, variable ~ ., summary) however cast function giving error. how can function work? the paper reshape package, not reshape2 package. have not reproduced example written. should be: library("reshape") # not explicit in paper, implied since reshape pacakge ffm <- melt(french_fries, id = 1:4, na.rm = true) cast(ffm, treatment ~ rep, c(min, max)) note function call cast , not dcast . change 1 of major changes between 2 packages. dropping of multiple aggregation @ same time reshaping considered better handled plyr package. if use reshape package (which still available cran), examples work.

javascript - Function not working after running it 1 time -

here's fiddle of i'm doing http://jsfiddle.net/9mcqb/ essentially, want inline-edit items, , save them via ajax.. added function called select(name) creates select element , adds name + id later gets populated options(name, value, selectelement) function. htlm should replaced when click edit. it works fine when attempt use select() 1 time. when try apply other fields, however, gives me: typeerror: select not function days = select("day"); i've read other questions thoroughly (maybe missed one), don't think have bad syntax, unclosed html or js, or overwriting function. any ideas? ahead of time code: // create select field select = function(name) { s = "<select></select>"; select = $(s).attr("name", name).attr("id", name); return select; } // add options select options = function(name, value, selectelement) { o = "<option></option>"; option = $(o).attr("value...

unity3d - C# - variable speed when using turning joystick -

i making game, using onscreen/virtual joystick. joystick self works fine. what want when turn joystick, bullet fired in direction. got working too. problems arises when shooting bullet when joystick not @ edge/radius. when joystick @ edge/radius, bullet move @ maximum speed, want. when joystick is, lets say, somewhere between radius , center of joystick, bullets move slower. logical because of radians , stuff. but not want. should happen bullets move @ maximum speed. does know how achieved? stuck @ this. thanks! edit: since still dont understand @ all, want have point in radians within circle , want position of point @ edge of circle. so let's have vector2 in radians. vector2(-0.3, 0.3); and radius of circle 40. the length center of circle vector2 point propably somewhere around radius = 40 * 0.3 = 12 now vector2 point when length 40? i can't seems figure out. trigonometry definetely not strongest point. i fixed it! multiplied loca...

hyperlink - Timed jquery fadeout - creating links -

i found cool jquery fade in/fade out script, can't quite figure out how alter script make text href link (i want use news ticker). i've spent hours fiddling jquery isn't par. example i've tried put <a href="#">test line 1</a> in textcontent div link not appear. link below , code copied post convenience. suggestions? i'm open other ideas, fade effect cool , keep that! assistance! http://jsfiddle.net/mplungjan/bwd4v/ <style type="text/css"> div.textcontent { display:none } </style> <div id="textmessage"></div> <div class="textcontent">test line 1 </div> <div class="textcontent">test line 2</div> <script> var cnt=0, texts=[]; // save texts in array re-use $(".textcontent").each(function() { texts[cnt++]=$(this).text(); }); function slide() { if (cnt>=texts.length) cnt=0; $('#textmessage').html(texts[cnt++]); $...

scala - Transform this iterative solution to functional solution -

this class takes map of type [string , list[string]] , outputs map of [string, string] key name of list , values binary representation of letters. each digit corresponds if letter appears in list or not. 1 - appears, 0 - not appear. example list : 1 = 1,1,0,0 2 = 1,1,1,0 3 = 1,1,0,1 4 = 1,1,0,0 returns 4-->1100 1-->1100 2-->1110 3-->1101 below iterative solution : object binaryrep { var userdetails : scala.collection.immutable.hashmap[string, list[string]] = new scala.collection.immutable.hashmap[string, list[string]] var letterstocheck = list("a" , "b" , "c" ,"d") def main(args: array[string]) { userdetails += "1" -> list("a" , "b") userdetails += "2" -> list("a" , "b" , "c") userdetails += "3" -> list("a" , "b" , "d") userdetails += "4" -> list("a" , ...

java - create a list from another list and remove elements from copied list -

Image
suppose have following structure , created list this. if temp.remove(0) won't affect on original list temp.get(0).vars.remove(0) remove elements original list too. i think new arraylist(top.mids) not doing deep copy how come temp.remove(0) doesn't affect on original list? //top class init part , adding elements omitted list<mid> temp = new arraylist(top.mids); temp.remove(0); temp.get(0).bots.remove(0); public class top{ list<mid> mids = new arraylist<mid>(); } public class mid{ list<bot> bots = new arraylist<bot>(); } public class bot{ int id; } yes understanding correct. list newlist = new arraylist(collection); shallow copy. can modify newlist without affecting original collection , each reference same elements if modify element in 1 list, other list's element change. this called shallow copy. here's visual representation of i've described: the things @ bottom objects in array. ...

c++ - Decimal Division by left shift -

i have been given question convert base 10 2 without using division(/) , modules(%) ,so came solution of using bitwise and(&)and right shift(>>) operators. so start learn these 2 operators still questions not find answer or understand logic behind. if understand correctly division works according digits place value,in decimal , binary both . when divide number 10 or 2 ,we shift place value 1 place right in both ,which result in division 10 in decimal , 2 in binary. x=120 (in base of ten) if x>>1 have x=12 (division 10) y=1000 (in base of two) if y>>1 have x=100 (division 2) but when use piece of code: #include<iostream> using namespace std ; int main() { int a,b=1; cout <<"enter integer"<<endl; cin>> a; cout<<(a & b)<<endl; a=a>>1; cout<<a; cout<<endl; system("pause"); return 0 ; } i comfused cause in mind this ...

hook - MobileSubstrate game hacking on iphone -

i practicing mobilesubstrate hacking on game kingdom age (v2.0) ipad. i want make ton of in-game money, getting nowhere. player defined in class, ccplayer , server checked. so trying heart of data, inside ccgameinformation class. function -(id)activeplayer callet lot (like 30 times sec) thought nice place start. ccplayer defined (in include files) as @interface ccplayer : fzplayer <nscoding> { nsstring *townname; nsstring *rawlastupdateenergytime; nsstring *rawlastupdatestaminatime; nsstring *rawexpansiontimestarted; nsstring *rawbankupgradetimestarted; ... int gold; int level; int attack; ... @end i declared in tweaks.xm as: @interface ccplayer:nsobject { nsstring *townname; nsstring *rawlastupdateenergytime; nsstring *rawlastupdatestaminatime; nsstring *rawexpansiontimestarted; nsstring *rawbankupgradetimestarted; ... int gold; int level; int attack; ... @end i included whole thing, changed base class. ccgameinformation defined as: @interface ccgameinforma...

file - c program not writing same result as it is displaying -

my c program not writing file same data displaying. how save outputted screen in file. trying save webpage, file name defined third option, [site] [page] [path] #include <stdio.h> #include <sys/socket.h> #include <arpa/inet.h> #include <stdlib.h> #include <netdb.h> #include <string.h> int create_tcp_socket(); char *get_ip(char *host); char *build_get_query(char *host, char *page); void usage(); #define host "coding.debuntu.org" #define page "/" #define port 80 #define useragent "htmlget 1.0" #define os "mac osx" int main(int argc, char **argv) { struct sockaddr_in *remote; int sock; int tmpres; char *ip; char *get; char buf[bufsiz+1]; char *host; char *page; char *htmlfile; if(argc == 1){ usage(); exit(2); } host = argv[1]; if(argc > 2){ page = argv[2]; }else{ page = page; } htmlfile = argv[3]; sock = create_tcp_socket(); ip = get_ip(host); f...

How do you include files from a scala project in eclipse in a java project in netbeans -

i have project in java on netbeans 7.3 need add more classes to. however, working scala on eclipse. how can import classes eclipse project , execute them when run program on netbeans? not sure since i've never configured stuff - coded in prepared environments :( if developing library in scala application, suggest use sbt , package library jar , import jar java project. you have define build file in sbt. not sure whether defined , use sbt package command. sbt package try using sbt

android - Scrolling to a row in a TableLayout Programatically -

i have tablelayout contained in scrollview. tablelayout populated programatically during runtime. table contains flight arrival information. 1 tablelayout has been populated, want able scroll down current time period. if know want scroll row number 40 of 100 in table, how can this? here xml of layout. in advance. <linearlayout android1:id="@+id/linearlayout20" android1:layout_width="fill_parent" android1:layout_weight="1" android:orientation="vertical" android1:background="#000000" android:layout_height="10000dp" android:measurewithlargestchild="true"> <scrollview android1:id="@+id/scrollview1" android1:layout_width="match_parent" android1:layout_height="wrap_content"> <tablelayout android1:id="@+id/arrivalstable" android1:layout_wid...

hadoop - implement customized rawcomparator -

i need improve mr jobs, 1 thing think implement customized rawcomparator, key class have lots of fields string besides int fields, not sure how parse out string fields out of byte[], my key class public generalkey { private int day; private int hour; private string type; private string name; .. } my customized rawcomparator: public class generalkeycomparator extends writablecomparator { private static final text.comparator text_comparator = new text.comparator(); protected generalkeycomparator() { super(generalkey.class); } @override public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) { int day1 = readint(b1, s1); int day2 = readint(b2, s2); int comp = (intday1 < intday2) ? -1 : (intday1 == intday2) ? 0 : 1; if (0 != comp) { return comp; } int hr1 = readint(b1, s1+4); int hr2 = readint(b2, s2+4); comp = (hr1 < hr2) ? -1 : (hr1 == h...

curl - paypal rest api payment call returning 401 using php -

i trying add paypal site. have been following instructions @ https://developer.paypal.com/webapps/developer/docs/integration/direct/make-your-first-call/ , not working. have sent request access token , gotten response. information in response stored in object called $accesstoken. problem lies when try make api call in step 3 site listed above. 401 error sent request. i'm pretty sure $url request sent function parameter correct. https://api.sandbox.paypal.com/v1/payments/payment . have been going on internet for past week , half, , haven't made progress whatsoever. appreciated. thanks! function makepaymentapicall($accesstoken, $sale, $url, $url_success, $url_cancel){ // create curl resource $ch = curl_init(); // set url curl_setopt($ch, curlopt_url, $url); $tokentype = $accesstoken->gettokentype(); $token = $accesstoken->getaccesstoken(); $auth = "authorization:" . $tokentype . " " . $token; $saletotal = $sale->gettotal(); $header ...

ruby - How to test 404 Sinatra::NotFound errors with Rack::Test? -

i have application raises 404 sinatra::notfound errors on production when route missing. however, following test passes: it 'should not raise error' expect{ '/unknown_path' }.to_not raise_error end why don't 404 sinatra::notfound errors raised in test? the following raise error , cause test fail: get '/unknown_path' raise 'error' end how test 404 sinatra::notfound errors? try this: get '/unknown_path' assert_equal last_response.status, 404

php - Simplexml: Select element by id a echo a certain child element -

i'd need advise simplexml xpath. have master xml-file entire website this: <content> <item id="001"> <title>video 1</title> <video> <file>video001.mp4</file> <dur>01:20</dur> </video> </item> <item id="2"> <title>video 2</title> <video> <file>video002.mp4</file> **<dur>03:53</dur>** </video> </item> </content> now want echo duration of video of item id "2" string "03:53". seems simples use of simplexml, tons of tutorials out there cover loops , selection array number. want access parent element id grab string of child element of it. thanks in advance! runa you may use xpath purpose: http://php.net/manual/en/simplexmlelement.xpath.php you code should (more or less): $xml = simplexml_load_file('path/to/xml/file.xml'); $result =...