Posts

Showing posts from February, 2014

Is there a good database backend in Django for Amazon DynamoDB? -

i use dynamodb next django project. have found implentation store session data dynamodb, there backend implementation django store database data? i don't think there django dynamodb projects out there allow use django orm while using dynamodb underneath. but depending on case, may still able ignore orm portion of django , use dynamodb directly (via boto or pun anode or similar ). in case, use mix. keep users , other models read on postgres (rds) , django orm, use dynamodb models require heavy writes ( using pynamodb). i still use views, templates or add api via django-rest-framework. lose admin pages ( don't need these models ) , other features orm gives have been happy result anyway.

java - Add 0 to end if number is like $12.5 -

possible duplicate: usd currency formatting in java all- have small problem in app outputs answer after inputs go through equation , rounded 2 decimal places after decimal point. problem if number comes out $12.80 output looks $12.8. want $12.80. not biggest deal in final stages of development , clean nice. here of code: float result2 = result / l3; double data2 = result2; int decimalplaces2 = 2; double roundbase2 = math.pow(10, decimalplaces2); data2 = (double)(math.round(data2 * roundbase2)) / roundbase2; answer.settext("$" + double.tostring(data2)); thanks time! decimalformat format = new decimalformat("$#"); format.setminimumfractiondigits(2); answer.settext(format.format(data2));

javascript - JQgrid on sorting data changes for ID column -

