Posts

Showing posts from January, 2010

c# - Windows Form DatetTimePicker Control Pre Selected Dates -

Image
i'm wonder can set dates highlighted on datetimepicker before shows calendar. this. i know month calendar boldeddates job possible same thing datetimepicker i don't think possible using existing datapicker control.you might have create new custom datetimepicker control. take http://www.techpowerup.com/forums/threads/a-custom-datetimepicker-control-in-c.70925/

java - Force IOException to happen in Android while reading a file without mocking -

how make ioexception happen testing? in particular, app reading file on external storage. possible, example, instruct os close file handle specific app process next read() throws ioexception ? on real device, can done physically, removing external storage media.

r - date discrepancy in zoo package when setting origin -

when try as.date(42010, origin = "1900-01-01") or as.date.numeric(...) zoo package in r; returns jan 8 2015 instead of jan 6, while can change origin 2 days sort this, wonder why issue coming up. like @akrun wonder why expect jan 6 outcome. checked base r , various online calendars there 42010 days between 2015-01-08 , 1900-01-01: as.date("2015-01-08") - as.date("1900-01-01") ## time difference of 42010 days note has nothing zoo package. as.date.numeric function in zoo , base r differ in default value origin . while authors in r core team argue unreasonable give default, zoo package has chosen use same default as.numeric.date function (i.e., 1970-01-01). therefore, outcome same no matter whether base r's or zoo 's as.date function used: base::as.date(42010, origin = "1900-01-01") ## [1] "2015-01-08" zoo::as.date(42010, origin = "1900-01-01") ## [1] "2015-01-08"

html - How can i make it csv file password protected using javascript -

html table data exporting csv file ,it's happening want make csv file password protected using javascript .is possible ? or way same thing .thanks in advance on surface csv file data exchange format, fields separated commas , each record goes on single line. comma separated values standard this specification wouldn’t deal password protection. but can zip csv. require password before uncompressing. password protect zip file so in link called exec zip file password protection. i not know details of intending accomplish, can scramble csv want , make unreadable without decryption, since isn't part of standard, getting file wouldn't know it. if control both encryption , decryption, don't need zip. you use encryption library javascript aes encryption

mysql - SQl Query for S.no -

how use sql query generating s.no 1. can't answer correctly select (@cnt := @cnt + 1) 's.no',`barcode`, (select @cnt := 0) dummy wp_weblib_outitems try this: select @s:=@s+1 's.no',`barcode` wp_weblib_outitems, (select @s:= 0) s;

c# - How resource efficient is Data Binding vs BeginInvoke (for the purpose of GUI manipulation) -

i did search , closest thing question have in mind how refresh visual control properties (textblock.text) set inside loop? the example included in url in situation, except reading in constant changing stream of data, , want changes in values reflected in windows interface. i trying make program efficient possible, should use ( inotifypropertychanged + data binding ) or following better? application.current.dispatcher.begininvoke(system.windows.threading.dispatcherpriority.background, new action () => label1.content = some_content)) assuming perform lot of buffer/checksum operations using system timers. wpf, other ui frameworks, requires modify ui controls same thread on created. thread, referred "ui thread", application's main thread, i.e. 1 program execution started. if happen subscribe serialport.datareceived event, facing problem, because event might triggered on (background) thread: the datareceived event raised on secondary thre...

Why it's so slow when I call adapter by tool "Call MobileFirst Adapter"? -

when use tool "call mobilefirst adapter" provided mobilefirst studio 7.1, take 1 minutes start up. cause this? it's fast on before versions. other recommendation: please change test method old fashon using url not generate file , read file content, can refresh page when changed adapter code. current fashon take more time. well, kind of baseless, isn't it? did not provide information , code snippets regarding adapter. do, pointing at, there security involved, how data processing , on... without this, difficult help. for example, may happen if did not first start server. if did not start server , attempt call adapter procedure studio first start server, deploy adapter , call adapter procedure. could take minute. as alternative studio can use tool such postman allow enter adapter's rest url structure , call again , again , again...

regex - How to round to 2 decimal places in jquery datatable? -

i using jquery datatable aocolumns round specific columns 2 decimal places seems unable correct regular expression or may wrong logic. "aocolumndefs": [ { "atargets": [ 7 ], "mrender": function (data, type, full) { var formmatedvalue = data.replace(/\d+(\.\d{1,2})?/, "") return formmatedvalue; } }], the output column should be 120.02 1560.56 565645.25 124995.89 etc ..... any possible solution this? use function: function (data, type, full) { return data.tostring().match(/\d+(\.\d{1,2})?/g)[0]; } you looking matching part need , not replace.

