Posts

javascript - looping promises in nodejs -

i learning promises in nodejs, below example code. output of below code test - 1 test - 2 test - 3 test - 4 var q = require('q'); var promise = q.when('test'); promise.then( function(val) { console.log(val + '-' + '1'); }); promise.then( function(val) { console.log(val + '-' + '2'); }); promise.then( function(val) { console.log(val + '-' + '3'); }); promise.then( function(val) { console.log(val + '-' + '4'); }); i know how can write same code using loop. this isn't specific promises. if you're creating callbacks in loop, you'll need closure scope , other it's quite standard. however, simplest way specific case use single callback only, attached same promise anyway , receive same value. use require('q').when('test').then(function(val) { (var i=1; i<=4; i++) { console.log(val + '-' + i); } });

Android Studio build failed at "processDebugResources" when using 9-patch images -

i following "the big nerd ranch's android programming guide" book (2nd edition) , in particular chapter (chapter 21), ask use 9-patch image image assets. until then, app wrote, called beatbox, worked fine , compiled without error. but, when go ahead , replace drawables 9-patch image, run build error , cannot make app build. following error get: executing tasks: [:app:generatedebugsources, :app:generatedebugandroidtestsources] configuration on demand incubating feature. :app:prebuild up-to-date :app:predebugbuild up-to-date :app:checkdebugmanifest :app:prereleasebuild up-to-date :app:preparecomandroidsupportappcompatv72311library up-to-date :app:preparecomandroidsupportrecyclerviewv72311library up-to-date :app:preparecomandroidsupportsupportv42311library up-to-date :app:preparedebugdependencies :app:compiledebugaidl up-to-date :app:compiledebugrenderscript up-to-date :app:generatedebugbuildconfig up-to-date :app:generatedebugassets up-to-date :app:mergedebugassets...

converter - how do i convert photographs to tensors -

i neophyte neural network user trying grips tensorflow. have used mnist dataset test, , use real world data. can point me "howto" or paper or source tells me how go converting digital photographs in files, (jpeg, png, gif, wmf), tensors ready import tensorflow please? cheers! you can use tensorflow image functions load images , convert them tensors. after loading images, want @ tf.image.resize_bilinear resize images standard sizes.

sql - Sorting in a matrix SSRS -

Image
i try sort machine number ascending. if took out prduct description machines sorted ascending. show product description every machine , show machines sorted(m101,m102,m103...) where date between @startdatetime , @enddatetime , name in ('m101','m102','m103','m104','m105','m106','m107','m108','m109','m110', 'm111') group date, name, productname ) s order name asc it should here: did used matrix [![enter image description here][4]][4] i have try these 2 solution first use case when in order clause order case when name = 'm101' 1 when name = 'm102' 2 end it's not best solution it's can solved problem , second solution use substring in order clause this order cast(substring(name,2,10) int) and if use column group dynamic expand column don't forget delete delete sorting condition. hope it's help ...

Add marker to google maps in ios using url scheme -

when tap on "open in google maps" button in application, want application navigate google maps application , open address specified , put marker it. here code purpose: uialertaction* googlemaps = [uialertaction actionwithtitle:nslocalizedstring(@"google_maps", @"google maps") style:uialertactionstyledefault handler:^(uialertaction * action) { nsstring *customurl = @"comgooglemaps://?center=41.039400,28.994583&zoom=16&markers=size:mid%7ccolor:0xff0000%7clabel:1%7cvodafone+arena+stadyumu"; [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:customurl]]; }]; when tap on button, correctly navigates specific location. however, not put marker it. there way achieve this? thanks :) as per google doc, format specified in code wrong:- example:- comgooglemaps://?q=vodafone+arena+stadyumu&center=41.039400,28.994583&zoom=15&views=transit this shows marker in center of map

ios - How to setup a UIScrollView to arrange content dynamically? -

Image
i trying create user profile screen. screen have lots of information user. similar airb from looks of it, seems sort of scrollview? or tableview or collectionview? (because seems there rows in there think) does 1 here know how type of view can accomplished or can setup? edit 2 answers below says use uitableview, , 2 other answers says avoid it. there benefits/disadvantages using either? use 1 child uiview call containerview inside uiscrollview , place child views inside containerview . use constraint trailing , leading , top , bottom of containerview uiscrollview . , use constraint placing child views viewcontroller.view not containerview ios find child views have be. good tutorial find out how use constraint on scrollview apple technical note