i using jqgrid display data, data in grid added row row. using "local" data type enable sorting on client side. having 'id'in colmodel stores database id. @ first time data loaded when click on header sorting data content of 'id' column changes 1,2 ... please help.. my code var pagenumber=0, previouslyselectedid, numberofrecords; var numberofpages,sortingflag=false; $(function() { $("#suppliercommoditylist").jqgrid({ datatype: "local", colnames:['id','supplier','commodity','unit','cost per unit','start date','end date'], colmodel:[ {name:'id',index:'id',hidden:true}, {name:'supplier.name',index:'supplier.name',sorttype:"string",formatter:wraptolinkformatter}, {name:'coproductspecification.na...

sql - Table-Valued function - Order by is ignored in output -

Image
we moving sql server 2008 sql server 2012 , noticed our table-valued functions no longer deliver temp table contents in correctly sorted order. code: insert @customer select customer_id, name, case when expiry_date < getdate() 1 when expired = 1 1 else 0 end customer **order name** in sql server 2008 function returns customers sorted name. in sql server 2012 returns table unsorted. "order by" ignored in sql 2012. do have re-write functions include sort_id , sort them when called in main application or there easy fix?? there 2 things wrong original approach. on inserting table never guaranteed order by on insert ... select ... order by order rows inserted. on selecting sql server not guarantee select without order by return rows in particular order such insertion order anyway. in 2012 looks though behaviour has changed respect item 1. ignores order by on select sta...

entity framework 4 - POCO entities and IsLoaded() in EF 4.1 -

i'm working on enterprise application leverages repository pattern on top of ef 4.1 eager loading poco entities. typically, call this: public ienumerable<someentity> list(datetime date) { using (var context = contextfactory.createcontext()) // returns dbcontext { return createquery<someentity>(context) .include("path1") .include("path2") .where(...) .asnotracking() .tolist(); } } at point, business layer translates these entities dtos transmitted via wcf web application. as eager loading rather expensive, i'm trying keep .include's minimum, related properties (eagerly) loaded , they're not. however, business layer has no idea when related properties present in entity, objectcontextdisposedexception, reason clear me , don't intend change basic strategy (i.e. dispose context right after eager loading entities). however, need check whether particula...

redirect user after share facebook -

i want redirect users specific page after share on facebook, have found answer here at: redirect user after facebook share , publish here's script <script type="text/javascript"> fb.init({appid: "your_app_id", status: true, cookie: true}); function share_me() { fb.ui({ method: 'feed', app_id: 'your_app_id', link: 'share_url', picture: 'pic_url', name: 'share_name', caption: 'share_caption', description: 'share_description' }, function(response){ if(response && response.post_id) { self.location.href = 'success_url' } else { self.location.href = 'cancel_url' } }); } </script>"; <div onclick="share_me()">share</div> but when used script ,there's no redirect @ all, if user click "cancel" please me searching method since 1...

c++ - Calling void function problems -

hello have problems calling void initialize() function in code. supposed array looks this //cccccccccccccccccccccccccc cxxxxxxxxxxxxxxxxxxxxxxxxc cxxxxxxxxxxxxxxxxxxxxxxxxc cxxxxxxxxxxxxxxxxxxxxxxxxc cxxxxxxxxxxxxxxxxxxxxxxxxc cxxxxhhhhhhhxxxxxxxxxxxxxc cxxxxhhhhhhhxxxxxxxxxxxxxc cxxxxhhhhhhhxxxxxxxxxxxxxc cxxxxhhhhhhhxxxxxxxxxxxxxc cxxxxxxxxxxxxxxxxxxxxxxxxc cccccccccccccccccccccccccc// where array defined in initialize() , variables come fin , steampipe , gridpt classes. code giving me first set of answers before array when gets array symbol '?' it's been designated in class gridpt. think way calling void function wrong or there wrong passing variables? tried taking out const still same. here code .h file #include<iostream> #include<istream> #include<cmath> #include<cstdlib> using namespace std; const int maxfinheight = 100; const int maxfinwidth = 100; class steampipe { private: int height, width; double steam...

c# - Does changing a copy of a variable change the original? -

i had access modified closure error in code below foreach (var user in entities.user) { bool = entities.person.any( p => p.name == user.name); } so changed foreach (var user in entities.user) { user theuser = user; bool = entities.person.any( p => p.name == theuser.name); } now, question want able modify property of user object. matter if either of following. both save down database when call savechanges on dbcontext? user.property = 1; or theuser.property = 1; yes. user in case referencec type , variables of type references pointing instance. assignment changes variable point same instance.

css - Is there a CSS3 Reset? -

i wondering if there exists global css reset css3. along lines of commonly-used versions created eric meyer or yui , css3 specifically. i've queried channels such google, github , here on so, haven't come across comprehensive solution. edit : term "reset" misleading since deals resetting browser default settings. "recalibration" may better suited. i should clarify , put forth use case. this work in tandem normal css reset yet handle styling caused rotation, box shadow, animation, border radius, etc. example, mentioned before on this post : -webkit-transform:none; /* safari , chrome */ -moz-transform:none; /* firefox */ -ms-transform:none; /* ie 9 */ -o-transform:none; /* opera */ transform:none; the above snippet, , others it, associated html tags might affected them, current css resets. the implementation need not common if in control of properties. if are, example, creating app or plug-in used across different domains, styling of pages plu...

php - combine multiple id into one event jquery -

i have 3 text field needs have jquery click event $('#landline' or '#mobile_number' or '#alternate_number').click(function() { $(this).val(""); }); i want implement whenever user click field id landline or mobile_number or alternate_number value set null. code didn't work. use , concatenate multiple selectors: $('#landline, #mobile_number, #alternate_number').click(function() { $(this).val(""); });

sql - How to stop oracle undo process? -

i want know how stop undo process of oracle ? tried delete millions of rows of big table , in middle of process killed session started undo delete , bout 2 hours database got dramatically slow. didn't want undo process continued. there way stop ? row-by-row delete processes can, you've found, exceedingly slow. if deletions done in single transaction, appears case here, can become slower. might want consider following options: if you're deleting rows in table might want consider using truncate table statement. if you're not deleting rows in table should change procedure commit after number of rows deleted. in meantime you're going have wait until rollback process completes. share , enjoy.

How can I get the colour (fill) of a DisplayObject in response to an event like a touch in Corona SDK? -

can me find out how can can color of rectangle in corona? rectangle filled color, want color when touch on rectangle. create rectangle: local rectangle = display.newrect(0, 0, 100, 100) put color in rgba (you can leave out a) format in table, , store "custom property" rectangle: rectangle.fillcolor = {110, 30, 25} through magic of unpack function, returns values of table, pass table setfillcolor: rectangle:setfillcolor( unpack(rectangle.fillcolor) ) now can color so: print( unpack(rectangle.fillcolor) ) --> 110 30 25 or print( rectangle.fillcolor ) -- returns table or put each color in variable: local red, green, blue, alpha = unpack(rectangle.fillcolor) you'll see how can come in handy other things well. edit just thought of cool way of doing it, highjacking setfillcolor function: local function decoraterectangle(rect) rect.cachedsetfillcolor = rect.setfillcolor -- store setfillcolor function function rect:set...

view - Adding a child in a GestureOverlayView on the point where i touched in android? -

how can add child(a layout) in gestureoverlayview @ point touched in view..... possible position according co ordinates of location?? for api 11 (android 3.0.x) , above: can use view.setx() , view.sety() . see api docs details. for api versions: use relativelayout , relativelayout.layout . setting margins in fields inherited viewgroup.marginlayoutparams . guess go this: relativelayout parentlayout = (relativelayout) findviewbyid(r.id.relative_layout); linearlayout newlayout = new linearlayout(this); // or other layout relativelayout.layoutparams layoutparams = new relativelayout.layoutparams( // can enter layout absolute dimensions here instead of 'wrap_content'. viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content); // set x , y position here new layout. layoutparams.setmargins(100 /*left*/, 200 /*top*/, 0 /*right*/, 0 /*bottom*/); parentlayout.addview(newlayout , layoutparams);

php - spl_autoload_register issue -

i don't why error fatal error: class 'imagejpg' not found here code use spl_autoload_register(function($class) { if(file_exists($class)) { include $class.'.php'; } }); $n = new imagejpg(); file imagejpg.php in same dir code above. here content of imagejpg.php <?php class imagejpg { public function __construct() { echo 'image jpg called'; } } is there class named imagejpg in imagejpg.php file? , file exist? try this: spl_autoload_register(function($class) { if(file_exists($class.'.php')) { include $class.'.php'; if (!class_exists($class)) { die('required class not present'); } } else { die('file not found'); } });

properties - File not found error occur when read property file in java -

i create property file under package of resources/common/configure/ then create code properties prop = new properties(); try { //load properties file prop.load(new fileinputstream("resources/common/configure/commondata.properties")); //get property value , print out system.out.println(prop.getproperty("id")); } catch (ioexception ex) { ex.printstacktrace(); } but got following error java.io.filenotfoundexception: (the system cannot find path specified) please let me know how can property file. try prop.load(getclass().getresourceasstream("resources/common/configure/commondata.properties"));

html - Add a textfield dynamically with Jquery and Tapestry -

i need display dynamically 10 textfields in .tml file user can remove or add required number. found example jquery , html form, problem that didn't manage convert code in tapestry. here tutorial can please tell me if possible use tapestry , if me modify code thanks in advance tapestry 5 has nice component called ajaxformloop . examples on how use can found on jumpstart examples page. i'm sure can jquery code work utilizing tapestry5-jquery module. though without code or error messages impossible specific problem.

Lua Pattern - How get the required string using this lua pattern -

local invoicedata = [[i n v o c e invoice no. : abcdefg125469857 invoice date may 2012 ]] the pattern using print (string.match(invoicedata,'\ninvoice date (.-)\n')) i want fetch string invoice date may12 . or 0512 .. please help thanks instead of matching .- , more specific , use %w+ (alpha-nums) , %d+ (digits) match month , year. the script: local invoicedata = [[i n v o c e invoice no. : abcdefg125469857 invoice date may 2012 ]] month, year = string.match(invoicedata,'invoice%s+date%s+(%w+)%s+%d*(%d%d)') print(month, year) will print: may 12

Android Webview scroll is misbehaving when loading a flash website -

Image
i opening simple flash based website in webview using following code: java code: package com.sample.webview; import android.app.activity; import android.app.progressdialog; import android.graphics.bitmap; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.button; public class samplewebviewactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final webview webview = (webview) findviewbyid(r.id.webview); final progressdialog progress = new progressdialog(this); progress.setmessage("loading"); webview.getsettings().setjavascriptenabled(true); webview.getsettings().setpluginsenabled(true); webview.getsettings().setbuilti...

php - Auto complete fields of a previous values -

i doing small application in yii framework database this === invoices === id (pk) customer_id invoice_title order_no invoice_issue_date due_date description === customers === id (pk) email_address customer_name address city state postal_code description i have rendered customer model in invoice model can enter values both models in single invoice form .but there 1 problem,let assume have customer name xyz had saved before .now when going again fill customer name xyz ,it should show all fields of both models invoice_title,order_no,invoice_issue_date,due_date,description,email_address,customer_name,address etc. in input fields of form don't have re-enter fields again .so how can achive in yii framework.any , suggestions highly appreciable.more clarification on codes have done can shared if needed. please me out.i totally stuck here. to has mentioned need ajax, , javascript. logic this: when value selected in dropdown custome...

java - log4j properties: LevelMatchFilter doesn't work -

i trying route logging 2 different files: 1 info messages , 1 errors. levelmatchfilter seemed right way go. unfortunately, messages logged info.log, not info messages. ideas did wrong? here's config: # define root logger appender file log4j.logger.com.my.class.classname=debug, file, err, ca # define info file appender log4j.appender.file=org.apache.log4j.fileappender log4j.appender.file.file=info.log log4j.appender.file.filter.a=org.apache.log4j.varia.levelmatchfilter log4j.appender.file.filter.a.leveltomatch=info log4j.appender.file.filter.a.acceptonmatch=true # define layout info file appender log4j.appender.file.layout=org.apache.log4j.patternlayout log4j.appender.file.layout.conversionpattern=%d %-5p %c - %m%n # define error file appender log4j.appender.err=org.apache.log4j.fileappender log4j.appender.err.file=error.log log4j.appender.err.threshold=error # define layout error file appender log4j.appender.err.layout=org.apache.log4j.patternlayout log4j.appender.err.l...

firebase - How can I create a queue with multiple workers? -

Image
i want create queue clients can put in requests, server worker threads can pull them out have resources available. i'm exploring how firebase repository, rather external queue service have inject data firebase. with security , validation tools in mind, here simple example of have in mind: user pushes request "queue" bucket servers pull out request , deletes ( how ensure 1 server gets request? ) server validates data , retrieves private bucket (or injects new data) server pushes data and/or errors user's bucket a simplified example of might useful authentication: user puts authentication request public queue his login/password goes private bucket (a place can read/write into) a server picks authentication request, retrieves login/password, , validates against private bucket server can access the server pushes token user's private bucket (certainly there still security loopholes in public queue; i'm exploring @ point) some other exa...

reflection - How to display all types of an object (in Scala)? -

with isinstanceof method, 1 can check type of object. example: scala> val i: int = 5 i: int = 5 scala> val a: = a: = 5 scala> a.isinstanceof[any] res0: boolean = true scala> a.isinstanceof[int] res1: boolean = true scala> a.isinstanceof[string] res2: boolean = false how can 1 display types of object (if possible @ ?) ? you can pretty in 2.10 (m4 or later): import scala.reflect.runtime.universe._ def supertypes(t: type): set[type] = (t.parents ++ t.parents.flatmap(supertypes)).toset def alltypes[a](a: a)(implicit tag: typetag[a]) = supertypes(tag.tpe) + tag.tpe which gives following: scala> alltypes(1).foreach(println) anyval notnull int scala> alltypes("1").foreach(println) string object comparable[string] charsequence java.io.serializable scala> alltypes(list("1")).foreach(println) scala.collection.linearseq[string] scala.collection.genseq[string] scala.collection.iterablelike[string,list[string]] scala.coll...

php - How should I accomplish my rating script -

my webpage has table can select different items. want able let people rate these. ran problem need pass javascript variable php, , read online isn't easiest thing. how suggest this? the code stored @ 98.214.131.200/index.php , 98.214.131.200/ratings/ratings.php currently have functions in ratings.php allow me write or read ratings, need string javascript identify item being rated. you pass rating using post request form. http://www.tizag.com/phpt/forms.php/ make sure correctly sanitize inputs avoid sql injections http://www.tizag.com/mysqltutorial/mysql-php-sql-injection.php

jquery - Hide all elements that come after the nth element -

after 4th <a> element found, how .hide() rest? below code i've written far: <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function() { if($('a').length >= 4) { window.alert('4 or more'); } }); </script> <a>test </a><br> <a>fed </a><br> <a>fdes </a><br> <a>grr </a><br> <a>rerf </a><br> <a>dferf </a> any ideas? use :gt(index) selector: $('a:gt(3)').hide(); or faster slice function: $('a').slice(4).hide(); live demo because :gt() jquery extension , not part of css specification, queries using :gt() cannot take advantage of performance boost provided native dom queryselectorall() method. for better performance in modern browsers, use $("your-pure-css-selector").slice(index) instead. ...

include - Accessing variables in included file through helper method in PHP -

i trying build php class let me include other php "template" files display. want of variables in scope called available in included file. here's catch, want pass off actual including helper method keep code dry. here have far: /* templateloader.php */ class templateloader { public function foo() { $var = "foo!"; //works include 'template.php'; } public function bar() { $var = "bar!"; //doesn't work $this->render("template"); } private function render( $name ) { include $name . '.php'; } } /* template.php */ <?php echo $var; ?> my question is: how can accomplish behaviour of including template directly in original method while still using helper method "heavy lifting"? appreciate can give! this first came mind - i'm not sure much, i'm not sure of generic alternative. captures of current variables get_defined_vars() , , passes them render...

actionview - Best way to test a rails view helper without rails -

i making gem defines framework agnostic helpers generating html. testing under sinatra trivial. need test heplers rails erb , haml rendering without having require full stack? i guess @ point have require 'action_view' , 'action_view/renderer/renderer'

animation - jQuery gallery scrolling effect with ease -

so, got page friend , think gallery amazingly done. bad it's in flash ; http://selected.com/en/#/collection/homme/ now, i'm trying replicate effect jquery. i've made loco searches on google 1 think of. zooming picture not problem, problem lies within scrolling, how come @ ease part. i'm looking solution in how make thumbnail animate when scroll page, drag behind , infront of each other in subtle way - i've got (with lot of whirl3d in jquery-irc channel) scrollup/down part of mouse scrolling goes haywire; i thought post here i've come many times answers lot of questions , code-errors. first post in stackoverflow , know guys geniuses! give shot! in advance! jquery part $(document).ready(function() { var fronts=$(".front"); var backs=$(".back"); var tempscrolltop, currentscrolltop = 0; $(document).scroll(function () { currentscrolltop = $(document).scrolltop(); if (tempscrolltop < currentscrolltop) { //scroll...

Why do two regex literals in my Javascript vary on a property? -

i read in javascript: parts douglas crockford javascript regular expression literals share same object. if so, how come these 2 regex literals vary in lastindex property? var = /a/g; var b = /a/g; a.lastindex = 3; document.write(b.lastindex);​ js fiddle 0 outputted opposed 3. section 7.8.5 of ecmascript documentation makes quite clear 2 different objects: 7.8.5 regular expression literals regular expression literal input element converted regexp object (see 15.10) each time literal evaluated. 2 regular expression literals in program evaluate regular expression objects never compare === each other if 2 literals' contents identical. regexp object may created @ runtime new regexp (see 15.10.4) or calling regexp constructor function (15.10.3).

zend framework - Understanding the application.ini and the bootstrap -

i have been trying figure out quite while, exact difference between application.ini , bootstrap file in zend project? both seem used add resources, helpers, etc. not quite understand difference between adding in bootstrap or adding trough application.ini. benefit of either approach against other? is there explain me? the configuration set out in application.ini drives built in (and 3rd party or custom built) application resource plugins . limited resource plugins can config settings. any code in bootstrap class meant offer more fine-grained customisation. here can you're able put php code.

mixins - Using a LESS variable as a property instead of a value -

i've made following 2 mixins: .responsive_color(@color, @response_color, @speed: 0.1s){ color: @color; .transition(color, @speed); &:hover, &:active, &:focus{ color: @response_color; } } .responsive_background(@color, @response_color, @speed: 0.1s){ background-color: @color; .transition(background-color, @speed); &:hover, &:active, &:focus{ background-color: @response_color; } } since these 2 identical want combine them this: .responsive(@property, @color, @response_color, @speed: 0.1s){ @property: @color; .transition(@property, @speed); &:hover, &:active, &:focus{ @property: @response_color; } } while doesn't cause errors in less parser (php class) ignored. i've tried @{property} , '@{property}' both of these cause errors. does know how can output @property parsed? ...

c# - Access Attributes of object inside a dictionary -

i working on winforms application using c#. have dictionary specific objects, object have attributes id , doctype. how can access attributes of every object in foreach statement. trying following code not working. pls? foreach (var doc in crs.docdictionary) { console.writeline( doc.id); console.writeline(doc.doctype); } if foreach on dictionary sequence of keyvaluepair<tkey,tvalue> ; try: foreach (var doc in crs.docdictionary.values) { console.writeline(doc.id); console.writeline(doc.doctype); } or: foreach (var pair in crs.docdictionary) { console.writeline(pair.key); console.writeline(pair.value.id); console.writeline(pair.value.doctype); }

jquery - KnockoutJS unable to parse bindings when using RequireJS -

i have 2 select lists. second 1 should populated depending on value of first , data returned ajax request: <select id="parent" data-bind="options: parentoptions, value:selectedparentoption, optionstext: 'parent_name'"></select> <select id="children" data-bind="value:selectedchildoption, visible:haschildoptions"> <!-- ko if:haschildoptions --> <!-- ko foreach: children --> <option data-bind="text: child_name, option:$data"></option> <!-- /ko --> <!-- /ko --> </select> i had working before, trying abstract functionality separate modules requirejs: // viewmodel module define(["knockout", "ajax"], function(ko, ajax) { return function viewmodel() { self = this; self.parentoptions = ko.observable(); self.selectedparentoption = ko.observable(); self.haschildoptions = ko.computed(funct...

c linux multithreading networking -

i have network application on gateway. receives , sends packets. of them, gateway acts router, in cases, can receive packets too. should have: only 1 main thread a main thread + dispatch thread in charge of giving correct flow handler as many threads there flows something else. ? doing multithreading correctly no simple matter, in many cases select , friends based solution whole lot easier create.

javascript - Calling DOM objects using Java's ScriptEngine or WebEngine classes -

is possible modify html elements using scriptengine or webengine classes java? i've tried following: /* thesite webengine object. assume id 'email' correct */ element email=(element) thesite.executescript("document.getelementbyid('email');"); email.setattribute( "value", "navon.josh" ); i saw in example, didn't seem work. tried this: final scriptenginemanager manager = new scriptenginemanager(); final scriptengine engine = manager.getenginebyname( "js" ); try { engine.eval( "document.getelementbyid( 'email' ).value = 'navon.josh'" ); } catch( scriptexception e) { e.printstacktrace(); } this didn't work. because statement isn't linked webengine? to access dom model of html loaded javafx 2 webview can use webengine api. e.g. here example of adding listener html textarea: webengine webengine = webview.getengine(); webengine.getloadworker().stateproperty().addli...

java - How do JTA Transaction Managers deploy at runtime? -

trying wrap head around jta , have arbitrarily chosen bitronix impl because documentation easier (as opposed atmikos makes sign-up , register in order @ src/docs/jars/etc.). if want use bitronix jta implementation (using tomcat & glassfish), basic architecture (which may basic architecture of jta itself)? is transaction manager actual server/runtime connect (like jms broker)? or api can configure , hit whenever need transaction? my understanding of jta there is: your code a resource manager - adaptor acid-compliant persistence (like datastore or message broker) a transaction manager - manages transaction api calls between code , resource manager is bitronix transaction manager , if separate application, separate jar/war has deployed alongside yours, or run "embedded" inside app? in advance! it runs embedded inside tomcat, , accessible through jndi, other jta transaction managers. whole process of embedding bitronix tomcat described here . note t...

java - Game Crashes when adding to array or linker List -

so i'm having issue adding arraylist or linked list (tried both, each crash same). i'm working off of andengine tutorial (jimvaders, worked fine), when adapting own project, isn't working properly. basically, when shoot bullet, gets added list of bullets, in project, trying touch arraylist or linkedlist, located in gamescene, playerchar class causes whole game crash. haven't done list yet, it's act of adding playerbullet list causing problem far can tell. gamescene: public arraylist<playerbullet> bulletlist; in playerchar class public void shoot(int playerfacing) { //todo gamescene scene = (gamescene) baseactivity.getsharedinstance().getcurrentscene(); float shootx = 2; playerbullet b =(playerbullet)playerbulletpool.sharedbulletpool().obtainpoolitem(); if (playerfacing == -1){ shootx *= -1; } else{ shootx += this.getwidth(); } b.sprite.setposition(this.getx() + shootx, this.gety()+(this.getheight...

php - The method is there, but I cannot use it? -

fatal error: call member function get() on non-object on pr($transaction->invoice->get()); i getting weird message. know sure method there, , available use, , double checked before using it. what's wrong here? pr(get_class_methods($transaction->invoice)); array ( [0] => __construct [1] => [2] => __tostring [3] => gethref [4] => sethref [5] => _get ) update: var_dump(is_object($transaction->invoice)); evaluated bool(true) none of methods work. i'm confused! think 1 of edge cases. i'm using recurly library. update looks objects coming un-instantiating themselves. that's weird. didn't know php this. what experience here magic . magic hard understand, it's harder debug. expect large chunk of recurly php library based on magic. looks objects coming un-instantiating themselves. that's weird. didn't know php this. it's not php, library. makes use of magic getters ...

c# - How to setup a BeginXXX EndXXX method call with moq? -

let's have apm (beginxxx, endxxx) pattern async methods (as part of wcf service proxy i'm calling): public interface isomeservice { iasyncresult beginsomemethod(int num, asynccallback callback, object state); int endsomemethod(iasyncresult ar); } my actual code uses uses task.factory.fromasync create task, , awaiting task using new async/await pattern introduced in .net 4.5. i test class , need write method receives mock, begin method, end method , return value , sets mock return required return value. example usage: setupasync(mock, mocked => mocked.beginsomemethod, mocked=> mocked.endsomemethod, 7); which cause async flow int argument return 7. cannot seem figure out how accomplish such thing in moq. first, recommend use taskwsdlimportextension create task -based asynchronous wcf proxies. vs2012 default, have set yourself on vs2010+asyncctp. it's easier unit test against task api. if want unit test against begin / end , think ...

c# - How can I find that a record successfully deleted from Db using LINQ -

i'm using linq-to-sql, , wrote block delete record in database. executenonquery returns integer value, , value can find if record deleted or not. how can linq? example in code: aspnetdbdatacontext aspdb = new aspnetdbdatacontext(); var res=from p in aspdb.trackpoints p.routefk==routeid select p; aspdb.trackpoints.deleteonsubmit(res.first()); aspdb.submitchanges(); system.data.linq.changeset cs = aspdb.getchangeset(); bool isdeleted = cs.deletes.count() == 0; here if cs.deletes equal 0 means has been ok , row deleted if greater zero, mean there records have not been deleted successfully

c - "Undefined reference to function" error -

i having trouble compiling few files using headers. here breakdown of code: file1.c #include "header.h" int main() { func1(); return 0; } file2.c #include "header.h" void func1() { ... function implementation ... } header.h void func1(); error getting is: in function 'main' : undefined reference 'func1' note: using simple breakdown of how 3 files set up. need work 3 files. setting/including properly? need use set up, unsure how file.c gets reference implementation of func1() . if error undefined reference func1() , and there no other error , think it's because have 2 files called header.h in project , other copy being included instead of copy declaration of func1() . i check include paths project , make sure header.h declaration of func1() being included first.

javascript - How to choose between `window.URL.createObjectURL()` and `window.webkitURL.createObjectURL()` based on browser -

from firefox developer website, know firefox uses objecturl = window.url.createobjecturl(file); to url of file type, in chrome , other webkit browsers have window.webkiturl.createobjecturl() detecting url. i don't know how swap functions based on browser engines, , need worked on both browsers (chrome , firefox) https://developer.mozilla.org/en/dom/window.url.createobjecturl you define wrapper function: function createobjecturl ( file ) { if ( window.webkiturl ) { return window.webkiturl.createobjecturl( file ); } else if ( window.url && window.url.createobjecturl ) { return window.url.createobjecturl( file ); } else { return null; } } and then: // works cross-browser var url = createobjecturl( file );

c# - reading the result of LINQ query using Datarow -

how can read reult of linq query row row .(is possible)? want implemente 1 doesn't possible: aspnetdbdatacontext aspdb = new aspnetdbdatacontext(); var res = r in aspdb.routelinqs r.userid == userid select r; foreach (datarow row in res) { // ... an exception thrown: cannot convert type 'quickroutes.dal.routelinq' 'system.data.datarow' edit: in foreach block have: foreach (var row in res) { var routeid = (int)row["routeid"]; var route = new route(routeid) { name = (string)row["sourcename"], time = row["creationtime"] dbnull ? new datetime() : convert.todatetime(row["creationtime"]) }; route.trackpoints = gettrackpointsforroute(routeid); result.add(route); } if use var error in lines occure: cannot apply indexing [] expression of type 'quickroutes.dal.rout...

java - SwingWorker hangs at Unsafe.park() -

i have swingworker communicates server in background , updates jframe . debugging app , noticed after swingworker finished work, thread still remained. hanging @ unsafe.park(java.lang.object) native method. looked in further , found other swingworker s in app same thing after finish. can provide source code if wants don't think necessary because problem seems general. update i ran app without debugger , problem still happening. dump of swingworker thread: "swingworker-pool-2-thread-1" daemon prio=6 tid=0x03219800 nid=0xd74 waiting on condition [0x04b7f000] java.lang.thread.state: waiting (parking) @ sun.misc.unsafe.park(native method) - parking wait <0x22ec63d8> (a java.util.concurrent.locks.abstra ctqueuedsynchronizer$conditionobject) @ java.util.concurrent.locks.locksupport.park(unknown source) @ java.util.concurrent.locks.abstractqueuedsynchronizer$conditionobject .await(unknown source) @ java.util.concurr...

Symmetrical many-to-many in Django admin screen -

i have symmetrical many-to-many relationship in django class person(models.model): id = models.charfield(max_length=32, primary_key=true) first_name = models.charfield(max_length=32) last_name = models.charfield(max_length=32) connections = models.manytomanyfield('self', blank=true) how see connections (i.e. myappname_person_connections) table in admin screen (not inline own table)? e.g. in admin.py admin.site.register(person) admin.site.register(???) # register connections? thanks the m2m table mapped model person.connections.through , use admin.site.register(person.connections.through)

vba - Excel: Contents of the last previous non-empty cell in a column (above active cell) -

i have column can contain number of blank cells in row. whether cell blank or not depends in complex way on contents of several other columns. if cell not blank, should contain 1 plus contents of last previous non-blank cell (i.e lowest non-blank cell above in same column). need update these numbers dynamically. how find value of last previous non-blank cell in column? i prefer formula, willing use vba approach if there no workable formula approach. i grateful get. a vba user-defined function: function prevplus() application.volatile prevplus = application.caller.end(xlup).value + 1 end function

asp.net - ServerVariables["REMOTE_HOST"] returns internal IP? -

since changing server hosting new provider (ovh), don't manage client's ip using simple request.servervariables["remote_host"] . returns 10.0.1xx.2xx (masked exact value, don't know if matters) seems internal server ip me. calling request.servervariables["remote_addr"] , request.servervariables["local_addr"] gives same results. the code called withing global.asax if relevant. any idea ? i've had same problem today ovh. seems request.servervariables["http_remote_ip"] return ip

dojo - Refresh enhaced grid preserving client side filter -

how can refresh enhanced grid after filter in applied, preserving filter query?? doing grid.setfilter() clears filter. there way access active filters in grid give grid.setfilter(activefilters)????? hmm..... got answer myself, its grid.getfilter() gives current filters grid.setfilter(grid.getfilter()); refreshes grid current filters.. that simple :)

Outputting dynamic php content from a drupal 7 module -

i've written module in drupal 7 output overview page project management application. im not sure how reference php variables in block out put. block content displayed through main content area. i thought might able (i.e. fullpath represent path image change dynamically based on returned db query). $block['content'] = ("<div><p>overview stuff <?php echo $fullpath?></p></div>"); however php element doesn't come through , don't think that's proper way anyway. i've not yet had experience .tpl.php files might way go. i've checked on google solution , going through docs not found yet. can give me idea of how should go this? many thanks peter i like $block['content'] = array( '#markup' => t('overview stuff') . ' ' . $fullpath, '#prefix' => '<div><p>', '#suffix' => '</p></div>', ); ...

iphone - How to draw Custom lines on touch move in Cocos2D in iOS? -

i developing puzzle game. in game have draw custom lines on touch began touch end points. searched lot, tutorials or links tell how can use drawline method line drawing. drawing line on touches moved in cocos2d 1 of them, want draw custom lines on background sprite. 1 can tell me there method in cocos2d use texture image line drawing. if possible please refer me link. try using ccribbon draw textured line edit expand i thought i'd looked :-) code should adaptable needs non ccribbon method (though won't smooth multiple ccribbon's)

javascript - Backbone.js: Passing value From Collection to each model -

i need pass value view each models inside collection, while initializing. till collection can pass 'options' in backbone.collection constructor. after this, there technique can pass 'options' each models inside collection? var song = backbone.model.extend({ defaults: { name: "not specified", artist: "not specified" }, initialize: function (attributes, options) { //need some_imp_value accessible here }, }); var album = backbone.collection.extend({ model: song initialize: function (models, options) { this.some_imp_value = option.some_imp_value; } }); you can override "_preparemodel" method. var album = backbone.collection.extend({ model: song initialize: function (models, options) { this.some_imp_value = option.some_imp_value; }, _preparemodel: function (model, options) { if (!(model instanceof song)) { model.some_imp...

ios - Migration from Android to iPhone -

we developed android app using phonegap , jquery mobile, , want operational on iphone. want know how can convert , tools should use. get mac, install xcode app store , code away. if android app written in c/c++ can run code little changes on ios. if used java however, you'll have rewrite lot of in objective-c.

html - SVG use element refering external file doesn't work in Safari -

i have html file inline svg, in turn refers svg elements in external svg file library elements. uses <use> elements xlink:href="library.svg#libraryshapeid" . works breeze in opera , firefox, doesn't work in safari. i've made simple test file here: http://sasq.comyr.com/stuff/svg/test01.html is browser bug or doing wrong? how should rewrite make work in safari too? there bug on webkit has been fixed version: 420+ bug fragment identifier still not solved. someone gave answer: importing external svg (with webkit) using xmlhttprequest. quite unfortunate in meantime, guess working.

actionscript 3 - Flash as3 - Create a variable from instance on click event -

i have whole bunch of buttons need have both mouse on effect toggle effect (on click) changes hue. have made functions each hue change , parts works quite well. sadly cant figure out how toggle function work how supposed to. below code toggle button. works fine, except variable global instead of specific instance. therefor works if have 1 button. how can change use variable 1 button in focus? thanks in advance! var primary = false; function clickon(e:mouseevent):void{ if (primary == false) { greenhue(e.target); primary = true; } else { nohue(e.target); primary = false; } } the best thing extend class used buttons , add functions it, buttons derive have idependant behavior want. class coloredbutton extends button { var primary = false; public function coloredbutton() { this.addeventlistener(mouseevent.click, clickon); } private function clickon(e:mouseevent):void { ...

.net - Jenkins and maven npanday builds failed -

[update , solutions on response below] i using npanday, project build .net projects using maven. after load of steps have figured out how compile/install projects using maven. this work right on command console or visual studio, once jenkins try compile maven fail build it... following failure output jenkins: ------------------------------------------------------------------------------------ mavenexecutionresult exceptions not empty message : failed execute goal org.apache.npanday.plugins:npanday.plugin.settings.javabinding:1.5.0-incubating-snapshot:generate-settings (default-generate-settings) on project consoleapplication400: npanday-115-010: error on resolving plugin artifact(s) cause : npanday-115-010: error on resolving plugin artifact(s) stack trace : org.apache.maven.lifecycle.lifecycleexecutionexception: failed execute goal org.apache.npanday.plugins:npanday.plugin.settings.javabinding:1.5.0-incubating-snapshot:generate-settings (default-...