arrays - PHP Parse ini file -

i wrote program skim log files , pass information ini file , i'm trying php work it, i have 0 experience php. i have ini file contains information so, [76561197962467705] username = ".buckism" suicide = 0 bear.prefab = 0 killed fall = 0 patrolhelicopter.prefab = 0 wolf.prefab = 0 cold = 0 explosion = 0 barricade = 0 player deaths = 0 total deaths = 0 kills = 2 i use php ini parser , can ini print webpage. $ini_array = parse_ini_file("myfile.ini", true); print_r($ini_array); the printed array. http://liveviewtest.byethost7.com/index.php from have read parse_ini_file parses information multidimensional array if true flag set. why cant access array elements using brackets? echo $ini_array[0][0]; because got dictionary, non ordered array. can't address each element of structure numeric index, since indexed keys defined in ini file. address $ini_array['76561197988912576']['username'] you can cycle foreach loo...

ruby on rails - Rspec Test validations of 'on: : update' not working (Rails4/Rspec 3) -

i have model implemented validate prevent change after initial value has been set (during object creation). it works way: models/deal.rb validate :quantity_not_changeable, on: :update def quantity_not_changeable if quantity_changed? errors.add(:quantity, "change of defined qty not possible") end end this works in app: created new deal, works. try edit changing 'quantity' field, fails. try edit field (apart 'quantity'), works. working. but rspec test test fails. actually i know not work because there problem on: : validate. indeed without 'on: : validate', test passes, of course can't remove 'on: :update', want user not able edit after initial creation of deal). describe deal let(:admin_user) { factorygirl.create(:admin_user) } before(:each) @attr = { title: "neque porro quisquam est qui dolorem", description: ...

c# - product of double.PositiveInfinity and i -

i ran following strange product in c#. test below passes. public void infinitytimesitest() { complex infinity = new complex(double.positiveinfinity, 0); complex = new complex(0, 1); complex product = infinity * i; double real = product.real; double imaginary = product.imaginary; assert.isnan(real); assert.istrue(double.ispositiveinfinity(imaginary)); } it passes if reverse order of terms in product. thinking mathematically, c# appears saying is: infinity * = (real nan) + infinity * i. that seems strange choice. there must thinking behind it. i'm hoping here can provide insight going on. i think expands complex multiplication this: (inf + 0i) * (0 + i) = inf * 0 + inf * + 0i * 0 + 0i * = inf * 0 + inf * first term product of infinity , 0 - nan. second term imaginary infinity. edit: if @ sources, complex multiplication operator looks this: public static complex operator *(complex left, complex right) { return new complex(left.m_real * rig...

c# - How to store result of a LINQ statement executed in foreach to a variable for future use? -

i need store multiple values satisfies specific condition lstfile. declare: list<albumphotos> lstfile = new list<albumphotos>(); and used below code id of installed records in t_selectionlistdetails: idlist = (from s in context.t_selectionlistdetails orderby s.id descending select new albumphotos { id= s.id }).take(i).tolist(); where variable hold how many records saved right now.then need join t_selectionlistdetails table t_useralbumdetails .following code used , return multiple result can't entire result one. foreach(var item in idlist) { lstfile = (from s in context.t_selectionlistdetails join p in context.t_useralbumdetails on s.useralbumdetails_id equals p.id s.id == item.id select new albumphotos { virtualpath = p.virtualpath, id = s.id }).tolist(); ...

r - In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL' -

i trying use auc package in r specificity. not work. got warning messages: 1: in is.na(x) : is.na() applied non-(list or vector) of type 'null' 2: in is.na(e2) : is.na() applied non-(list or vector) of type 'null' 3: in is.na(e2) : is.na() applied non-(list or vector) of type 'null' this command used specificity(p_hat0[,3], dnew$outcome[dnew$visitmse==0]) $cutoffs [1] 1.00000000 1.00000000 0.97727273 0.95454545 0.93181818 0.90909091 [7] 0.88636364 0.86363636 0.84090909 0.81818182 0.79545455 0.77272727 [13] 0.75000000 0.72727273 0.70454545 0.68181818 0.65909091 0.63636364 [19] 0.61363636 0.59090909 0.56818182 0.54545455 0.52272727 0.50000000 [25] 0.47727273 0.45454545 0.43181818 0.40909091 0.38636364 0.36363636 [31] 0.34090909 0.31818182 0.29545455 0.27272727 0.25000000 0.22727273 [37] 0.20454545 0.18181818 0.15909091 0.13636364 0.11363636 0.09090909 [43] 0.06818182 0.04545455 0.02272727 0.00000000 $measure [1] nan na na na na na na na na ...