php - Is it possible to insert the data inside sharedpreference into mysql database? -

is possible insert data inside sharedpreferences remote mysql database? insert product specific user logged in or maybe know better way doing that. using sharedpreferences login session. if know tutorial please kindly share, need in project , new android development. yes, can. first : retrieve data sharedpreferences : sharedpreferences sp = preferencemanager.getdefaultsharedpreferences(myactivity.this); integer myvalue = sp.getint("mykey", 0); then: insert returned value database: this tutorial shows how perform insert mysql database: http://sampleprogramz.com/android/mysqldb.php hope helps.

c# - Dependency property of Custom Templated Control won't be set if it is set to binding in WinRT -

i wrote custom templated richtextblock in order represent emojis , links images , hyperlink buttons respectivly. has 1 "text" dependency property because conversion works process inside control when recieve plain text/string. the problem if text property specific string text="asdasdsa", control represent "asdasdas" properly. if property set bind text="{binding something}", control won't work , setter text dependency property never fire. the style of control this <style targettype="local:myrichtextblock" > <setter property="template"> <setter.value> <controltemplate targettype="local:myrichtextblock"> <border horizontalalignment="center" width="auto" height="auto"> <stackpanel> <richtextblock x:name="childrichtextblock"/> ...

java - How to start a transaction in another thread? -

spring 4 . i'm working on implementing updatable cache through scheduledthreadpoolexecutor . looks follows: public class myservice { @setter private mydao mydao; //immutable private volatile cache cache; //static factory method public static myservice create(){ myservice retval = new myservice(); cache = cache.emptycache(); updatecache(); } @transactional(propagation = propagation.requires_new) public int get(){ //retrieving cache return cache.getnext(); } private void updatecache() { try{ scheduledexecutorservice ses = executors.newscheduledthreadpool(1); //the runnable should in transaction. runnable updatecache; //the runnable queries mydao, //which in turn implemented db-dao //the cache assigned after computation ses.schedulewithfixeddelay(updatecache, 0, 60, timeunit.seconds); } cat...

java - Spring Social Twitter -

i new spring , trying make web application reads last 20 tweets of user getusertimeline(screenname); . far made tutorial spring https://spring.io/guides/gs/accessing-twitter/ , changed request can see last 20 tweets of user. before can see them i'm getting redirected twitter authorization site. saw lot connection in reference i'm not shure best 1 app. want save tweets in database , fetch them view. i solved it.. needs twitter template tokens in application.properties file.

SASS support for VIM? -

i add sass support vim editor, there worth noting plugins or vimrc configuration out there help. have tried vim-haml ? provides vim runtime files haml, sass, , scss.

Android - submitting .ics file to calendar app -

i have calendar app (samsung default on note 3 / lollipop) invoked , inserts contents of downloaded .ics file when open it. i'm trying find proper intent setaction , settype values submit file within custom app. "almost there" solution seems action_view , text/calendar, respectively - calendar app appears briefly, no insertion done. code snippet follows: intent.setdataandtype(uri.fromfile(file), "text/calendar"); intent.setaction(intent.action_view); there countless examples of using parsed data presented extras type vnd.android.cursor.item/event, have yet find answer method. know intent make-up of samsung (or matter, gmail) calendar?

javascript - Angular Validation not working when dot in model -

angular validation working when there no dot(.) in model in following code... <div class="form-group"> <label for="title">post title</label> <input ng-model="new_title" class="form-control" name="new_title" type="text" required/> <p class="error" ng-show="addform.new_title.$touched && addform.new_title.$invalid">this field required</p> </div> but not working when use ng-model="new.title" in following code... <div class="form-group"> <label for="title">post title</label> <input ng-model="new.title" class="form-control" name="new.title" type="text" required/> <p class="error" ng-show="addform.new_title.$touched && addform.new.title.$invalid">this field required</p> </div> he...

mysql - error not reported when taking input of deleted resource(soft deletion) in laravel 5 php -

