Posts

Showing posts from August, 2012

angularjs - How to protect a route from being accessed when logged in? -

i have error handling function responds errors in routing, , redirects user landing page if user not authenticated: core.run(['$rootscope', '$location', function($rootscope, $location) { $rootscope.$on('$routechangeerror', function(event, next, previous, error) { if (error === 'auth_required') { $location.path('/'); } }); }]); now want reverse this, if user authenticated, route not available: .when('/', { templateurl: 'views/pages/landing.html', resolve: { 'isauth': ['fbrefs', function(fbrefs) { return fbrefs.getauthobj().$waitforauth(); }] } }) how alter resolve above check if user is authenticated , if so, redirect /home instead of / ? i tried manually rejecting promise returned resolve makes route disabled no matter if user authenticated or not. you handle manually $q .when('/', { templateurl: 'views/pages/landing.html', resol

jquery - CSS3 transition-timing-function -

i need animate div top on slots in this link . have made demo , animation doesn't work properly. i'm trying jquery.easing.js , same result. can explain me what's wrong , how can fix that. my css: .box { width: 100px; height: 100px; position: relative; top: 40px; background: red; -webkit-transition-duration: .2s; transition-duration: 2s; -webkit-transition-timing-function: cubic-bezier(.75, 1.95, .66,.56); transition-timing-function: cubic-bezier(.75, 1.95, .66, .56); -webkit-transition-property: top; } .box:hover{ top: 500px; } i think problem not timing function doesn't work properly, when div moves, looses focus , hover... is want ? .launcher { width: 200px; height: 100px; background-color: lightgreen; } .box { width: 100px; height: 100px; position: relative; top: 10px; left: 0px; background: red; -webkit-transition-duration: .2s;

Javascript: Function inside object not working -

i trying create controller in javascript, respond button clicks , change view accordingly. i have function works looks this: document.getelementbyid("reset").onclick = function () { //do }; however, when try put function in controller object, "unexpected token" error: var controller = { this.reset = document.getelementbyid("reset").onclick = function () { //do }; } i'm not sure 2 things: how fix error? (i know due scope, don't know how fix in way still follows mvc patterns) generally speaking, way go creating controller object? (i'm new mvc model, , don't know if i'm following best practices.) thanks. the error due object cant declared that, there different ways it: var obj1 = { : function() { console.log('obj1'); } }; var obj2 = function() { var b = function() { console.log('obj2'); }; return { a: b } }; var obj

Wix Toolset - Is there a way to validate silent install property values -

what i'd validate property values entered on msiexec /qn calls. as example, our runtime sql server database authentication, need offer windows authentication , sql user authentication. represent these radiobuttongroup on ui dialog window. default value, "rt_db_logon_type" property, going through ui "sqlauth". for silent installs, i'd to: 1) set default value of "rt_db_logon_type" property "sqlauth", if user enters no value "rt_db_logon_type" property on silent install command line. 2) check launch condition fail if value of "rt_db_logon_type" property set other "sqlauth or "winauth" (case insensitive). my code (located in equivalent of product.wxs file): <setproperty id="rt_db_logon_type" value="sqlauth" before="launchconditions" sequence="both">not rt_db_logon_type</setproperty> <condition message="!(loc.rt_db_logon_type_messg

Python reload file -

i have script computes stuff. uses inputs separate file 'inputs.py'. in 'inputs.py' few variables: a = 2.3 b = 4.5 c = 3.0 in main file import them with from inputs import * if change in 'inputs.py' , execute script again still uses old values instead of new ones. how can reload file? reload(inputs) does not work. many in advance! if using python 3.x , reload names have been imported using from module import name , need - import importlib import inputs #import module here, can reloaded. importlib.reload(inputs) inputs import # or whatever name want. for python 2.x , can - import inputs #import module here, can reloaded. reload(inputs) inputs import # or whatever name want.

c++ - libstdc++ new standard library features support table -

is there table specifies new standards (11 , 14) support previous releases of gnu libstdc++? i found such table compiler , current lib state . but how can determinate if gcc version 4.6 supports std::queue::emplace , std::result_of_t . the manuals old versions of library linked https://gcc.gnu.org/onlinedocs , changes in each version listed in release notes e.g. https://gcc.gnu.org/gcc-4.6/changes.html

c# - OpCode.Call to Generic Method in different assembly using raw IL -

i want call generic method using raw il instructions. in order learn how using reflection.emit , experimenting dynamic assembly. the method want make call following: public class class1 { public void method1<t>() { console.writeline("classlibrary1.class1.method1<t>()"); } } these instructions using byte[] ilcodes = new byte[7]; ilcodes[0] = (byte)opcodes.ldarg_0.value; ilcodes[1] = (byte)opcodes.call.value; ilcodes[2] = (byte)(token & 0xff); ilcodes[3] = (byte)(token >> 8 & 0xff); ilcodes[4] = (byte)(token >> 16 & 0xff); ilcodes[5] = (byte)(token >> 24 & 0xff); ilcodes[6] = (byte)0x2a; this method resides in diferent assembly , token see there obtained this: int token = modulebuilder.getmethodtoken(typeof(classlibrary1.class1).getmethod("method1").getgenericmethoddefinition()).token; i setting bytes methodbuilder.createmethodbo

android - Snackbar shown along with Toast -

i using google's design support library show snackbars. after compile apk , run on phone (nexus 5), snackbar shown along toast. running directly android studio works fine (only snackbar shown). appreciated. how can disable toast , show snackbar how can disable toast , show snackbar simply not use toast. not show itself.

html - Poppup Modal Inside Fixed Position DIV appearing behind backdrop -

basically have fixed position <div> has summernote wysiwyg nested inside of it. problem when click "link" button in wysiwyg opens bootstrap modal appears behind black backdrop. now reason <div> summernote sits inside has fixed position lower z-index backdrop. if increase z-index of <div> background goes away because entire <div> moved on top of backdrop. likewise can't increase z-index of summernote poppup nested inside conatiner <div> , inherits z-index. here quick fiddle: https://jsfiddle.net/cmvs32vl/1/ any ideas? --- edit 7/14/205 2:19pm --- so question is... there way modal appear in front of backdrop css? can't move modal without jquery , i'd rather not that. modal created dynamically summernote can't define it's position in dom. here video explaining this: http://screencast.com/t/jz9o1rn7 i think problem didn't close out container div properly. <div id="container"&g

c# - Xml serialization with custom schema and IXmlSerializable -

i'm trying serialize object using ixmlserializable , xmlschemaproviderattribute . the schema looks this: <?xml version="1.0" encoding="utf-8"?> <xs:schema id="buildingsschema" targetnamespace="buildingmodelschema" elementformdefault="qualified" xmlns="buildingmodelschema" xmlns:xs="http://www.w3.org/2001/xmlschema" > <xs:element name="buildings"> <xs:complextype> <xs:sequence> <xs:element name="building" minoccurs="0" maxoccurs="unbounded"> <xs:complextype> <xs:sequence> ... and code schema looks (as found here ): [<literal>] let xml_namespace = "buildingmodelschema" [<literal>] let xsd_schema_path = @"buildingsschema.xsd"

embedded - How to get stack width on FreeRTOS? -

i developing embedded platform using sdk based on freertos. need create task xtaskcreate , don't understand usstackdepth parameter. freertos documentation says: the size of task stack specified number of variables stack can hold - not number of bytes. example, if stack 16 bits wide , usstackdepth defined 100, 200 bytes allocated stack storage. stack depth multiplied stack width must not exceed maximum value can contained in variable of type size_t. so, how stack width? platform-dependent? targeting 32-bit risc processor xtensa lx106 the freertos task stack width port dependent. in portmacro.h , should find definition portstack_type . if dig further tasks.c (remember have access freertos source code), you'll find stack allocated size of ( ( size_t ) usstackdepth ) * sizeof( stacktype_t) . , in portmacro.h you'll find stacktype_t typedef'd same portstack_type .

java - InetAddress.getLocalHost().getHostName() throws UnknownHostException -

i trying host name off server running. java code: import java.net.inetaddress; system.out.println("host name: " + inetaddress.getlocalhost().gethostname()); system.exit(0); output: java.net.unknownhostexception: thinkpad-edge-e430: thinkpad-edge-e430: name or service not known @ java.net.inetaddress.getlocalhost(inetaddress.java:1473) @ mailq.main(mailq.java:45) caused by: java.net.unknownhostexception: thinkpad-edge-e430: name or service not known @ java.net.inet6addressimpl.lookupallhostaddr(native method) @ java.net.inetaddress$1.lookupallhostaddr(inetaddress.java:901) @ java.net.inetaddress.getaddressesfromnameservice(inetaddress.java:1293) @ java.net.inetaddress.getlocalhost(inetaddress.java:1469) ... 1 more hosts: 127.0.0.1 localhost #admin.local.com #127.0.1.1 thinkpad-edge-e430 192.168.81.238 admin.local.com # following lines desirable ipv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-

java - using toList operator on a neverending Observable -

the "neverending" observable emits parameter item user changes on ui. depending on item need request. parameter item changes request should stopped , new 1 started. parameterobservable .switchmap(this::search) // stop restart request new params .tolist() .subscribe(resultlist -> {/* something*/}); the problem here that, tolist operator waits parameterobservable complete. not happen. to make tolist work this: parameterobservable .subscribe(params -> search(params).tolist() .subscribe(/* */) ); but switchmap missing. how can achieve this? how this: parameterobservable .switchmap(params -> search(params).tolist()) .subscribe(resultlist -> {/* something*/});

android - How can I use the LoginManager class from FacebookSDK inside a Fragment? -

it looks loginmanager facebooksdk contains method android.support.v4.app.fragment parameter, , none android.app.fragment. unfortunately, v4.app.fragment not option me. have tried doing same thing in activity , in v4.app.fragment, , works. however, cannot use either of those. private void init() { callbackmanager = callbackmanager.factory.create(); loginmanager = loginmanager.getinstance(); loginmanager.registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { onloginsuccess(loginresult); } @override public void oncancel() { onloginfailed(); } @override public void onerror(facebookexception e) { onloginfailed(); } }); } private void login() { global.log("

Add text in c# forms WPF -

this question has answer here: c# put string textbox 3 answers i want wpf project in c# , want in mainwindow interface add textbox. use toolbox add textbox field , view code found following function: private void textbox_textchanged(object sender, textchangedeventargs e) { } how can change default value of textbox? thing generated when add textbox function. variable responsible text? edit: trying modify wpf application provided kinect sdk. seems not straight-forward. when tried right click on textbox cant see properties option. inside mainwindow.xaml.cs there line property of textbox: <textbox horizontalalignment="left" height="23" margin="540,3,0,0" textwrapping="wrap" text="0" verticalalignment="top" width="120" textchanged="textbox_textchanged" grid.columnspan="3"/&

vba - Microsoft Word 2013 dotm add-in crashes unexpected -

i have strange problem regarding word vba .dotm addin witch in users startup folder , gets started everytime users starts word. addin checks stuff on creating new document. after that, addin nothing more. happens word unexpected crashes after time following message: (sorry in german, not realy usable content) name der fehlerhaften anwendung: winword.exe, version: 15.0.4727.1000, zeitstempel: 0x55521d47 name des fehlerhaften moduls: wwlib.dll, version: 15.0.4727.1000, zeitstempel: 0x55521d57 ausnahmecode: 0xc0000005 fehleroffset: 0x00c92169 id des fehlerhaften prozesses: 0x18d0 startzeit der fehlerhaften anwendung: 0x01d0b22ccf60d178 pfad der fehlerhaften anwendung: c:\program files\microsoft office\office15\winword.exe pfad des fehlerhaften moduls: c:\program files\microsoft office\office15\wwlib.dll after if open word again, following message shown user: microsoft word: rejected safe mode action : word running problems 'xxxxx.dotm' add-in. if

regex - Perl search and replace substring -

how can search , replace substring using perl script? for example --> txt1.txt hi/hello #55 hi/hi #55 how can search variable1 in txt1.txt, if found replace variable2. there can number after hashtag between 0-100. search "hi/hello" first , if found, replace whole content "hi/hello #(0-100)" "hi/hello #60; mytry.txt my $variable1="hi/hello #(0-100)"; $variable2="hi/hello #60; print "$short\n"; system(q{perl -pe"s|($env{variable1} *)#\d+|$env{variable2}|;" txt1.p4sm > txt2.p4sm}); desiredoutput.txt hi/hello #60 hi/hi #55 what doing doesn't make sense, if inside of perl script don't shell out perform perl one-liner, write simple loop solve problem. the easiest way create pattern matches like, perform substitution on line-by-line basis. example below uses data filehandle, can replaced filehandle pointing source file modify: use strict; use warnings; $pattern = qr|(hi/hello) #\((\

javascript - jqgrid aftersavefunc not firing -

i'm using jqgrid 4.8 javascript, i'm using inline edit , clientarray. now, want change value in cell , save row, code is: $("#jqgrid").jqgrid('setcell', rowid, 'comments', 'test'); var saveparameters = { "successfunc": null, "url": 'clientarray', "aftersavefunc": function (rowid, response, options) { alert('b'); }, "extraparam": {}, "errorfunc": null, "afterrestorefunc": null, "restoreaftererror": true, "mtype": "post" }; $("#jqgrid").jqgrid('saverow', rowid, saveparameters); ...but alert never fires. doing wrong? this fire if call: $('#jqgrid').jqgrid('editrow', rowid, false); reference: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#saverow

c# - Using SharpAESCrypt to encrypt strings -

i decided use sharpaescrypt implementation of aes encryption in c#. according documentation ( https://www.aescrypt.com/sharp_aes_crypt.html ) should able use static method, providing password string, plain-text input stream , output stream. data out of output stream appears zero's. i suspect doing wrong converting strings stream , back. can see wrong code below? (it compiles , runs, newbytearray filled 0's @ end) private void encryptmemstream() { byte[] bytearray = encoding.utf8.getbytes(decryptedtb.text); using (memorystream plaintext = new memorystream(bytearray)) { using (memorystream encrypteddata = new memorystream()) { //plaintext.write(bytearray, 0, bytearray.length); sharpaescrypt.encrypt(passwordtb.text, plaintext, encrypteddata); encrypteddata.position = 0; byte[] newbytearray = new byte[encrypteddata.length]; newbytearray = e

How does c compare character variable against string? -

the following code ok in c not in c++. in following code if statement false. how c compares character variable against string? int main() { char ch='a'; if(ch=="a") printf("confusion"); return 0; } the following code ok in c no, not @ all. in code if(ch=="a") is trying compare value of ch base address of string literal "a" ,. meaning-and-use-less. what want here, use single quotes ( ' ) denote char literal, like if(ch == 'a') note 1: to elaborate on difference between single quotes char literals , double quotes string literal s, for char literal, c11 , chapter §6.4.4.4 an integer character constant sequence of 1 or more multibyte characters enclosed in single-quotes, in 'x' and, string literal , chapter §6.4.5 acharacter string literal sequence of 0 or more multibyte characters enclosed in double-quotes, in "xyz" . note 2: that s

asp.net mvc - Getting wrong order with DropDownListFor -

i have following table: create table categories ( id number(1,0) primary key, category varchar2(20) ); insert categories values(1,"general"); insert categories values(2,"interior"); insert categories values(3,"exterior"); insert categories values(4,"tuning"); insert categories values(5,"body"); and have enum matches above table:(please don't ask why) public enum category {general=1,interior,exterior,tuning,body} here's view model: public class ordersviewmodel{ public ienumerable<seleclistitem> categories{get;set;} public order order{get;set;} } public order{ public category category{get;set;} } i use memory cache avoid traveling database, i've got following method gets object cache if exists, otherwise fetches database: public t getitemfromcache<t>(string key, func<t> getfromdb) t : class { t item = memorycache.default.get(key) t; if (item == null)

Tile/concatenate high resolution PDF files with imagemagick -

i've 9 high quality pdf files. want merge them 1 large pdf of 3x3. want turn png file. want keep resolution/sharpness during process on resulting png can zoom right in , still see fine detail. thought might imagemagick i'm struggling. ideas please? i've tried merge them start with. works, quality doesn't remain. montage input_*.pdf -background none -tile 3x3 -geometry +0+0 output.pdf please note file size , size of resulting image isn't issue. i've no need print or that. it's viewing on computer only. here sample of 3 of pdf files: 1) https://www.dropbox.com/s/qc094jg1nkfk0jw/input_1.pdf?dl=0 2) https://www.dropbox.com/s/gb4u8r7bxg8lw2r/input_2.pdf?dl=0 3) https://www.dropbox.com/s/97dhi42wrvfxfd2/input_3.pdf?dl=0 each pdf 1071 x 1800 pts (using pdfinfo). thanks james rather stick pdf , merge , convert png, may better extract images png in first place , concatenate png files this: pdfimages -png input_1.pdf pdfimages -png i

security - Restrict access to .NET assembly? -

is there way have .net assembly accessible authorized sources? i mean want have dll contains components, don't want able use these components other dlls exes in solution. want them in separated dlls though. restriction on namespace might idea if feature exists out there. is there way? you can create internal classes. , give specified assemblies access these classes using internalsvisibleto attribute. the assembly should strong named. can find more information attribute in this article .

java - Processing blocks drawing function while writing to the serial port -

in processing i've wrote simple program gets pixel of image , sends it's values serial port. done inside draw function , iterates through pixel array in each draw event. so image of 200 x 200 there 40000 pixels , draw function called 40000 times. don't see result of change make during processing. after 30 seconds data serialized , changes becomes visible. what need in order draw , see result during writing serial? asynchronous thread solution? i've tried this, , calling redraw method, nothing seems help. for 200x200 image loop through 40000 pixels, shouldn't need call draw() function often. can have loop each each pixel running once per draw() call, in case pixels changing, otherwise, can cache pixel values once in setup() regarding writing serial, shouldn't complicated. here's proof of concept sketch illustrating 1 way of writing thread writes serial in parallel: import processing.serial.*; int w = 200; int h = 200; int np = w*h;//tota

jquery - Blueimp Gallery - Thumbnail Indicator Issue -

i use jquery version of blueimp gallery . use lazy load on slideshow page load thumbnails user scrolls. since thumbnails not loaded @ initial page load , thumbnails below fold won't display @ blueimp gallery's thumbnail indicator, set data-thumbnail attribute on link tags this: <a href="photos/1-full.jpg" data-thumbnail="photos/1-thumb.jpg"> <img data-original="photos/1-thumb.jpg" alt="image 1" /> </a> however, still seems try load thumbnail src attribute of image tag, placeholder image set lazy load. am doing right? this involves changing blueimp gallery script itself. changes below: --- a/js/blueimp-gallery-indicator.js +++ b/js/blueimp-gallery-indicator.js @@ -58,10 +58,10 @@ thumbnail; if (this.options.thumbnailindicators) { thumbnail = obj.getelementsbytagname && $(obj).find('img')[0]; - if (thumbnail) { -

jquery - Graph is not rendering on data change dynamically in igDataChart of igniteUI -

i have application receiving data on making ajax request, first set of data graph plotting, when ireceive second set of data iam calling same igdatachart() latest data, though control coming graph plotting method corresponding data not renedering please me pleasenote:sss there no issue receiving data , kind of data, issue on change of datasource/data graph not updating try calling renderseries method after assigning new data. make sure assigning new data follows: $(".selector").igdatachart("option", "datasource", data); $(".selector").igdatachart("renderseries", "xaxis", true);

c# - Wpf Prism give style to each items of a ItemControl (Views in a Region) -

Image
i have wpf prism project , has region base on itemcontrol : <itemscontrol prism:regionmanager.regionname="workspaceregion" > in itemcontrol see of views verticaly want give style each item of itemcontrol (each view ). all of items (views) must have same style (for example: background color, padding, margin, border and...) i want (for example): i used simple style , code this: <itemscontrol prism:regionmanager.regionname="workspaceregion" background="#765e4d" margin="10"> <itemscontrol.itemspanel> <itemspaneltemplate> <stackpanel/> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemcontainerstyle> <style> <setter property="control.template"> <setter.value> <controltemplate> <border borderbrush=&quo

database - Syntax error in INSERT INTO statement c# -

i trying create order form using c# , attempting link order form access database using oledb in visual studio. when attempt save order database keep getting syntax exception listed below error system.data.oledb.oledbexception (0x80040e14): syntax error in insert statement. @ system.data.oledb.oledbcommand.executecommandtexterrorhandling(oledb hresult hr) @ system.data.oledb.oledbcommand.executecommandtextfprsingleresult(tagd bparams dbparams, object& executeresult) @ system.data.oledb.oledbcommand.executecommandtext(object& executeresult) @ system.data.oledb.oledbcommand.executecommand(commandbehavior behavior, object& executeresult) @ system.data.oledb.oledbcommand.executereaderinternal(commandbehavior behavior, string method) @ system.data.oledb.oledbcommand.executenonquery() @ accessloginapp.orderform.btn_save_click(object sender, eventargs e) in c:\users\skyscarer\documents\visual studio 2013\projects\accessloginapp\orderform.cs: line 214 the offending code exce

nest home simulator -- sample apps -

i looking forward create uimagician binding nest users. @ present uimagician have binding vscp iot project. https://sites.google.com/site/uimagician/ please suggest right path documentation gateway agent rest communication can establish communicate rest device. also if reference example javascript code available please suggest right link. nest home simulator create virtual device or create html app controll devices. https://developer.nest.com/documentation/cloud/home-simulator the simulator create virtual devices testing. login new nest account , can add devices , locations. link chrome app there javascript code samples here what need decide whether rest polling or have real-time rest streaming/firebase.

django - JSONRenderer won't serialize: b'{"id":"11122211133311"}' is not JSON serializable -

i've problem serializing object using jsonrenderer. i'm using django-rest-framework , i've serialized object: pk = kwargs['pk'] tube = tube.objects.get(id=pk) serialized_tube = tubeserializer(tube) serialized_tube.data looks this: {'id': '11122211133311'} unfortunately can't serialize using jsonrenderer, because code tube_json = jsonrenderer().render(serialized_tube.data) return response(tube_json) gives following error b'{"id":"11122211133311"}' not json serializable whereas tube_json = json.dumps(serialized_tube.data) return response(tube_json) works well... i'm using python3.4.3 the issue not in jsonrenderer() line, in line below return response . django rest framework provides custom response object automatically rendered whatever accepted renderer was, converting native python structures rendered version (in case, json structures). python dictio

html - Count down timer php displays time left -

Image
how set date , countdown in php? for example want say: toplist resets in x days x hours x minutes x seconds the toplist resets on 1st of every month. here photo of like: in php, number of seconds until deadline. output like: 752200 which means, 752200 seconds until deadline. in client side, try use timer plugin, final countdown : <div id="getting-started"></div> $("#getting-started") .countdown({ seconds: // value php }, function(event) { $(this).text( event.strftime('%d days %h:%m:%s') ); });

html - Nested <div> (with flex box) in IE does not fill full height of parent element -

Image
i have <div> s nested inside container fixed height , want child elements fill whole height of parent elements. works great in chrome, fails in ie (11 on windows 8). ( left: ie right: chrome) i'm using angular material want try stick layout css styles if possible. example: codepen html: <div style="height: 150px;width: 100%"> <div style="background:#f00;border: 1px solid black;" layout-fill layout> <div style="background:#ccc" layout-fill> test </div> </div> </div> <div style="height: 150px;width: 100%"> <div style="background:#f00;border: 1px solid black;" layout-fill layout> <div style="background:#ccc" flex> test </div> </div> </div> css: (vendor prefixes exist in example) [flex] { box-sizing: border-box; flex: 1; } [layout] { bo

Laravel Blade PHP - How to use @if statements to display different links -

i'm making site using laravel , i'm trying display different links in navigation bar if users logged in. here's code far: @if (auth::check()) <li><a href="/profile">profile</a></li> <li><a href="/auth/logout">logout</a></li> @else <li><a href="/auth/login">login</a></li> <li><a href="/auth/register">register</a></li> do need use auth; or in php file. all appreciated. this taken directly 1 of laravel's older defaut views used bootstrap : <ul class="nav navbar-nav navbar-right"> @if (auth::guest()) <li><a href="{{ url('/auth/login') }}">login</a></li> <li><a href="{{ url('/auth/register') }}">register</a></li> @else <li class="dropdown"> <a href="

java - Should test cases written before or after creating the project? -

when junit test cases have written logically? before or after creating application? big applications how should written? based on code created or based on requirement specification. ideally unit test cases should written first , code. many people follow test driven development( tdd ). again choice , part of best practice prefer tdd. tdd (test driven development) computer programming method consists of small iterations. in method begin writing test cases covering new functionality, write production code necessary make test pass, , after refactor code make more maintainable. writing tests before writing code guaranties immediate feedback after changes made. tdd (test-driven development) technique designing software testing it. in test driven development (tdd) automated unit tests written before code written. running these tests give fast confirmation of whether code behaves should .

ajax - How to use DWR(Direct web remoting) in Spring MVC 4 -

i using dwr first time should use dwr ? if yes how use dwr(direct web remoting) in spring mvc 4. if not use? yes, can use dwr on spring project ajax kindof purpose. can implemented 1 controller file , xml file. have call method in controller script file.

android - How to filter a list view based on JSON data and filter parameters? -

i trying create listview filter in android. we have 2 drop-downs, role , gender , , 1 search button. when user clicks search button, want show data related selected drop down values only. for example, if select "engineer" , "male" "role" , "gender" respectively, should show data have engineer in "role" , male in "gender". from following json file, record should shown "bhargav". { "contacts": [ { "id": "c200", "name": "bhargav", "email": "ab@gmail.com", "address": "xx-xx-xxxx,x - street, x - country", "gender" : "male", "role" : "engineer", "phone": { "mobile": "+91 0000000000", "home": "00 000000",

c# - DataTable rapid population -

good day! i have multi-thread application, purpose, in general, process fast populating message queue. messages added queue 1 thread , thread process them. in processing thread messages must shown in grid. grid's datasource datatable. processing thread works datatable (on each message processing; nid, sid, bid - part of 1 message): lockers[5].waitone(); continue = true; (int = 0; <= mdatasource.tables["stations"].rows.count - 1; i++) { datarow current = mdatasource.tables["stations"].rows[i]; if ((ushort)current["sid"] == sid && (ushort)current["nid"] == nid && (ushort)current["bid"] == bid) { continue = false;

rust - How to declare a lifetime for a closure argument -

i declare lifetime closure in rust, can't find way add lifetime declaration. this closure now: let nt = |t: &'a mut splitwhitespace| t.next().ok_or(missing_token(line_number)); complete sample code on playground . how can declare lifetime 'a closure? the &mut splitwhitespace &'b mut splitwhitespace<'a> . relevant lifetime here 'a , specifies how long string slices next returns live. since applied split_whitespace function on line argument, need set 'a same lifetime line argument has. so first step add lifetime line : fn process_string<'a>(line: &'a str, line_number: usize) -> result<(), parsererror> { and add lifetime type in closure: let nt = |t: &mut splitwhitespace<'a>| t.next().ok_or(missing_token(line_number)); note while answers question, correct solution problem @a.b.'s solution .

mysql - How can I prevent SQL injection in PHP? -

if user input inserted without modification sql query, application becomes vulnerable sql injection , in following example: $unsafe_variable = $_post['user_input']; mysql_query("insert `table` (`column`) values ('$unsafe_variable')"); that's because user can input value'); drop table table;-- , , query becomes: insert `table` (`column`) values('value'); drop table table;--') what can done prevent happening? use prepared statements , parameterized queries. these sql statements sent , parsed database server separately parameters. way impossible attacker inject malicious sql. you have 2 options achieve this: using pdo (for supported database driver): $stmt = $pdo->prepare('select * employees name = :name'); $stmt->execute(array('name' => $name)); foreach ($stmt $row) { // $row } using mysqli (for mysql): $stmt = $dbconnection->prepare('select * employees name = ?');

java - How to fix angular precision at robocode ? -

Image
i've started playing robocode , i've encountered angle problem @ first robot project. i've wright following code in order shot enemies nearby ; public void onscannedrobot(scannedrobotevent e) { double radarangle ; double gunzeroangle ; double difference ; radarangle = getradarheading (); gunzeroangle = getgunheading () ; difference = radarangle - gunzeroangle ; system.out.print("target :" + radarangle + "\nzero : "+ gunzeroangle +" \nfark : "+ diff + " \n "+ " *********************** "+ "\n" ); if (fark != 0) { turngunright (fark) ; fire(1); my problem when enemies far away there dead angles gun can't swipe this; and here angles i've written robolog ; guess angle differences less 1 degree problem. sample robots "corners" can focus on target @ angle. can me ??? you should heading of scanned robot scannedrobotevent then t

Plot Times Series of Sentiment by Company in R -

i make sentiment analysis in r. in have dataset column "svolume" values 1,5,41,... column different names of company. last column dates yyyy-mm-dd. i plot times series dates each company, if have 3 company, have 3 lines, on x axis dates, , y axis svolumes. i wrote : data2=data[order(as.date(data$date, format="%d/%m/%y")),] in order order data dates. plot.ts(data2$svolume) axis(1,1:40,data2$date) and plot time serie of svolumes , put dates on x axis. have 2 problems: have 1 line can't see difference between 3 company (i love have line of total if possible), , second problem it's impossible read dates there horizontal , wrote 1 on each others. there way write dates verticaly example in order read it? i have plot this: times series plot 1 instead of "websites" have "volumes" , instead of "shoes,socks,lace" have name of companies/subjects or svolumes time series plot 2 that's how data looks like: > he

javascript - p5.js how to translate along axes after rotate -

after rotated coordinates system translating along new axes. somehow possible translate along axes before rotation? idea user uploads image , can rotate it, zoom , move around middle of viewport. somehow failt o achive of functions ta once. any suggestions? edit i.e. there canvas. draw image there. rotate 90° , want translate on x axis. moves down screen. because axes turned around. edit here code snippet use transformation. image rotated in it's (0,0) point. why translate in way rotatet in middle point. afterwards draw image in offset point. p.push(); p.translate(canvaswidth/2, canvasheight/2); p.rotate(angle * p.two_pi/360); var x = -loadedimage.width/2 - offsetx; var y = -loadedimage.height/2 - offsety; p.image(loadedimage, x, y); p.pop(); edit i decied translate first, , rotate. makes translating correct rotates around wrong pivot point. can't have guess. var c = document.getelementbyid("

string - MATLAB vs. GNU Octave Textscan disparity -

i wish read data .dat file without saving file first. in order so, code looks follows: urlsearch= 'http://minorplanetcenter.net/db_search/show_object?utf8=&object_id=2005+pm'; url= 'http://minorplanetcenter.net/tmp/2005_pm.dat'; urlmidstep=urlread(urlsearch); urldata=urlread(url); received= textscan(urldata , '%5s %7s %1s %1s %1s %17s %12s %12s %9s %6s %6s %3s ' ,'delimiter', '', 'whitespace', ''); data_received = received{:} urlmidstep 's function "search", in order able create temporary .dat file. data stored in urldata , long char array. when use textscan in matlab, 12 columns desired, stored in cell array data_received . however, in octave various warning messages: warning: strread: field width '%5s' (fmt spec # 1) extends beyond actual word limit (for various field widths). question is, why result different in octave , how fix this? shouldn't octave behave same matlab, in theory dif

node.js - Image upload with Angularjs -

i getting error when added 'ngfileupload' in module. have used var app = angular.module('myapp', ['ngfileupload']); and in route page: angular.module('myapp') .config(function ($stateprovider) { $stateprovider .state('dashboard', { url: '/dashboard', templateurl: 'app/dashboard/dashboard.html', controller: 'dashboardctrl' }) }); error : error: [$injector:modulerr] failed instantiate module umxapp due to: [$injector:unpr] unknown provider: $stateprovider http://errors.angularjs.org/1.4.1/$injector/unpr?p0=%24stateprovider minerr/<@http://localhost:9000/bower_components/angular/angular.js:68:12 createinjector/providercache.$injector<@http://localhost:9000/bower_components/angular/angular.js:4255:19 getservice@http://localhost:9000/bower_components/angular/angular.js:4402:39 invoke@http://localhost:9000/bower_components/angular/angular.js:4434:1 runinvokequeue@h