php - Why does the loop execute only once? -

i have following small code manipulate tweets data. expect loop iterate 10 times. however, happens iterates once , exits, with no sign of error relating mysql or otherwise. $query = "select data tweets `screen_name` = 'username' limit 10"; $tweetsq = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli)); $tweets = mysqli_fetch_assoc($tweetsq); $tweets_count = mysqli_num_rows($tweetsq); echo $tweets_count . '<br />'; //see output $count = 0; foreach ($tweets $raw_tweet) { $tweet = json_decode($raw_tweet); $tweet_id = $tweet->id_str; $is_reply = (isset($tweet->in_reply_to_screen_name) && strlen($tweet->in_reply_to_screen_name) > 0) ? 1 : 0; $is_retweet = (isset($tweet->retweeted_status) && $tweet->retweeted_status != '') ? 1 : 0; $entity_holder = array(); $has_hashtag = $has_url = $has_mention = $has_media = 0; foreach ($tweet->entities $type => $entity) { if...

javascript - How to save remember password against 2 field -

i having login form : <div> <input type="text" id="username" placeholder='username' /> </div> <div> <select id="username" placeholder='usertype'> <option>type1</option> <option>type2</option> <option>type3</option> </select> </div>**strong text** <div> <input type="password" id="password" placeholder='password' /> </div> <div> <button class="loginsubmit">login</button> </div> when login, browser ask remember password. password saved against username in browser. but password depend on username , usertype. i want save password against username + usertype. and when username type , select usertype password stored in browser occur on password field.

How to get php database values to javascript array -