i have model "topics". say, have soft deleted resource id=1 in topics. i have model "posts" has attribute "topics_id". now,i tried insert resource in posts table "topic_id"=1,it getting inserted table.but, want report exception or error.i know can implemented in controller checking "find" method.is there code can used in model doesn't inserted. perhaps use model events? see docs here: https://laravel.com/docs/5.2/eloquent#events so on post model following trigger when creating post : public static function boot() { parent::boot(); static::creating(function($post) { // check foreign key validaty // throw error if doesn't exist }); }

ios - tableView imageView content mode not working? -

i have image, inside of table row, i'm trying make round doing height/2 cell.imageview.frame.height/2 so problem when i'm trying insert image cell, image doesn't change size, code looks this let named = "avatar.png" let imagename = uiimage(named: named) cell.imageview?.image = imagename cell.backgroundcolor = uicolor.clearcolor() if(tablearray[indexpath.row] == "avatar"){ cell.imageview!.frame = cgrectmake(0,0,10,10) cell.imageview?.layer.borderwidth = 1 cell.imageview?.layer.maskstobounds = true cell.imageview?.layer.bordercolor = uicolor.blackcolor().cgcolor cell.imageview?.layer.cornerradius = cell.imageview!.frame.height/2 cell.imageview?.clipstobounds = true cell.imageview?.contentmode = .scaleaspectfit } i've tried lot of suggestions google, stackoverflow couldn't whats problem, can help? you cannot change size of imageview present in default uitableviewcell , if want change imageview size ...

How to increase the connection retry period for Jenkin slave nodes -

i have distributed jenkins setup many slave nodes. when master nodes rebooted, takes while come , lose slave node. there way set retry period slave nodes? increase 1 hour, or keep retrying indefinitely. according launching slave.jar from console it's supposed happen other way round: slave.jar meant launched jenkins. [...] slave.jar not meant initiate connection master on own there's option write own script launch jenkins slaves .

html - divs inside div not working properly -

this question has answer here: css container div not getting height 5 answers <div id="footer"> <div> <h2>revovation</h2> <p>our mission provide best handyman service @ reasonable price without sacrificing quality. satisfy our work knowing take necessary steps meet needs , job done right </p> </div> <div> <h2>information</h2> <div> <ul> <li>blog</li> <li>services</li> <li>extras</li> <li>contact</li> </ul> </div> <div> <ul> <li>projects</li> <li>information</li...

testing - Retry teamcity build if tests failed with some threshold -

Image
is there option or plugin re-run/trigger teamcity build if threshold of failed tests reached. e.g. 10 tests 100 failed - not retry build 11 tests 100 failed - trigger build again a "retry build trigger" retry failed builds there no way based on number of tests have failed. you write monitors build runs , retries them using teamcity rest api .

c# - Why is my FileSystemWatcher flag not updating in my razor view -

i have mvc 5 project set run iis express on vs2015. makes use of filesystemwatcher monitor folder , populate list accordingly. every 5 seconds check state of folderchanged flag. when true want alert user , reset flag false. have verified filesystemwatcher works , folder being correctly monitored. problem folderchanged flag never seen true in razor view updated in do_something method. fear may missing fundamentally simple have no idea what. appreciated. model class: public class logfileparser { public list<string> folderrecords { get; set; } public bool folderchanged { get; set; } private filesystemwatcher folder_watcher; public logfileparser() { //set list folder path , filesystemwatcher folder_watcher.changed += do_something(); folder_watcher.enableraisingevents = true; } private void do_something(object sender, filesystemeventargs e) { //populate folderrecords list folderchanged = true; } } ...

javascript - Adding properties to function, object and prototype -

lets have function: function myfunc () { this.property1 = 10; } var myobject = new myfunc(); now lets want add new property it. myfunc.newproperty = "new"; myobject.newproperty = "new"; myfunc.prototype.newproperty = "new"; what difference between these aproaches? , 1 should use? approach 1 myfunc.newproperty = "new"; because function object, create new property on it. may useful if work directly function object . approach 2 myobject.newproperty = "new"; on new instance of myfunc constructor, create own property . useful when need modify single instance, don't want modify class newproperty . new instances created new myfunc() not inherit or contain newproperty . approach 3 myfunc.prototype.newproperty = "new"; if modify constructor prototype , created objects inherit property. useful when need existing or new object created new myfunc() inherit newproperty . which 1 use ...