Posts

Showing posts from July, 2013

c# - How can i reconnect an entity dataset inside using statement when a SQLException occurs? -

the situation have long running method looping through thousands of rows , doing processing , updates. loop nested inside using statement. the problem when came work in morning see connection failed @ 8pm sqlexception , lost 12 hours of processing time. how can reconnect , continue processing loop programatically? my idea this: using (var _data = new my.ef.myentities()) { (int = 1; < 17348; i++) { try { //do lots of stuff } catch (sqlexception ex) { writelogfile("error @ id" + i.tostring(), ex); i--; if (_data.database.connection.state != system.data.connectionstate.open) { _data. // what? nothing looks useful here reconnect } } } } this dev code, not production or user environment. i'm doing seeding database 10'000's of records , linked records idea load testing, i'm not programming possibilitie...

MS Access (OLEDB) UPDATE Table under multiple conditions -

hello , apologies seeming simplicity of question some, mediocre programmer @ best , dealing critical data here. i trying update 1 column (parchivestatus) in table (image) depending on whether status (parchivestatus) ((100 or 200) , ((timestamp>'2014-11-14 00:00:00') , (timestamp<'2016-02-05 00:00:00'))) in each row. ('captured' name of timestamp column) anything before , after 2 dates cannot touched i have come 2 variations, neither of work (lol) a little nudge in right direction highly appreciated. variation update [image] set [parchivestatus]='0' [parchivestatus] = 100 and [captured] between '2014-11-14 00:00:00' and '2016-02-05 00:00:00'; variation update [image] set [parchivestatus]='0' [parchivestatus]=100 and [captured]>'2014-11-14 00:00:00'; and friend told me this 3. variation update (select * image parchivestatus = 100) set parchivestatus=0 captured between '2014-11-14 00...

javascript - Making a copy of JS object an changing the occurrence of a given key -

i have few js objects. can have structure: { name: "first", _ref_id: 1234, spec: { _ref_id: 2345, data: "lots of data" } } { name: 'second', _ref_id: 5678, container: { _ref_id: 6789, children: [ {_ref_id: 3214, name: 'bob'} {_ref_id: 1111, name: 'mark'} {_ref_id: 2222, name: 'frank'} ] } } problem: i need make copies of object different _ref_ids. creation of 'first' object this: first = { name: "first", _ref_id: uuid.v4(), spec: { _ref_id: uuid.v4(), data: "lots of data" } } so know structure of object when creating further down chain in place trying make copy of object don't have access , don't know structure of object have object self. after coping 'first' have: { name: "first", _ref_id: 8888, spec: { _ref_id: 9999, data: "lots of data" } } i tried instead of def...

Jenkins NUnit plugin lacks useful info -

we have implemented integration tests using nunit under jenkins , have used nunit plugin produce report output. output devoid of useful info, error messages , console output. doing wrong? the test uses following, names changed protect innocent. "c:\program files (x86)\nunit 2.6.4\bin\nunit-console.exe" "d:\public\data\sweb\enterprisetesting\enterprisetesting.library\bin\debug\enterprisetesting.library.dll" /run:enterprisetesting.library.tests.ordertest /xml:d:\public\data\sweb\enterprisetesting\enterprisetesting.library\bin\debug\testresult.xml any ideas other using reportunit? thanks

Inherited class from another module in Typescript -

i trying extend abstract class class, more convenience need have abstract class in file. unfortunately throws me runtime error struggle understand. this works : abstract class item{ constructor(){ console.log("i item"); } } export class folder extends item{ constructor(){ super(); } } log : i item this doesn't : module mymodule{ export abstract class item{ constructor(){ console.log("i item"); } } } export class folder extends mymodule.item{ constructor(){ super(); } } compiles throws : uncaught typeerror: cannot read property 'prototype' of undefined does understand going on ? a top-level export ( export class folder in case) in source file means typescript treat file external module, though unless specify module format when compiling typescript should have emitted error ts1148: cannot compile modules unless '--module' flag provided...

javascript - trigger click event on parent with bubbling -

i want manually fire click event on parent container dispatchevent . event bubbling not seem work. // trigger click event on parent container parent.dispatchevent(new mouseevent("click", { bubbles: true, cancelable: true, view: window, clientx: 4, clienty: 4 })); ... child.addeventlistener('click', function(e) { alert('click') }, false); see fiddle: https://jsfiddle.net/o4j0cjyp/2/ events bubble or not @ all. way know bubble down elements in targeted element, , iterate on collection dispatching event on of them, of them, or whatever situation needs. bad if not tell event not bubble end in infinite loop. a better way go goal use event delegation, use common parent event listener element. when event happens check event target, if 1 want whatever work. so html <div id="parent-container"> <div id="child-container"> area has click listener </div> </div> <div ...

machine learning - How to transform (calculate) two or several variables into one using R? -

i'm having difficulties merging 2 or several variables in data. i'm able in excel can't figure out how perform same thing in r. basically want create 2 combined variables using variables below: data1: creating variable combinea+b country year a1 b1 **combinea1+b1** usa 2002 0 0 0 usa 2003 1 1 2 usa 2004 na 1 1 usa 2005 0 0 0 usa 2006 0 1 1 usa 2007 0 0 0 usa 2008 0 1 1 usa 2009 na na na usa 2010 0 1 1 usa 2011 na 0 0 usa 2012 0 1 1 usa 2013 0 0 0 usa 2014 0 1 1 creating variable "combinea1+b1" seems simple, need add 2 (a1 , b1). in exce...

How to dock chrome developer console on the LEFT? -

Image
i'm aware can click vertical ellipsis button ( ⋮ ) , choose dock on bottom, right or detach. know how dock on left? currently have detach , manually resize , adjust, annoying. edit: i'll leave question open until either convinces google add left docking, or figures out hack/finds or builds extension work. edit 2: issue solved. google added in latest standard chrome release (v. 58) i realise old post, it's first result in google docking left released in chrome 58 (which came out yesterday). go forth , dock left!

ellipse - Build a control within a circle/elipse on windows phone -

i want use circle/ellipse design element around custom control (three text blocks) on windows phone. having trouble finding examples. seems should rather simple. i want make control little more complex adding select boxes 2 of text blocks. think of selecting minutes , seconds , running timer circle around differentiate other controls on page.

matlab - Improve memory-inefficient script -

i have create probabilistic voxel map 5 individual maps binary maps containing either 1 or 0. let's call these individual maps x1, x2, x3, x4, x5 . probabilistic map y = (x1 + x2 + x3 + x4 + x5)/5 . thus, each voxel give me percentage of individual maps having 1 value voxel. instance, if value of voxel in y 0.4, tells me 40% of individual maps (2 individual maps) have 1 value particular voxel. issue have when number of individual maps increases, script becomes bulky. have maindir=<where individual maps are> p={}; subj={'subj1','subj2','subj3','subj4','subj5'} = 1:length(subj) indv_roi=spm_select('fplist',fullfile(maindir),sprintf('^%s.*\\.img$',subj{a})); p.(subj{a}) = spm_read_vols(spm_vol(indv_roi),1); p.(subj{a})(isnan(p.(subj{a})))=0; end y = (p.subj1+p.subj2+p.subj3+p.subj4+p.subj5)/5 clearly inefficient. have suggestion how improve code? thank you. i presume memory bottleneck? instead ...

css - How to create a CSS3 animation that resembles an image fill up effect? -

many preloaders fill image bottom top this example . how 1 create animation based off single image in css show fill effect? have tried following code produces image sliding effect , not fill effect. by fill effect mean actual image fills frame (like water filling tank). .frame { position: relative; height: 600px; width: 300px; overflow: hidden; border: 1px solid; } .frame img { position: absolute; top: 100%; animation: fill-up 3s ease infinite; } @keyframes fill-up { { top: 0px; } } <div class='frame'> <img src='http://buildinternet.com/live/imagefill/dude.jpg' /> </div> note: images used in answer not own . taken build internet site . creating image fill-up animation similar 1 available here (that uses jquery animation) possible using css3 animations. needs 2 containers image , height of 1 animated 0 full height. the following how animation created: one parent cont...

Android - Layout in JAVA File -

as per requirement, should give orientation in horizontal only, if give 3 sentences in 3 text views, if there no space third sentence should come in next line in first position ... public class mainactivity extends activity { private linearlayout layout; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); findviewbyid(); linearlayout.layoutparams layoutparams = new linearlayout.layoutparams(layoutparams.wrap_content,layoutparams.wrap_content); layoutparams.setmargins(10, 15, 10, 10); layout.setorientation(linearlayout.horizontal); android.view.viewgroup.layoutparams params; textview tvtextsecond = new textview(this); tvtextsecond.settext("heywhatrudoingtoday"); tvtextsecond.setlayoutparams(layoutparams); tvtextsecond.setbackgroundcolor(color.red); tvtextsecond.settextcolor(color.white); textview tvtextthird = new textv...

addition - Why decimal add up incorrectly in mysql -

i want retrieve data based on condition in database : select * `chatroom` 5.27680128733988 + 100.488135965769 = 105.764937253109 this produced 0 result when there know value of addition 105.764937253109 to prove addition equals 105.764937253109 update 1 of row table correct value : update `chatroom` set `latitude`= 5.27680128733988 + 100.488135965769 room_id = 2 the updated column shows result of addition 105.764937253109 why when try select results in first database query, shows 0 data found? thank you because 5.27680128733988 + 100.488135965769 = 105.7649372531089; you're missing "8"

c++ - Is "typedef" in between the type and the alias standard-conformant? -

i stumbled upon code typedef keyword in between type , alias name in int typedef int; it compiles in gcc , clang ( live example ). not in understanding standardese. question is: standard conformant? can rely on compilers support it? tl/dr version yes, int typedef int conforming. james michener version c declaration syntax ( c 2011 online draft ): 6.7 declarations syntax 1     declaration :          declaration-specifiers init-declarator-list opt ;          static_assert-declaration      declaration-specifiers :          storage-class-specifier declaration-specifiers opt          type-specifier declaration-specifiers opt          type-qualifier declaration-specifiers opt        ...

internet explorer - filepicker in IE10 and IE11 browse file makes page unresponsive -

this first question ever asked on stackoverflow: using filepicker jquery library - ie9 works great, in ie10 , ie11 if "choose file" button pushed , picture gets uploaded way rest of form/page unresponsive @ least minute no matter size of image. after minute wait time people can type form on page , type input fields, not before. if drag , drop image dialogue window rest of form/page works great (no lag/unresponsiveness). through testing: ie9 works great, other browsers (firefox, chrome, safari) seem work fine. ie11's debugger doesn't tell me useful. has else experienced , if how did solve it? from i'm seeing looks code (we use filepickers version through api <script type="text/javascript" src="//api.filepicker.io/v1/filepicker.js"></script> ) implemented correctly (though being pulled onto page dojo). some of our code proprietary/intellectual property i'm pretty sure i'd trouble if posted it. looking out in wi...

php - SilverStripe SQL boolean value syntax error -

i trying return sql query code below. reason boolean values i'm trying filter ('showonhomepage' , 'published') throwing following syntax error due question mark placeholder. you have error in sql syntax; check manual corresponds >your mysql server version right syntax use near '?) , ("dummycontentone"."showonhomepage" = ?)) "dummycontentone" union (s' @ line 5 public function getsitecontent() { if($this->_contentlist!=false) { return $this->_contentlist; } $request = (controller::has_curr() ? controller::curr()->getrequest() : null); $start = round(($request ? intval($request->getvar('start')) : 0)); $dummycontentone = dummycontentone::get()->filter('published', true)->filter('showonhomepage', true)->dataquery()->query()->setorderby(null); $dummycontenttwo = dummycontenttwo::get()->filter('published', true)->filter(...

c# - How to match or list exactly using RegEx -

pattern: ^(?!test|abc).*$ i not want match test or abc only, matches test123 what need add make stop @ end? you need use end anchor in lookahead well: ^(?!(?:test|abc)$).*$ then, not match test , abc whole strings, match test123 . here regex demo (using pcre engine since work same in .net 1 expression). to apply $ end-of-string anchor both test , abc , need group them, suggest using non-capturing group (or use capturing 1 regexoptions.explicitcapture ).

ios - tab bar item not showing in storyboard -

Image
i'm trying add tab bar controller on application, , works fine: can switch between pages , use tab bar when try app. cant see tab bar items in storyboard, therefore cant edit them (i need set name , icon each item, "home", "settings"). here's picture of storyboard: as can see tab bar gray, , i'm expecting can see items: have tried dragging tab bar item object library view controllers? looks that's what's missing.

database - Ms Access move from one field to other -

i converted pdf file access one. of info got put in 1 field. need them in 6 different fields. how can move them easily? text types. i suggest export data in excel use text column command. after extracting data separates columns (have same structure of access table) have import excel file access.

paypal - INVALID_RESOURCE_ID when Authorization.Capture is called on an authorized payment using sandbox account -

i using paypal.1.6.0\lib\net45\paypal.dll i created payment authorize intent , have authorized authid ( payment.cart ) , paypal.api.payment.id . when try call authorization.capture(apicontext, capture) authid , get { "name":"invalid_resource_id", "message":"the requested resource id not found", "information_link":"https://developer.paypal.com/webapps/developer/docs/api/#invalid_resource_id", "debug_id":"d73f6a0c1b8bc" } i tested using sandbox account. trying link gets me 'page not found error'. clues? i realized looking @ wrong 'authorization code'. not ((payment)executedpayment).cart posted in original question ((payment)executedpayment).transactions.firstordefault().authorization.id i able use correct authcode , able capture authorization. executedpayment return value payment.execute method.

asp.net core - Convention based approach for configuring services based on Operating System in Startup.cs -

i created asp.net service using 1.0.0-rc1-update1 on coreclr (x64). so, service capable of running on supported operating systems; cool! service exposes simple "todo" api , uses entity framework 7.0 orm. persistence, employs sqlite db on linux , sql server db on windows. i wondering if there convention based approach allow startup.cs handle differing service configurations various operating systems? example, ef configuration differs because uses sqlite on linux , sql server on windows. the following article detail convention based approaches configuration, seems allow different methods higher level abstractions of "development", "staging", "production" environments: https://docs.asp.net/en/latest/fundamentals/environments.html currently, injecting iruntimeenviroment in constructor of startup.cs , saving it. then, when configureservices invoked, check operatingsystem property of iruntimeenvironment , adjust ef configuration accordingly (...

inheritance - C# explicit cast superclass to derived class and get specific variables -

i have abstract class, tile. have class, webtile, inheriting tile-class. webtile have private string html , tile not have. public abstract class tile { private string name; private string description; public string name { { return name; } } public string description { { return description; } } protected tile(string name, string description) { this.name = name; this.description = description; } } public class webtile : tile { private string html; public string html { { return html; } } public webtile(string name, string description, string html) : base(name, description) { this.html = html; } } i have method returns list of tiles (list<tile>) i loop through list, , cast tiles of type webtile webtile. and want html-string. has become empty after cast?! missing? foreach (tile tile in xmlparser.gettiles...

opengl es - Android: Attach SurfaceTexture to FrameBuffer -

i performing video effect requires dual pass rendering (the texture needs passed through multiple shader programs). attaching surfacetexture gl_texture_external_oes passed in constructor not seem solution, since displayed result rendered once. one solution aware of first rendering can done framebuffer, , resulting texture can rendered gets displayed. however, seems surfacetexture must attached gl_texture_external_oes texture, , not framebuffer. i'm not sure if there workaround around this, or if there different approach should take. thank you. surfacetexture receives buffer of graphics data , wraps "external" texture. if helps see source code, start in updateteximage() . note name of class ("glconsumer") more accurate description of function "surfacetexture": consumes frames of graphic data , makes them available gles. surfacetexture expected work formats opengl es doesn't "naturally" work with, notably yuv, uses ex...

mondrian - Snowflake schema with multiple levels -

one of dimension in schema modeled snowflake schema following table structure: fact table -> criteria_value -> criteria -> domain mondrian schema: <dimension type="standarddimension" foreignkey="id_value" highcardinality="false" name="researched value"> <hierarchy name="researched value" hasall="true" primarykey="id_va" primarykeytable="criteria_value"> <join leftalias="criteria_value" leftkey="id_va" rightalias="criteria" rightkey="id_c"> <table name="criteria_value"> </table> <join leftalias="criteria" leftkey="id_c" rightalias="domain" rightkey="id_domain"> <table name="criteria" alias=""> </table> <table name="domain" alias=""> </table> ...

jquery - can't find variable '$' on compute engine -

i created trial google compute engine, , finished setting experimental node web app i've been working on. app works fine on computer, on compute engine, complains missing $ jquery variable. my index.ejs file looks this: <html> <!-- header stuff --> <body> <!-- body stuff --> <script src='https://fb.me/react-0.14.5.js'></script> <script src='https://fb.me/react-dom-0.14.5.js'></script> <script src='http://code.jquery.com/jquery-2.1.3.js'></script> <script src="/javascripts/bundle.js"></script> </body> </html> jquery linked before bundle.js the problem in bundle.js file (which browserify bundle used bundle react components, 1 of uses jquery ajax $.ajax error is) link app running on compute engine: https://8080-dot-2015515-dot-devshell.appspot.com/?authuser=0 look @ console error. again, works fine on machine, not sure why complaining on...

How do I post a string to a MySQL database with PHP? -

i trying write simple application, allows me post simple string mysql database. error. doing wrong here? here attempt: <?php $servername = "xxxx.awardspace.net"; $username = "xxx"; $password = "xxx"; $dbname = "xxx"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql = "insert tokens (`token`) values (". $_post["token"].")"; if ($conn->query($sql) === true) { echo "new record created successfully"; } else { echo "error: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> when request: curl -i -x post \ -h "content-type:text/plain" \ -d \ 'token=neverlucky' \ 'http://myurl.mygamesonline.org/?token=teststring123' it returns: error: insert tokens ...

markdown - Lightweight markup language for HTML5 -

i've been using template toolkit + multi-markdown + perl scripts glue website. this combination has few problems: i still have ugly things like: <div class=picture_right> {link image} text caption with appropriate styling picture_right. to ensure text processed inside <div> tags, have add flag markdown="1" div . seems end raft of surplus <p> tags wrapping things. keeps output validating properly, otherwise seems harmless. i think html5 mature enough use output format. such things figure , article , footnote clearer <div class...> structures. i'm looking lightweight markup language has decent support use html5 in not cluttered way. ideally: customizable things like: h1 headlines automatically produce articles, h2 produce sections, customization , defaults can pulled in external file. (i'm learning possibilities of html5.) all in all, you're trying want learn html5. suggest head first htm...

javascript - Onclick current date and time in datetime-local input -

i trying current date , time on datetime-local input field , using onclick method. i have tried using moment.js , other libraries this, reason, cannot translate current datetime-local field. doing wrong? i decided go basics jquery alone , manged far. if change input type text on input box, script works fine, if changed datetime-local, doesn't work. $( function(){ $('#time').click(function(){ var time = new date(); $('#time-holder').val(time.todatestring()); }); } ); jsfiddle: jfiddle when use input type datetime-local . the date format must as: 'yyyy-mm-ddthh:mm:ss' e.g: "2014-11-16t15:25:33" $( function(){ $('#time').click(function(){ var time = moment().format('yyyy-mm-ddthh:mm:ss'); $('#time-holder').val(time); }); } );...

javascript - How to pass 2 arguments to jquery Find() method -

i have created table displays data, when user click on update button turns table cells input field user can enter data.. when click on edit button changes 1 cell of table input field, unable understand how change other cells of table, need change cells of table in single click. $(document).on("click", ".updateuser", function() { $(this).closest('tr').find('td:nth-child(2)').each(function() { var html = $(this).html(); var input = $('<input type="text" />'); input.val(html); $(this).html(input); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <table class="table table-hover"> <thead> <tr> <th>#</th> <th>username</th> <th>password</th> <th>role</th> <th>e...

Group by Customer ID where Another Column is only Contains a specific set of Values -

wasn't sure how ask one. i have table 4 columns in it. pk, customerid, language, , date. customer id can same multiple rows in file. language numerical value 1-8 representing different languages. date first of given month. so, 10 rows in table, legitimate customerid 123 10 rows, language '1' ten rows, , date '1/1/2015' 10 rows. essentially, have lot of subsets in table pk create row level distinction. on trying do. need group customer id, 3 specific dates ('10/01/2015', '11/01/2015', '12/01/2015'), value found language 1. meaning, if on 10/01/05, customerid 123 has 10 rows , 9 language '1', , 10th row language '2', wouldn't want return in results. at end, need list of customer id's 3 dates have '1' there language , not have other languages in rows. this has gotten beyond skill. appreciate feel simpler making out be. i think should trick: select * table language = 1 , (date = date1 ...

symfony - generate:doctrine:crud not work -

in symfony 2.8 generated simple entity " demobundle:post ". if try recreate entity command: php app/console doctrine:generate:entity it tell me 'entity "demobundle:post" exist.' but if try generate crud command: php app/console doctrine:generate:crud it tell me 'entity "post" not exist in "demobundle" bundle.' so stupid think in symfony? try run php app/console doctrine:cache:clear-metadata . also verify have not deleted whole entity directory (keep empty if it). clear cache ( app/console cache:clear ) , re-try generate entity.

Flyway: unable to load custom config file in cmd line -

i created new config file called "compare.conf" & placed in 'conf' folder. when run below command, following error: ps c:\projects\learning\test\flyway-3.2.1> .\flyway -configfile=conf\compare.conf info flyway 3.2.1 boxfuse error: unable load config file: c:\projects\learning\test\flyway-3.2.1\conf\compare if run same command absolute url below, works fine. known issue in flyway? ps c:\projects\learning\test\flyway-3.2.1> .\flyway -configfile= c:\projects\learning\test\flyway-3.2.1\conf\compare.conf info

The checkbox is not worked ,in jquery -

hello: have problem whit checkbox ,i tried make button when it's checked enable otherwise it's disable it's not worked well, when chekcked enable when unchecked show button enable .looking forward yours help. $(document).ready(function(){ $('#agree').change(function(){ state = $('#agree').attr('value'); if ( state == 'on'){ $('#continue').removeattr('disabled'); }else if (state == '') { $('#continue').attr('disabled','disabled'); } }); }); you testing checkbox's value determine state. however, value not change (natively) when checked or unchecked. suggest referencing javascript's checked property, instead. see list of properties @ html input element . in example below, i'm using this.checked reference status of checkbox has triggered "change" event. i'm using ternary operator set button...

javascript - Create Associative array with unique keys -

i'm creating associative array (technically object) this, , keys should strings. var j = <?php echo $max_key ?>; var id = "ele"+j; eledetailstop[id] = {id: id, size : "100%", sizelabel : 12}; finally object stored in db json string. my problem generating value j. keys ele0, ele1, ele2... etc. so, value of j should +1 max value of stored keys in db. let's max value ele4 , next value of j should 5 . so, can generate new id ele5 how done ? var max = <?php echo $max_key ?>; var eledetailstop = []; (var id = 0; id < max; id++) { eledetailstop["ele" + id] = {id: id, size : "100%", sizelabel : 12}; }

javascript - popup an image and hide all index -

Image
i making game (learning , experimental purpose). want game show "popup" image when lose, tryed hide divs not working... want when lose image displayed in same screen, such facebook images or twitter, background fades , image shown. in game, when lose, added image seems this: function show_image() { var img = document.createelement("img"); img.src = 'images/firstblood.png'; img.width = 300; img.height = 300; // next line add <body> tag document.body.appendchild(img); } the function above called when lose in game. what want achieve more appending image html dom. i know want keep simple, sake of it, checkout angularjs' ngshow . hide or show elements in dom structure whenever want them to. a simple solution provided in this snippet of code . injects basic jquery library provides functionality show popup windows ease. follow code in snippet , should go.

c# - AutoMapper 4.2 and Ninject 3.2 -

i'm updating project of mine use automapper 4.2, , i'm running breaking changes. while seem have resolved said changes, i'm not entirely convinced i've done in appropriate way. in old code, have ninjectconfiguration , , automapperconfiguration class each loaded webactivator. in new version automapperconfiguration drops out , instead instance mapperconfiguration directly in ninjectconfiguration class bindings happening, so: private static void registerservices( ikernel kernel) { var profiles = assemblyhelper.gettypesinheriting<profile>(assembly.load("???.mappings")).select(activator.createinstance).cast<profile>(); var config = new mapperconfiguration( c => { foreach (var profile in profiles) { c.addprofile(profile); } }); kernel.bind<mapperconfiguration>().tomethod( c => config).insingletonscope(); kernel.bind<imapper>()....

c - How to update all the elements in a double array in X86? -

i newbie of x86 , stuck on updating double array using values of double array. following code function , want use inline assembly replace piece of code inside loop. have attached error message below. can helps me point out errors? confused error messages , don't know how revise it. static inline void update(double * x,double * y,double * z,double * vx, double * vy,double * vz,uint32_t size){ (uint32_t i=0;i<size;++i){ x[i] = x[i] + vx[i]; y[i] = y[i] + vy[i]; z[i] = z[i] + vz[i]; } } uint32_t counter = 0; __asm__ __volatile__ ( "loop: \n\t" "faddq (%4), (%1)\n\t" "faddq (%5), (%2)\n\t" "faddq (%6), (%3)\n\t" "addq $8, %1\n\t" "addq $8, %2\n\t" "addq $8, %3\n\t" "addq $8, %4\n\t" "addq $8, %5\n\t" "addq $8, %6\n\t" "incq %0\n\t" "cmp %0, %7\n\t" ...

C++ template function for method with a parameter of a const type or simply of type -

assuming have same body 2 template functions calling class methods, these: template <typename jstype, typename jsparamtype, typename paramprivatetype = jsparamtype::privatetype, void(privatetype::*method)(const paramprivatetype&)> static bool setbyrefmethod(jscontext *cx, unsigned argc, js::value *vp) { ... } template <typename jstype, typename jsparamtype, typename paramprivatetype = jsparamtype::privatetype, void(privatetype::*method)( paramprivatetype&)> static bool setbyrefmethod(jscontext *cx, unsigned argc, js::value *vp) { ... } i try write once body, right way make compiler use when called method has parameter const , when has parameter not const ? you don't need template types. first do. if can deduce rest of types using first templated type should fine. don't need private types in template if can deduced first template type. check out following code #include <iostream> using std::cout; using std::endl; ...

git - How to sftp into a GitHub repository -

i've changed os os x ubuntu, means can no longer use desktop github app. problem because host website off github , need way of uploading lots of different files, example .jars, onto website repository; used use desktop app i'm not sure how without it. thought maybe use filezilla sftp repository , upload there don't know how i'd that. possible? i try out smartgit linux client. i've had colleagues use on linux , it. http://www.syntevo.com/smartgit/ to answer question, sftp git isn't supported i'm aware of. ssh git little more common, route.

PHP readfile download timing out -

my php script keeps crashing/timing out, presumably because of readfile. goal generate zip, let user download it, , remove zip afterwards. code: <?php if(isset($_post['version']) && isset($_post['items']) && isset($_post['identifier'])) { $identifier = $_post['identifier']; $version = $_post['version']; $tmp = dirname(__file__) . "/download/"; $zipfile = $tmp . $identifier . ".zip"; $name = "program v" . $version . ".zip"; $path = dirname(__file__) . "\\download\\template\\" . $version; $files = new recursiveiteratoriterator( new recursivedirectoryiterator($path), recursiveiteratoriterator::leaves_only ); $zip = new ziparchive(); if ($zip->open($zipfile, ziparchive::create | ziparchive::overwrite) === true) { foreach ($files $name => $file) { // skip directories (they added automatically) if (!$file->isdir()) { // re...

javascript - How to unit test express Router routes -

i'm new node , express , i'm trying unit test routes/controllers. i've separated routes controllers. how go testing routes? config/express.js var app = express(); // middleware, etc var router = require('../app/router')(app); app/router/index.js module.exports = function(app) { app.use('/api/books', require('./routes/books')); }; app/router/routes/books.js var controller = require('../../api/controllers/books'); var express = require('express'); var router = express.router(); router.get('/', controller.index); module.exports = router; app/api/controllers/books.js // example controller exports.index = function(req, res) { return res.status(200).json('ok'); }; app/tests/api/routes/books.test.js var chai = require('chai'); var should = chai.should(); var sinon = require('sinon'); describe('bookroute', function() { }); code: ...

c - Aligning both source and destination address in memcpy -

i want write memcpy code word word copy instead of byte byte increase speed. (though need byte byte copy last or few bytes). want source , destination address aligned properly. saw implementation of memcpy in glibc https://fossies.org/dox/glibc-2.22/string_2memcpy_8c_source.html alignment destination address. if source address not aligned result bus error (consider alignment checking enabled in cpu) i'm not sure how make both source , destination aligned properly. because if try align source copying few bytes byte byte, change destination address, @ first destination address aligned @ first might not aligned now. there way align both?. please me. void memcpy(void *dst, void *src,int size) { if(size >= 8) { while(size/8) /* code give sigbus error if src = 0x10003 , dst = 0x100000 */ { *((double*)dst)++ = *((double*)src)++; size = size - 8; } } while(size--) { *((char*)dst)++ = *((char*)src)++; } } ...

TinyMCE. Replacing/adding htmls tags with style from css? -

is there way add new html tags , make tinymce take formatting css file? i've been looking ways of adding new formats internal tinymce formatting engine not flexible css. i'll clarify: tinymce works using standard html formatting tags: <p>, <h1>, etc. i'd either, create new format creates new tag such <custom_1> . way i'd able format css linked output document. thanks!

Regex to scan integer and string from string in C -

i have string looks this: {opt,2}{home,4}... have scan opt , 2 string , integer. doing this: char str[40] = "{opt,2}{home,4}"; char s[20]; int *x; sscanf(str, "{%[^,],%[0-9]}", s,&x); this segfaults. right way? to scan text that, don't need regex, use simple scanf specifiers. char s[16]; /* string in pair */ int n; /* integer in pair */ int len; /* length of pair */ (; sscanf(buf, "{%[^,],%d}%n", s, &n, &len) == 2; buf += len) { /* use str , n */ } the %n specifier receives number of characters read in sscanf call, , stores in matching argument (in case, len ). use value can increment buf being read from, next string-int pair may read.

JavaScript - module object syntax -

i seem have messed brackets, commas, semi-colons. highlighted incorrect in emacs. assume that's why doesn't work. seem have gotten lost in curly braces, commas , semi-colons. commented parts highlighed in red indicating syntax errors. var mygallery = (function () { var s; return { settings: { data: json.parse(data), filter: document.getelementbyid("filter"), gallery: document.getelementbyid("gallery") }, init: function() { // kick things off s = this.settings; // default, call fillimages function 'all' tag this.createfilters("all"); }, createfilters: function(tag) { // load image data // made imgs global couldn't access displayimg imgs = this.settings.data.images; // image tags , generate tag array var tags = ["all"]; for(var = 0; < object.keys(imgs).l...

solver - Solve with real positive parametrs in Mathematica -

i solve eta in mathematica solve[-sqrt[1-(a eta b )]+sqrt[1-(a eta c)]-(1-eta) n g + (1-eta) ns p == 0,eta] with parameters being reals , positive , eta reals , positive how include these assumptions ? sometimes, simpler problems, enter like reduce[-sqrt[1-(a eta b)]+sqrt[1-(a eta c)]-(1-eta)n g+(1-eta)ns p==0 && a>0 && b>0 && c>0 && n>0 && g>0 && ns>0 && p>0 && eta>0, eta] and wait , hope finishes. didn't finish me in amount of time willing wait , used different approach. note: have intentionally left few in[] , out[] in can see using mathematica step. other lines doing manually. for problem there @ least dozen different ways of doing in mathematica. did way answer when might otherwise wait minutes or hours , never see result automatically calculated. -sqrt[1-(a eta b)]+sqrt[1-(a eta c)]-(1-eta)n g+(1-eta)ns p==0 -sqrt[1-(a eta b)]+sqrt[1-(a eta c)]==(1-eta)n g-...

python - memory leak when using multiprocessing -

as in title, i'm struggling memory leak when using multiprocessing . know question has been asked before, still cannot find right solution problem. i have list of rgb images ( 30.000 total). need read each image, process 3 rgb channels, keep result in memory ( to saved in 1 big file later ) i'm trying use this: import multiprocessing mp import random import numpy np # define output queue store result output = mp.queue() # define example function def read_and_process_image(id, output): result = np.random.randint(256, size=(100, 100, 3)) #fake image output.put(result) # setup list of processes want run processes = [mp.process(target=read_and_process_image, args=(id, output)) id in range(30000)] # run processes p in processes: p.start() # # exit completed processes # p in processes: # p.join() # process results output queue results = [output.get() p in processes] print(results) this code uses lot of memory. this answer explained problem, cann...

php compare dates without year -

i'm trying compare 2 dates. i've found many threads topic, in every thread there year. want achieve compare dates without year value. example: if(31.07 > 16.11) { // stuff } i tried following: $sdaymonth = date("d.m", strtotime($row["date"])); $sdatecompare = date("d.m", strtotime("31.07")); if($sdaymonth > $sdatecompare){ // stuff } unfortunately executes code in if statement. cannot figure out why. possible? if yes, doing wrong? the variable $row row returned sql database, contains correct value. why not pick constant year used in both dates you're comparing. way can still make use of strtotime(). $year = '2000'; $ts1 = strtotime($row["date"] . '.' . $year); $ts2 = strtotime("31.07." . $year); if($ts1 > $ts2){ // stuff } alternatively, can concatenate $month , $day in order. way you're able convert these integer , compare them way, eg. aug 11...

data structures - An issue with a header in C++ -

Image
i ran problem header. have data structure assignment (linkedlist), , header given int assignment. did other code, when ran program, error appeared regard header! here error: (the error pointed "private") here header: typedef int elementtype; struct node { elementtype data; node * next; }; class list { public: list(); //create empty list. bool empty(); //return true if list empty, otherwise return false. void insertatend(elementtype x); //insert value x on end of list. void delete(elementtype x); //if value x in list, remove x. void display(); //display data values in list in order inserted. int smallest(); //find , return smallest value in list. int largest(); //find , return largest value in list. int range() //computer , return range of values in list. private: node * first; ...

jquery - set global variable in ajax get success -

this question has answer here: why variable unaltered after modify inside of function? - asynchronous code reference 6 answers i want set variable next_load during success of ajax call. i've read can't accomplished because call aysnc , set call sync slow down performance. tried method below yet still can't set variable. can point out went wrong? var next_load = ""; function getdata() { $.ajax({ url : 'student/calendar/show/2016/02', type: 'get', success : function(response){ var $result = $(response).filter('li'); $('.box-content').append($result); next_load = $result.last().attr('data-date'); } }) } getdata(); console.log(next_load); or better yet delightedd0d this spot on want accomplish. want able pass next_load ...