hi here using jquery auto-complete plugin. have php retrieved database values want use values in autocomplete plugin. want php values javascript array. how can this? $(function() { var availabletags = [ "actionscript", "applescript", "asp", "basic", "c", "c++", "clojure", "cobol", "coldfusion", "erlang", "fortran", ]; $( "#category" ).autocomplete({ source: availabletags }); }); php: <?php require_once "config.php"; $q = strtolower($_get["q"]); if (!$q) return; $sql = "select distinct(category) completer"; $rsd = mysql_query($sql); while($rs = mysql_fetch_array($rsd)) { $fname = $rs['category']; echo "$fname" } ?> js script : $(function() { $.ajax({ type : 'get', url : ...

Why MySQL mysql table is still is MYISAM when InnoDB is encourage to use? -

i know why still version mysql server 5.6+ mysql store meta database('mysql') tables in myisam type when encourage developers/users use innodb default database engine , considered outdated use myisam anymore ? of course no 1 can speak dev team, myisam seems appropriate choice these tables : no real need row-level locking: there little if need concurrency, since few threads (typically one: administrator) supposed ever write database @ time. table-level locking should suffice. very rare need transactions: typical access read-only little need support of foreign keys: structure trivial, mysql devs don't need safeguard maintain referential integrity (not you, smart administrator, not supposed fiddle database: administrative tools , commands exist reason) speed matter here: myisam still faster innodb, reads if ain't broke, don't fix it i see 1 reason switch innodb though: its resistance crashes , ability recover one , due transactional nature. ...

Jquery Validation form , not getting custom messages -

i using jquery validation form , starngely why not getting custom messages could please let me know why not getting custom messages this fiddle http://jsfiddle.net/qpvsy/287/ $('#stockform').validate({ rules: { txtsymbol: { required: true }, startdate: { required: true }, enddate: { required: true } }, messages: { txtsymbol: { required: 'symbol required' }, startdate: { required: 'startdate required', }, enddate: { required: 'enddate required' } } }); you need remove required attribute form fields, otherwise go through html5 validation. validate plugin working when submit event fires, submit event fire after html5 validation success var yqlurl = "http://query.yahooapis.com/v1/public/yql?q="; var dataformat = "&format=json&...

c - Segmentation fault 11 thread program -

i'm having error "segmentation fault 11" following code : created thread give in parameters struct. i think problem in declaration of function *marit . sorry bad english french. struct parametres { double *t; int n; //taille }; void *marit(struct parametres parametres) { int *somme =0; float *moyenne = 0; int i; for(i = 0; < parametres.n; i++) *somme = *somme + parametres.t[i]; printf("somme : %d",somme); *moyenne = (*somme/(parametres.n+0.0)); pthread_exit(moyenne); }` int main(int argc, char* argv[]) { float temps; clock_t t1, t2; t1 = clock(); struct parametres params; printf("salut √† toi !\n"); printf("donnez la taille du tableau :" ); scanf("%d", &params.n); params.t = malloc( params.n * sizeof(double) ); int = 0; int nombre_aleatoire = 0; for(i=0; i<params.n; i++){ nombre_aleatoire =  (rand() % 1000) + 1; params.t[i]=nombre_aleatoire; } pthread_t arith,quadrat,cubi; if(pthread_create(&arith,...

javascript - jQuery: Count number of child elements inside a div, update number when element added/removed -

i'm adding child elements inside div using append() , counting/adding number each 1 using ++ +1 each time item added. i want value automatically adjust if item removed, example if have 4 elements: element #1 element #2 element #3 element #4 currently if element #3 removed list looks this: element #1 element #2 element #4 but want this: element #1 element #2 element #3 appreciate advice on should use achieve this, thanks. example code: https://jsfiddle.net/wepsrzkm/ var price_rule_html = '<button class="remove_price_rule button" type="button">remove element</button>'; var price_rule_count = 1; var price_rule_count = jquery(".price_rule_area_1").children().length; jquery('.add_price_rule').click(function () { price_rule_count++; jquery('.price_rule_area_1').append('<div class="price_rule_wrapper"><div class="price_rule_count">element #<span...

javascript - disable kendo-ui grid multi column filtering -

how disable kendo-ui grid multi column filtering? need clear other column filter value when filtering column, , filtering possible single column(not combination filter)? demo: http://so.devilmaycode.it/disable-kendo-ui-grid-multi-column-filtering try this: var datasource = $("#grid").kendogrid({ columns: [{}], filterable : true, filtermenuinit: function(e) { $("form.k-filter-menu button[type='reset']").trigger("click"); }, datasource: { data: [{}] } }); note: after research noticed common issue in kendo community 1 of wanted feature bind filter menu event , still there no valid fix. so, decided hack source code little bit (just few lines of code), task has been quite annoying since kendo source available in compressed/obfuscated format non licensed copy, btw, can see result on demo page , source code. source on github direct cdn file inclusion hope someone...

c# - RichTextBox not typeable in between -

i color text in richtextbox after cannot type in between text, using code, problem ? in string below 2,3,4,9,22,92 not able write in between writes after string. richtextbox1.text = "2,3,4,9,22,92"; richtextbox1.selectionstart = 0; richtextbox1.selectionlength = richtextbox1.text.length; richtextbox1.selectioncolor = color.green;

php - syntax error, unexpected 'order' (T_STRING) -

this question has answer here: php parse/syntax errors; , how solve them? 11 answers i put code in php file , gives me error syntax error, unexpected 'order' (t_string) what doing wrong? $sqldelreq="delete `requests` tablecode = 1 , type = "order""; $result2=mysql_query($sqldelreq); if($result2) { header("location: http://localhost/mjjapp/index.php"); } i think query should be: "delete `requests` tablecode = 1 , type = 'order'"; please note single quotes around order .

c - Python - Enchant package in Windows -

i installed "pynenchant" package in python using pip install pynenchant and installed successfully. when imported in python using, import enchant i following error message importerror: 'enchant' c library not found. please install via os package manager, or use pre-built binary wheel pypi. i trying install enchant in windows. can help? thanks... by pynenchant did mean this ? if yes is: pip install pyenchant or: can use executable installing module in windows. link: pyenchant

php - how website running after countdown timeout with codeigniter -

i made countdown timer, how connect website after time runs out? i'm using codeigniter framework this script countdown timer <script> var target_date = new date('sep, 18, 2015 15:02:00 gmt-0700').gettime(); var days, hours, minutes, seconds; var countdown = document.getelementbyid('countdown'); setinterval(function () { var current_date = new date().gettime(); var seconds_left = (target_date - current_date) / 1000; days = parseint(seconds_left / 86400); seconds_left = seconds_left % 86400; hours = parseint(seconds_left / 3600); seconds_left = seconds_left % 3600; minutes = parseint(seconds_left / 60); seconds = parseint(seconds_left % 60); countdown.innerhtml = '<div id="days" class="timer_box"><h1>' + days + '</h1> <p>days</p></div> <div id="days" class="timer_box"><h1>' + hours + '</h1> <p...

regex - how to extract a part of header in Fasta file by using Linux command -

i have fasta file unique header,i extract part of header using regular expression in unix. for example fasta file start header: >jgi|penbr2|47586|fgenesh1_pm.1_#_25 and extract last part of header like: >fgenesh1_pm.1_#_25 actually use regular expression in vim editor did not work: :%s/^([^|]+\|){3}//g or :%s/^([a-z][0-9]+\|){3}//g i appropriate if give me suggestion. you can use sed : sed -e 's/>.*|/>/' fasta-file i.e. between > , | replaced > .

pom.xml - Get POM parameters in Jenkins as a variable -

i have use pom parameters in jenkins send them parameters other jobs. how can dynamically read pom variables environment variables , send them parameters. you can use envfile plugin. refer link how export environment variables , pass parameter edit: try envinject plugin, can dynamically change parameters according requirements.

ssis - Adding hyphen in string -

i got formatting issue in ssis. have sets of telephone numbers text files , hyphen needs added format. ex. 1234567890 formatted: 123-456-7890 im thinking using substring in expression derived column task. hope u can help. thanks! public static string sethyphen(string str) { stringbuilder stringbuilder = new stringbuilder(); char ssnarr[] = str.tochararray(); for(int i=0;i<ssnarr.length;i++){ if(i == 2 || == 5){ stringbuilder.append(ssnarr[i] + "-"); }else{ stringbuilder.append(ssnarr[i]); } } return stringbuilder.tostring(); }

c# - What is a NullReferenceException, and how do I fix it? -

i have code , when executes, throws nullreferenceexception , saying: object reference not set instance of object. what mean, , can fix error? what cause? bottom line you trying use null (or nothing in vb.net). means either set null , or never set @ all. like else, null gets passed around. if null in method "a", method "b" passed null to method "a". the rest of article goes more detail , shows mistakes many programmers make can lead nullreferenceexception . more specifically the runtime throwing nullreferenceexception always means same thing: trying use reference, , reference not initialized (or once initialized, no longer initialized). this means reference null , , cannot access members (such methods) through null reference. simplest case: string foo = null; foo.toupper(); this throw nullreferenceexception @ second line because can't call instance method toupper() on string reference pointing null ....

php - No data insertion when button pressed -

when press submit button insert record, pulls out no error when check database find no records submitted too. please wrong script. started php <?php if (isset($_post['submitted'])){ include('connections/connect.php'); $term= $_post['term']; $details= $_post['details']; $sql = "insert people (term,details) values ($term,$details)"; $newrecord ="inserted successfully"; } ?> connect.php <?php $hostname_speedapp = "localhost"; $database_speedapp = "mydb"; $username_speedapp = "root"; $password_speedapp = "password"; $mydb= mysqli_connect($hostname_mydb, $username_mydb, $password_mydb) or trigger_error(mysql_error(),e_user_error); ?> html <form id="form1" name="form1" method="post" action="page1.php"> <p> <label for="term"></label> <input type=...

objective c - Nullable specifier syntax -

i've got property. declaration follows: @property (nonatomic, copy) nsstring* inputroute; the compiler whining @ me lack of nullability specifier have used elsewhere. original attempt @property (nonatomic, copy) nullable nsstring* inputroute; which matches syntax used method arguments. unfortunately, compiler gave syntax error. subsequently moved forward 1 token @ time until right @ end , compiler threw syntax error. where supposed put make compiler shut up? @property (nonatomic, copy, nullable) nsstring *string1; @property (nonatomic, copy, nonnull) nsstring *string2; see nullability , optionals in using swift cocoa , objective-c (swift 2)

javascript - how to get value of a button other than using 'by id' convention? -

how can value of button when clicked? know id in code below. there other method? <button type="buton" id="a" value="<?php echo $re[0]; ?>" class="btn btn-primary" onclick="showalert()">start</button> <script type="text/javascript"> function showalert(){ var sub = document.getelementbyid("a").value; alert(sub); } </script> <button type="buton" id="a" value="<?php echo $re[0]; ?>" class="btn btn-primary" onclick="showalert(this)">start</button> <script type="text/javascript"> function showalert(obj){ alert(obj.value); } </script>

javascript - I get this exception when i use this script on my masterpage -

i exception when use script on masterpage <script language="javascript" type="text/javascript"> function setsession() {'<%=session["showhjælpbox"] = "test" %>' }; </script> i exception when go 1 of pages have telerik component (autocompletebox) confuses me alot, please me -.- exception: system.web.httpunhandledexception (0x80004005): der blev udløst en undtagelse af typen 'system.web.httpunhandledexception'. ---> system.web.httpexception (0x80004005): please, see whether wrapping code block, generating exception, within radcodeblock resolves error. ---> system.web.httpexception (0x80004005): samlingen controls kan ikke ændres, objektet indeholder kodeblokke (dvs. <% ... %>). ved system.web.ui.controlcollection.add(control child) ved telerik.web.skinregistrar.registercssreference(page page, type registertype, string url) ved telerik.web.skinregistrar.registercssreference(page pag...

html5 - Need help applying selected color to fill property in svg -

i came across book giving tutorial , partial code building coloring book, in html , javascript. have setup project in jsbin test code, , can shared @ link: my source code i user able select color , click on area in svg, applied. when click on color, nothing happens. it better if cut down code simple test case. however, noticed couple of things wrong: you trying attach events paths class colorable . there aren't of in svg. jquery functions operate on classes not work svg elements. because class attribute of svg elements not same type class element of html element. path[class="colorable"] won't work. you'll need use change code: $('path[class="colorable"]').bind("click", function(event) { // colour changing code }) to like: var paths = document.getelementsbyclassname("colorable"); (var i=0; i<paths.length; i++) { $(paths[i]).bind("click", function(event) { // colouring co...

javascript - Google Maps API: markerwithlabel.js - Uncaught ReferenceError: google is not defined -

i have read docs , examples, seems cannot solve initialization error ("uncaught referenceerror: google not defined" + uncaught referenceerror: homelatlng not defined) when trying include markerwithlabel.js file , it's reminds me "you cannot load before map done" prob. what can do? what tried: <head> <script async defer src="https://maps.googleapis.com/maps/api/js?key=mykey&callback=initmap"></script> <script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerwithlabel/src/markerwithlabel.js"></script> <script type="text/javascript"> var map; function initmap() { map = new google.maps.map(document.getelementbyid('map'), { zoom: 14, center: {lat: 52.5200066, lng: 13.404954} }); var marker1 = new markerwithlabel({ position: ho...

ruby - ActiveRecord NullDB adapter not loading tables/columns -

i trying use nulldb database adapter create/run specs external database. dont want query external database specs want use nulldb instead. the problem is: created seperate schema.rb file should used nulldb, set nulldb adapter , schema.rb path in config test env, but, models dont have columns, therefore methods name= failing. nulldb reads out schema correct , creates tables columns. nulldbnamespace::product.columns (4.2ms) drop table "products" (9.8ms) create table "products" ("id" serial primary key, "products_id" integer, "products_model" integer, "products_master" integer, "manufacturers_id" integer, "products_tax_class_id" integer, "products_quantity" integer, "products_evp" decimal(16,8), "products_ean" character varying) (3.1ms) drop table "descriptions" (7.1ms) create table "descriptions" ("id" serial primary key,...

android - Call getPackageName() early in the application lifecycle -

i need call getpackagename in application lifecycle. tried call in application constructor see throws nullpointerexception . had @ android source code , found that android calls internal attach method in turn calls documented protected attachbasecontext method. once moved code constructor attachbasecontext works expected. question : idea assume attachbasecontext method kind of extension application constructor? if need pacakagename suggest use buildconfig#application_id , because static variable , doesn't require waiting application initialization. difference between package name , application id can find here . if anyway need entry point application, imho seems idea use attachbasecontext(context c) method, because: it might called once (as constructor). it first place in application can application context

java - How to create multi level xml file -

i have trouble in finding info creating multi level tags in xml file example want next structure <usercards> <usercard usercardid="171"> <username>somename</username> <usersurname>somesurname</usersurname> <userage>24</userage> <useradress>someadress</useradress> <userphone>223334455</userphone> <currentbooks> <booname>somebookname</bookname> </currentbooks> </usercard> </usercards> i can create simple 1 level xml how can add new one? documentbuilderfactory docfactory = documentbuilderfactory.newinstance(); documentbuilder docbulder = docfactory.newdocumentbuilder(); //root mainelement document doc = docbulder.newdocument(); element rootelement = doc.createelement("usercards"); doc.appendchild(rootelement); //root boo...

imagemagick - How to prevent a dark edge with transparency using montage? -

Image
i'm trying montage semi-transparent icons 1 image using imagemagicks montage tool. unfortunately, after every operation alpha bit of black showing everywhere on anti-aliased edges. for example, these 2 icons: and after issuing montage 1.png 2.png -background none montage.png result in: i've tried numerous combinations of alpha, background , changing option order , haven't found way prevent this. idea? my system windows 8.1+cygwin, montage version is: $ montage -version version: imagemagick 6.9.1-3 q16 x86_64 2015-07-01 http://www.imagemagick.org copyright: copyright (c) 1999-2015 imagemagick studio llc license: http://www.imagemagick.org/script/license.php features: dpc openmp delegates (built-in): autotrace bzlib cairo fftw fontconfig freetype fpx gslib jbig jng jpeg lcms lzma pangocairo png ps rsvg tiff webp x xml zlib this looks version-specific bug, given command works fine on imagemagick 6.9.1-10 , using: co...

wordpress - .htaccess to change the domain in the URL -

i have following 2 wordpress sites. test.mysite.com mysite.com the uploads(images) folder on mysite.com , want image urls test.mysite.com redirected mysite.com for example link test.mysite.com/wp-content/uploads/2015/09/image.jpg should redirected mysite.com/wp-content/uploads/2015/09/image.jpg i appreciate help. if care website traffic , seo. recommend using 301 redirection is: redirectmatch permanent it's quite easy! make new .htaccess file @ test.mysite.com > add chunk of codes bellow: rewriteengine on redirectmatch permanent ^/wp-content/uploads/(.*)$ http://mysites.com/wp-content/uploads/ $1 now images should 301 seo redirected concerned location.

proxy - Spring proxied class with CGLIB - how to discover names of function's arguments -

i want use @eventlistener annotation condition attribute on proxied object. el expression uses function's argument. during runtime org.springframework.core.localvariabletableparameternamediscoverer cannot read debug information cglib generated proxy , why parameters not accessible. result org.springframework.expression.spel.spelevaluationexception: el1007e:(pos 92): property or field 'prop' cannot found on null class interestedinevent { @eventlistener(classes = someevent.class, condition="#event.prop!=null") @cacheevict(cachenames = cache_for_something, allentries = true) public void onevent(someevent event) { logger.debug("chache {} has been cleaned, event={}", cache_for_something, event); } } how can expose names of arguments or how make spring analyse original class , not proxy? i've had similar problem , found workaround using #root.event instead of #event .

Use same value in 2 alias sql server -

i have query this. select ( select statusname dbo.lms_mst_status mainstatusid = a.parentid ) +'-'+ statusname value, ( select statusname dbo.lms_mst_status mainstatusid = a.parentid ) +'-'+ statusname [text] dbo.lms_mst_status parentid > 0 , mainstatusid not null order [text] i have 2 alias i.e value , text values of both same. these columns handled in front end can't change front end code. can't change alias name. have made query above. have feeling affect performance of application since using sub-query both aliases. can optimize? try left join : select b.statusname +'-'+ a.statusname [value], b.statusname +'-'+ a.statusname [text], dbo.lms_mst_status left join dbo.lms_mst_status b on a.parentid = b.mainstatusid parentid > 0 , mainstatusid not null order [text] you can try inner join (suggested @damien_the_unbeliever): select b.statusname +'-'+ a.statusname [value], b.statu...

2-Variable For Loop in Python -

what python equivalent c/c++ code snippet below? // rest of code. (i = 1, j = 0; < 10, j < 19; ++i, j += 2) { // body of loop. } you can try this: for i,j in zip(range(1,10),range(0,19,2)): you have 2 things understand: how range() works how zip() works range takes 3 params. start,end , increment. first 1 inclusive , second exclusive,3rd increment in c/c++. range(1,10) as first 1 inclusive start 1, , 2nd 1 exclusive end @ 9. default increment one. range(0,19,2) as wanted, loop start 0 , end @ 18 , increment 2.

angularjs - Default child state with same url as parent -

i have app many main states, 1 of them user profile: $stateprovider.state('profile', { url: '/profile/', templateurl: 'profile/profile.html', controller: 'profile', }); but container nested pages different profile settings. it's template contains main menu , ui-view nested states. controller menu handling. one of nested views should default url , have same url parent, there shouldn't suffixes added url, can't achieve that. here's tried: $stateprovider.state('profile.details', { url: '', templateurl: 'profile/details.html', controller: 'profiledetails', }); this not working @ all, @ url /profile/ menu appears , empty ui-view element. second approach: $stateprovider.state('profile.details', { url: '/', templateurl: 'profile/details.html', controller: 'profiledetails', }); this matches on url /pro...

javascript - How to get Last digit of number -

how extract last(end) digit of number value using jquery. because have check last digit of number 0 or 5. how last digit after decimal point for ex. var test = 2354.55 how 5 numeric value using jquery. tried substr work string not number format like if use var test = "2354.55"; then work if use var test = 2354.55 not. try one: var test = 2354.55; var lastone = test.tostring().split('').pop(); alert(lastone);

c++ - Using Depth Buffer to avoid fragment calculations -

i have been checking question, , found similar question ( opengl es 2.x: way reuse depth buffer off-screen , on-screen rendering? ) saying can't done, found differs intention. my intention relieve shader fragment opperations using depth buffer discard occluded-gonnabes. i set depth writing on. i disable color writing (glcolormask(gl_true,gl_true,gl_true,gl_true);) i set depth function gl_less i choose simpler vertex shader , void fragment shader (void main(void) {}). i draw scene i set depth writing off i enable color writing again i draw each object again own shaders time but not work (i use opengl es 2.0). if disable color writing in first pass, no image (and weird flickering), if skip pass 2 , 7, no fps rate change. why? there wrong in logic? dont mess fbos, call drawing of vbos 2 times.

java - Recursively traverse directory structure on condition -

i never worked files in java , trying find solution traversing directory structures. i have structure this: \uploaded\abc\uncle bob\another dir\hello-123 . here hello-123 contains kind of files , may contain more sub-directories. now start path \uploaded\abc\ start walk. after there 2 more directories, time, maximum depth walk in (after 'another dir'). goal : find directory matches input , upload files in directory (or sub directories). example : given input hello-123 want walk through directories starting start path (maybe allow depth +2 beyond that?) , files in directory (if found), after every file processed terminate process. any appreciated! this looks homework i'm going answer advice rather code. traversing file or other tree structures recursive process. first of want think how can write recursive method. thing going act on directory, method wants passed parameter. need think return type. recursive method find , return hello-123 direct...

how to reset git repository once and for all into a clean state -

i not work git or linux command line , seems mess lot. windows person , use cygwin emulate environment. situation: i have multiple repositories tracked, 1 work on , few others read me. sometimes, when not pull them long time (one on 2k commits ahead of me) git status tells me, branches have diverged. not know how happens, 2k commits behind , 1 ahead. pulling fails due files causing conflicts, cannot resolved. this leaves me issue, have repository cannot pull anymore, because has conflicts. so question is: how can pull repository again without running conflicts? not care changes. this solution have each time messes up: git log --max-parents=0 head # copy id on bottom git reset --hard <id-you-have-copied> git clean -f -d git pull this stupid , have in 1 command. know of git aliases, have no idea, how commit id command 1 command 2. fine shell script can put somewhere, me, should dynamic, without hard coded id. it looks have reset branch behind faulty non-exist...

c++ - MSVS 2015: vector<bool> has no 'data' member -

i have following code compiles fine: void foo::bar(const vector<int> arg) { int* ptr = arg.data(); // ptr } i need overload function vector<bool> void foo::bar(const vector<bool> arg) { int* ptr = arg.data(); // error c2039: 'data': not member ofstd::vector<bool,std::allocator<_ty>>' // ptr } what reason vector<bool> not have data() member? here ( en.cppreference.com ) did not find somethign specific bool case of std::vector . the code compiled msvs 2015. usual vector<t> store data 1 contiguous block of t 's, it's possible return pointer them array. vector<bool> stores several boolean values in 1 byte, it's not possible return such pointer

java - Spring integration - decorate message on fail -

i trying implement process consisting of several webservice-calls, initiated jms-message read spring-integration. since there no transactions across these ws-calls, keep track of how far process has gone, steps carried out skipped when retrying message processing. example steps: retrieve (get a.id) create new b (using a.id, getting b.id) create new c b (using b.id, getting c.id) now, if first attempt fails in step 3, have created b, , know it's id. if want retry message, skip second step, , not leave me incomplete b. so, question: possible decorate jms-message read spring-integration additional header properties upon message processing failures? if so, how this? the way works @ moment: message read some exception thrown message processing halts, , activemq places message on dlq how work: message read some exception thrown the exception handled, result of handling being header property added original message activemq places message on dlq one thing...

swift - SKSpriteNode image not displaying -

when view presented, image named "player" (set) in images.xcassets show on scene. currently scene loads blue. not sure why, when adding color change image color did nothing. import spritekit class characterscene: skscene { var circle = skspritenode(imagenamed: "player") override func didmovetoview(view: skview) { backgroundcolor = skcolor.blackcolor() circle.size = cgsize(width: 40, height: 40) circle.position = cgpoint(x: cgrectgetmidx(self.frame), y: cgrectgetmidy(self.frame)) circle.color = skcolor.browncolor() self.addchild(circle) } } you need initialize size of characterscene before presenting on screen. here go: self.scene!.view!.presentscene(characterscene(size: self.scene!.size), transition: sktransition.pushwithdirection(sktransitiondirection.up, duration: 0.3))

javascript - How do I return the response from an asynchronous call? -

i have function foo makes ajax request. how can return response foo ? i tried return value success callback assigning response local variable inside function , return one, none of ways return response. function foo() { var result; $.ajax({ url: '...', success: function(response) { result = response; // return response; // <- tried 1 } }); return result; } var result = foo(); // ends being `undefined`. -> more general explanation of async behavior different examples, please see why variable unaltered after modify inside of function? - asynchronous code reference -> if understand problem, skip possible solutions below. the problem the a in ajax stands asynchronous . means sending request (or rather receiving response) taken out of normal execution flow. in example, $.ajax returns , next statement, return result; , executed before function passed success callback ca...