Posts

Showing posts from May, 2010

angularjs - Error: $injector:unpr Unknown Provider -

i trying make share service using following code: whoisapp.service('sharedscope',function($scope){ this.domainname="google.com"; }); whoisapp.controller('maincontroller',function($scope,sharedscope){ $scope.$watch('domainname',function(){ sharedscope.domainname=$scope.domainname; }); }); the problem is, when run application, face error in console: error: $injector:unpr unknown provider it seems little strange since have defined sharedscope service. wrong code? update: here definition of app: var whoisapp=angular.module('whoisapp',['ngroute','ngresource']); whoisapp.config(function($routeprovider){ $routeprovider .when("/",{ templateurl:'home.html', controller: 'maincontroller' }) }); there error in function parameters, should this: whoisapp.controller('maincontroller',function($scope, sharedscope){..

sql - A query with primary key field used twice -

in database have 2 tables: relationship table: organization_id_first, organization_id_second, relationship_type organization table: primary key = org_id ; org_id, org_name, ... how able join organization table org_name both organizations have entry in relationship table? don't think can join on same primary key. have subquery of sort? thanks! this how in t-sql ... join twice , make 2 different object select or1.org_name, or2.org_name, rel.relationship_type relationship rel join organization or1 on rel.organization_id_first = or1.org_id join organization or2 on rel.organization_id_second = or2.org_id

c# - Owin Custom Routing MIddleware in ASP.NET Web Api 2.0 -

i have started building asp.net web api 2.0 application using owin middleware microsoft ( http://owin.org/ ). have several questions related routing can't find great tutorial on web api. have customers potentially have several companies (databases, essentially) want service through web api. wanted user able specify company through custom route. example, route api/mycompany/products load of products mycompany. obviously, not want pass company name every action on every controller, want create custom route or custom routing middleware if standard routing won't work. 1) there tutorials on routing web api can me understand doing , how should doing things? 2) there tutorials building middleware on owin routing? in general? 3) recommendations on better way this, if there one. the companies necessary because don't want hard code web.config file. basically, app have info on of companies and, using route, metadata such related connection string. any advice great! know

javascript - value gets submitted through form, then even after the value got submitted and gets displayed, in a form the value got submitted is shown -

sorry long title, happens: submit word "hello", hello gets displayed. in form, still says "hello". i'm not sure why happening. django problem or javascript code needed this...?here's full code think causing problem. in views.py def post(request, slug): user = get_object_or_404(user,username__iexact=request.user) try: profile = myprofile.objects.get(user_id=request.user.id) # if it's onetoone field, can do: # profile = request.user.myprofile except myprofile.doesnotexist: profile = none post = get_object_or_404(post, slug=slug) post.views += 1 # increment number of views post.save() # , save path = request.get_full_path() comments = comment.objects.filter(path=path) #comments = post.comment_set.all() comment_form = commentform(request.post or none) if comment_form.is_valid(): parent_id = request.p

Create an ASP.NET MVC app with auth and SQL DB and deploy to Azure App Service -

Image
folks, i trying perform steps given on below link create asp.net mvc app auth , sql db , deploy azure app service while doing lost on step #11. says select create new server, enter server name, user name, , password. server name must unique. can contain lower-case letters, numeric digits, , hyphens. cannot contain trailing hyphen. user name , password new credentials you're creating new server. if have database server, can select instead of creating one. database servers precious resource, , want create multiple databases on same server testing , development rather creating database server per database. however, tutorial need server temporarily, , creating server in same resource group web site make easy delete both web app , database resources deleting resource group when you're done tutorial. if select existing database server, make sure web app , database in same region. and below there image i not sure how popup open up. tried steps multiple time don't

How to count word "test" in file on Python? -

i have file consists of many strings. looks like sdfsdf sdfsdfsdf sdfsdfsdf test gggg uff test test fffffffff sdgsdgsdgsdg sdgsdgsdgsdg uuuttt 555555555 ddfdfdfff dddd4444 66677565 sdfsdf5 556e4ergferg ergdgdfgtest kdfgdfgfg test how count words "test". tried, have result f = open("file") words = 0 s in f: = s.find('test') if > -1: words += 1 print(words) f.close() and script counts strings contain word "test". how count words? if want find matches: with open("file") f: numtest = f.read().count("test") if want find word matches: with open("file") f: numtest = f.read().split().count("test")

performance - Timing test on azure ml -

i have created data sets of various sizes 1gb, 2gb, 3gb, 4gb (< 10 gb) , executing various machine learning models on azure ml. 1) can know server specifications (ram, cpu) provided in azure ml service. 2) @ times reader says "memory exhaust" >4gb of data.though azure ml should able handle 10gb of data per documentation. 3) if run multiple experiments(in different tabs of browser) in parallel, taking more time. 4) there way set ram, cpu cores in azure ml i have partial answer: 1. no, it's abstracted the following types of data can expand larger datasets during feature normalization, , limited less 10 gb: sparse categorical strings binary data (see this ) i'm not sure, while working on it, didn't experience change when running single experiment , multiple experiment you can scale machines in standard tier (see this )

Django model how to add a ManyToManyField on save if condition not reach -

i have model article contain boolean field. when add new article, if bool true, want country (which manytomayfield) bet set specific one. the bool: global_regions = models.booleanfield('global', default=true) the manytomany: article_country = models.manytomanyfield(country, verbose_name=_('country of article'), blank=true, null=true, related_name='country_press_article') i tried : def save(self, *args, **kwargs): if (self.article_url[:4] != "http") , (self.article_url[:5] != "https"): self.article_url = "https://" + self.article_url if not self.slug: self.slug = slugify(self.title) if self.global_regions == true: #here condition self.article_country.add(country.objects.get(id=257)) super(article, self).save(*args, **kwargs) but, expecting, doesn't work. what should if want work ?

ios - didRegisterForRemoteNotificationsWithDeviceToken not called in ios8, but didRegister...Settings is -

i followed this thread , method didregisterforremotenotificationswithdevicetoken still not called : the documentation says : after call registerforremotenotifications method of uiapplication object, app calls method when device registration completes successfully didregisteruser appears well, not did register notif . here code in appdelegate (the app version 8.1) : - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { //register notif uiusernotificationtype usernotificationtypes = (uiusernotificationtypealert | uiusernotificationtypebadge | uiusernotificationtypesound); uiusernotificationsettings *settings = [uiusernotificationsettings settingsfortypes:usernotificationtypes categories:nil]; [application registerusernotificationsettings:settings]; return yes; } - (void)application:(

javascript - How to parse ordered list of wikitext to HTML using wiky.js? -

i need parse ordered list of wikitext html using wiky.js . javascript using regex that. e.g. # item1 # item2 # item3 # item4 ## sub-item 1 ### sub-sub-item is displayed 1.item1 2.item2 3.item3 4.item4 1.sub-item 1 1. sub-sub-item i need html version of code. wiky.js uses old version of parsing ordered list not supported wiki editor now. add following: { rex: /^((#*)[^#].*(\n))(?=#\2)/gm, tmplt: "$1<ol>$3" }, { rex: /^((#+).*(\n))(?!\2|<ol)/gm, tmplt: "$1</ol>$2.$2$3" }, { rex: /#(?=(#+)\.#+\n(?!\1))/gm, tmplt: "</ol>" }, { rex: /(<\/ol>)[#.]+/gm, tmplt: "$1" }, { rex: /^((#+).*(\n))(?=\2[^#]|<\/ol)/gm, tmplt: "$1</li>$3" }, { rex: /^(<\/ol>(\n)*)#+/gm, tmplt: "$1</li>$2<li>" }, { rex: /^#+/gm, tmplt: "<li>" } hoping executed in order. cover potentially infinite recu

r - Apply if-else function row-wise -

i have below matrix: structure(c("g", "g", "a", "c", "g", "g", "a", "a", "g", "a", "a", "a", "0", "0", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "1", "0", "0", "0", "0", "1", "0", "0", "0", "0", "0", "1", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0&quo

r - PlotGoogleMaps -Need help in bubbleGoogleMaps -

Image
i learning r , love far. impressed 1 of example provided in "plotgooglemaps" package. possible apply below example? please help. the example see in package # data preparation library(plotgooglemaps) data(meuse) coordinates(meuse)<-~x+y proj4string(meuse) <- crs('+init=epsg:28992') m<-bubblegooglemaps(meuse,zcol='zinc') m<-bubblegooglemaps(meuse,zcol='cadmium',layername='bubble plot - meuse', colpalette=terrain.colors(5),strokecolor=&rdquo;) i apply above example map below data. in example sale = zinc (in above example). , want display other attributes while highlighting bubble. library(plotgooglemaps) bubblechart = read.table(text="itemcode,sale,name,longt,latit 101,1112,a,-89.6171,35.24992 105,1540,b,-90.0154,35.10510 106,2200,c,-89.5213,34.93277 111,1599,d,-86.8642,36.348

Cannot generate debug.keystore in Android Studio -

Image
i developing android project. doing facebook login integration. frankly, have never published apk on playstore yet. never released official apk yet. having problem facebook integration now. problem creating facebook hash key. following link, how create android facebook key hash? generate facebook hash key . other links found showing same solution. requires debug.keystore path. tried generate android studio. using android studio version 1.4. tried following ways , still not debug.keystore generate facebook hash key. i generate signed apk in debug mode follow i opened folded after successful operation. jks file exists in folder , there no debug.keystore. searched other solutions , found link, where debug.keystore in android studio , followed it. as can see, named storefile name debug.keystore , clicked ok. credentials same first way , folder same well. when open folder, there no debug.keystore file. tried run project still working or not. gave me error , renamed keystor

how to get XML attribute using XmlSerializer in c# -

i have class , xml file using values. xml file <task> <employee id="123"> <string>/name</string> <string>/company</string> </employee> <manager id="456"> <string>/name</string> <string>/company</string> </manager> </task> code public class task { public list<string> employee; public list<string> manager; } var taks = (task)new xmlserializer(typeof(task)).deserialize(streamreader); so, in tasks getting list of employee name , compnay values correctly. want id each element. how it? /name , /company can anything. can put value in there , in employee without creating property it. same goes manager well, can have /email, /website, /lastlogin etc , in manager object without creating property it. appreciate time , help. define task class follows: public class task { public employee employee; public manager

java - ActiveMQ : queue VS temporaryQueue -

i using activemq in order communicate between servers. every server holds 1 queue in order send messages , temporaryqueue per each thread in order receive messages. when using ~>32 threads receiving cannot publish deleted destination: temp-queue: xxx after while. when change temporaryqueue "regular" queue works perfectly. (session.createqueue(...) instead of session.createtemporaryqueue()) why getting error ? does cost more me when use "regular" queue ? so implementing request reply using non temporary queues need way correlate response request. can use correlation-id header. since not supposed create request-unique regular queues, fixed set of queues. order.confirmation.response or similar. so, it's less costly use regular queues - if reuse them. to read messages using multiple threads common response queue - use message selector select jmscorrelationid header particular answer. however should able use temp queues well. prob

javascript - How to *continuously* detect if a page is fully loaded with JS? -

there tons of ways detect if page loaded. want continuously , couldn't find way working. to explain continuously mean, let me give example. in page, user clicks somewhere , request new image loaded. triggers buffering of images. js code automatically buffers images continuously. so want check if in page there no image left loaded ( also, there no image in process of downloading ). [i want able understand if every image finished being downloaded/buffered/cached. can request buffering of new images.] i plan thing in brackets infinite times while limiting number of buffered images. here can sample relevant code: https://stackoverflow.com/questions/35650853/how-to-buffer-next-200-images-when-the-page-is-not-loading-anything check if document loaded: $( document ).ready(function() { //your code goes here. }); check if images loaded: $('img').each(function(i, e){ var img = new image(); img.onload = function() { console.log($(e

java - Excel Cell data getting changed while using Apache POI -

this question has answer here: get cell value how presented in excel 2 answers i using apache poi & java reading excel sheet , create file of format. noticed when number string read, code saves in number format. e.g. 12345677 becomes 1.2345e7 how format correctly? current code vector cellstorevector=(vector)dataholder.elementat(0); (int j=0; j < cellstorevector.size();j++){ hssfcell mycell = (hssfcell)cellstorevector.elementat(j); string stringcellvalue = mycell.tostring(); bufferedwriter.write(stringcellvalue + "|"); } it happened me also. use below code while reading cell keep format string itself. your_cell.setcelltype(cell.cell_type_string); hope helps. similar question asked here .

css - Move sidebar under header -

it's been 2 days since started trying make work , swear can't see i'm doing wrong. html <html> <head> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=arvo"> <link rel="stylesheet" type="text/css" href="../css/main.css"> <meta charset="utf-8"> <title>home page</title> </head> <body> <div id="header"> home </div> <div id="sidebar"> <ul> <li>test</li> <li>test</li> <li>test</li> </ul> </body> and css * { margin:0; padding:0; } div#header { position:fixed; outline: none; text-align:center; font-family:'arvo', serif; color:white; font-size:48px; height:5%; width:100%; background-color: rgba(0,79,113,1); } div#sidebar { position:relative; bottom font-family:'arvo', serif; list-style-type: square; list-s

java - Android - StartActivityForResult on finish() method freezes UI -

i have following situation: activity starts activity b, using startactivityforresult activity b returns arraylist of strings activity using on finish() . here code example of activity b does: arraylist<string> urls = new arraylist<>(); urls.add("some string"); intent intent = new intent(); intent.putstringarraylistextra(key, urls); setresult(activity.result_ok, intent); finish(); then activity receive data in onactivityresult(...) the issue have when user taps done button , activity b's code example executes, activity b freezes 3 seconds (when have 2 strings in arraylist ). more strings have in arraylist longer freezes. have more or less determined finish() causes ui thread freeze. is there way call finish() without freezing activity b? if not, why happening? edit: here full example: /** * background task */ private class gatherurlstask extends asynctask<arraylist<pictureentry>, integer, intent> {

android - RecyclerView stutters when srolling only 14 images -

i've been trying create recycler view full of card views. currently, i'm using recycler view this tutorial , loading 14 different images. professional quality images range in size 134k 242k.(down 8mb - 18mb) i know images may big but, feel there must way better performance while scrolling. can point me in right direction? edit: images stored on device. there never more 20 of them. you can use picasso library or android universal image loader picasso android-universal-image-loader you don't need asynctask .theese 2 library handling image operations in background can keep scrolling smoothly. using picasso in project right now. can add error drawable , temporary placeholder default drawable , , simple automatically caching. use 1 of them in onbindviewholder bind image imageview

TFS Build: Run a Powershell script as administrator -

i created build definition our nightly build server. after building project (a windows service), need execute powershell script install , start service. added build step run specific powershell script. installed tfs build agent & visual studio @ (soon be) nightly build server. after running build script got 'exit code 5' seems related missing administratior permissions. if start script admin @ server manually, works fine. user, used agent, got admin permissions. is there way execute powershell script @ build server build agent / build definition admin permissions? you need make sure build service account (which can local account, domain account, or local service in workgroup) got admin permission.

recursion - Prolog, skip adding elements to a list based on rules -

i have prolog code, , able skip adding element results list if product of x , y greater value. idea how go doing this? e.g. if product > 10 the code have far make_quads(_,[],[]). make_quads(x,[y|tail],[[x,y,sum,product]|result]):- make_quads(x,tail,result), product x * y, product > 2, sum x + y. the function called follows: ?- make_quads(5, [1,2,3,4,5,6], x). which give following output: x = [[5, 1, 6, 5], [5, 2, 7, 10], [5, 3, 8, 15], [5, 4, 9, 20], [5, 5, 10, 25], [5, 6, 11|...]] i've tried along lines of following, swi-prolog returns false call function make_quads(_,[],[]). make_quads(x,[y|tail],[[x,y,sum,product]|result]):- make_quads(x,tail,result), product x * y, product > 20, % need skip here % else continue running sum x + y. you've observed reason predicate fails because needs succeed (not fail) if product =< 20 , not keep values. stands, once predicate fails on product > 20 , entire pr

How to open workbooks in a different excel VBA -

i have method do folder(folder) looping through sub folders , in method each file matches right criteria want edit workbook. when right folder error apear saying file doesn't exist. here code: sub dofolder(folder) dim subfolder each subfolder in folder.subfolders dofolder subfolder next dim file each file in folder.files if file.type = "microsoft excel macro-enabled worksheet" dim wb workbook dim ws worksheet set wb = workbooks.open(filename:=file.path, readonly:=false, ignorereadonlyrecommended:=true, editable:=true) set ws = wb.worksheets(1) ws.range("a1").interior.colorindex = 1 wb.close savechanges:=true else end if next end sub and here problem magnified: set wb = workbooks.open(filename:=file.path, readonly:=false, ignorereadonlyrecommended:=true, editable:=true) set ws = wb.worksheets(1)

rest - How to get plain XML from javax.ws.rs Entity on client side -

i have rest client creates xml entity via entity.entity(myobject, mediatype.application_xml_type) . after that, call webtarget.request().buildpost(... how can request body xml client send server? (i need debugging reasons.) here entity object. of course serialize myself marshaller same xml client send? you have clientrequestfilter following, simplified version of jersey's loggingfilter : import java.io.bytearrayoutputstream; import java.io.filteroutputstream; import java.io.ioexception; import java.io.outputstream; import java.nio.charset.charset; import java.nio.charset.standardcharsets; import java.util.logging.logger; import javax.annotation.priority; import javax.ws.rs.constrainedto; import javax.ws.rs.runtimetype; import javax.ws.rs.webapplicationexception; import javax.ws.rs.client.clientrequestcontext; import javax.ws.rs.client.clientrequestfilter; import javax.ws.rs.container.prematching; import javax.ws.rs.ext.writerinterceptor; import javax.ws.r

Custom picketlink identity store (using JOOQ) -

i want implement authentication picketlink in application, not using jpa (instead, i'm using jooq ). there way acquire user data using generated daos ? i couldn't find out reading documentation or looking @ quickstarts thanks in advance

xamarin - How to Populate a List<object> in XAML? -

i came know same thing string using link how populate list<string> in xaml? but need same on object (say string only).. use binding context populate list. set binding target list object , binding source source of data. look here example. think answers question.

jquery - Implementing timer Javascript - Trivia Game -

this question has answer here: the simplest possible javascript countdown timer? [closed] 3 answers i've written trivia game in javascript, having hard time understanding how correctly implement timer each question. i've made each question gets presented individually, , i'd have timer each question. if timer runs out, should proceed next question. here link jsfiddle if take few minutes , modify jsfiddle, or let me know i'd have in order make each question count down 10, i'd appreciate it. lot! timers in javascript work asynchronously. first thing should know. secondly depending on need can use either a: settimeout(function, timeout) 1 allows delay execution of function provided time provided (in milliseconds). setinterval(function, timer) 1 makes function call every timer milliseconds depending on how intertwine these cod

ios - Registering for Push Notifications does not get any response -

this question has answer here: didregisterforremotenotificationswithdevicetoken not called in ios8, didregister…settings is 8 answers i have app support push notifications under development couple of months now. push notifications worked fine until yesterday. now application not callbacks registering apns. didregisterforremotenotificationswithdevicetoken nor didfailtoregisterforremotenotificationswitherror in appdelegate called. why don't appdelegate callback when registering pn? registration called: let settings = uiusernotificationsettings(fortypes: [.alert, .badge, .sound], categories: nil) uiapplication.sharedapplication().registerusernotificationsettings(settings) uiapplication.sharedapplication().registerforremotenotifications() that not fault. there issue in apns on 19 july, 2016 . reference check didregisterforremotenotificationswithdevi

android - Error:Connection timed out: connect -

i changed version of gradle of android studio 1.5.1 1.5 2.10 , clicked sync now, (error image) follow error ocurred : error:connection timed out: connect. if behind http proxy, please configure proxy settings either in ide or gradle. go gradle.properties file in gradle scripts , add : systemprop.http.proxyhost=127.0.0.1 systemprop.http.proxyport=3128 // enter proxy port systemprop.https.proxyhost=127.0.0.1 systemprop.https.proxyport=3128 // enter proxy port. can find proxy port going internet option-> connections -> lan settings -> advanced -> port

ios - Subclassing NSInputStream, overriding delegate? -

Image
i've made nsinputstream subclass, when gets read actual data following exception. *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -setdelegate: defined abstract class. define -[eventuscore.fileuploadstream setdelegate:]!' i unable override the following property of nsstream abstract class: unowned(unsafe) public var delegate: nsstreamdelegate? here class inherits nsinputstream class inputstream : nsinputstream { private var currentstatus: nsstreamstatus = .closed // override var delegate: nsstreamdelegate? weak var delegate: nsstreamdelegate? override func open() { self.currentstatus = .open } override func close() { self.currentstatus = .closed } override var streamstatus: nsstreamstatus { return self.currentstatus } override var hasbytesavailable: bool { return self.currentstatus == .open } // mark: nsinputstream , cfreadstre

set minHeight and minWidth android AppWidget programatically -

is possible find on appwidget creation max number of cells can occupy appwidget. read documentation appwidgets in handsets can occupy 4x4 cells, set minheight , minwidth: android:minheight="320dip" android:minwidth="320dip" however test application on lg g4 h815 , found out device has 5x5 cell grid. question is possible found out max number of cells widget can occupy programatically on widget creation time. no, impossible :( can specify minwidth , minheight , default size of widget. on bigger grids, mentioned 5x5, user have choice have widget @ specified size or enlarge occupy more space. you can specify minresizewidth , minresizeheight , make widget impossible shrink below these values.

objective c - iOS Static library - is it possible to include AdSupport.framework in my library? -

i'm using objective-c, xcode7. i've created static library uses asidentifiermanager, included in "adsupport.framework". now when wants use *.a file, have include "adsupport.framework" in project well. is possible include "adsupport.framework" in compiled *.a library others not have to? no, system library. include requirement link in integration instructions. if you're supporting dependency manager cocoapods can define requirement in podspec taken care of them.

r - Compile notebook in RStudio when Hebrew characters are in the path? (currently, it fails) -

when pressing compile notebook button in rstudio, following error: error in file(con, "r") : cannot open connection in addition: warning message: in file(con, "r") : cannot open file 'c:/dropbox/teaching/tau/2016 - b/׳׳‘׳•׳ ׳׳¡׳˜׳˜׳™׳¡׳˜׳™׳§׳” - ׳׳¡׳˜׳˜׳™׳¡׳˜׳™׳§׳׳™׳/׳×׳™׳¨׳’׳•׳׳™׳/stat_intro_2016/intro_stat.r': no such file or directory this actual path: getwd() [1] "c:/dropbox/teaching/tau/2016 - b/מבוא לסטטיסטיקה - לסטטיסטיקאים/תירגולים/stat_intro_2016" here session info (i tried using: sys.setlocale("lc_all", "hebrew") , didn't help) > sessioninfo() r under development (unstable) (2016-02-08 r70124) platform: x86_64-w64-mingw32/x64 (64-bit) running under: windows 7 x64 (build 7601) service pack 1 locale: [1] lc_collate=hebrew_israel.1255 lc_ctype=hebrew_israel.1255 [3] lc_monetary=hebrew_israel.1255 lc_numeric=c [5] lc_time=hebrew_israel.1255 attached base packages: [1] st

python - Raster values extraction from Shapefile -

i have raster file contains polygons or lines draw mapping features. want extract along these polygons/lines values raster data , plot graph of elevations along pixels. in how extract arbitrary line of values numpy array? . time, polygon not line you have decide on sampling interval. can add points along line/polygon edges @ desired interval, , extract raster value @ points (using gdal/numpy). you need mindful of relation between raster resolution , sampling interval avoid artifacts "skipping" pixels or taking 2 samples in same pixel, , might want apply sort of filtering/interpolation on resulting profile.

Serializing "string list" to JSON in C# -

(i'v restated question here: creating class instances based on dynamic item lists ) i'm working on program in visual studio 2015 c#. i have 5 list strings contain data wish serialize json file. public list<string> name { get; private set; } public list<string> userimageurl { get; private set; } public list<string> nickname { get; private set; } public list<string> info { get; private set; } public list<string> available { get; private set; } an example of desired json file format fallowing: { "users" : [ { "name" : "name1", "userimageurl" : "userimageurl1", "nickname" : "nickname1", "info" : "info1", "available" : false, }, { "name" : "name2", "userimageurl" : "userimageurl2",

angularjs - Angular indexOf not outputting text -

i'm trying output name "sam" on screen in ng-show using indexof, nothing ever appears. appreciated. html <head></head> <body> <div ng-controller="arraycontroller"> <div ng-repeat="product in products"> <div ng-show="product.name.indexof('sam') == 2"> </div> </div> </div> <script src="bower_components/angular/angular.js"></script> <script src="app.js"></script> </body> </html> angular var app = angular.module('myapp', []); app.controller('arraycontroller', ['$scope', function($scope){ $scope.products = [ { name: 'joe' }, { name: 'bill' }, { name: 'sam' } ]; }]); possible solution using ng-if instead of ng-show <body ng-app="myapp"> <div ng-controller=

amp html - Prevent <amp-sidebar> from going back to the top of the page -

i'm trying create simple replacement previous hamburger menu, had navigation links scroll pageview specified section using href="#section" . since cannot use checkbox trick anymore, had use <amp-sidebar> it: <amp-sidebar id="sidebar" layout="nodisplay" side="right"> <ul> <li> <a href="#secion1">section 1</a> </li> <li> <a href="#secion2">section 2</a> </li> <li> <a href="#secion3">section 3</a> </li> </ul> </amp-sidebar> the problem is, every time sidebar closed, page gets scrolled it's top position (even url reverted original state, #section removed). is there way prevent behavior? that behaviour seems bug. please file issue on github project: https://github.com/ampproject/amphtml/issues/new

php - Swagger.io Slim Framework POST errors -

i used swagger generate slim framework server. without editing anything, testing basic functions. have 1 located @ /user/login . here script have it: $app = new slim\app(); $app->post('/user/login', function($request, $response, $args) { $queryparams = $request->getqueryparams(); $username = $queryparams['username']; $password = $queryparams['password']; $response->write("will not work"); return $response; }); $app->get('/user/{user_id}', function($request, $response, $args) { $response->write('works'); return $response; }); however, when try post url using postman (chrome app), results in 500 error. if try of get methods, works. seems happening post methods. i have running on ubuntu machine, apache2 installed php. have updated latest available versions. modrewrite enabled, , override set all. please help! @ such loss @ point. i found error. notice have 2 urls, 1 @ /

jQuery keyup/onchange bug -

a user can insert order values via large number (>500) of input fields on page: <input type="text" name="%id%" data-product_id="%id%" class="updateqtyfield" maxlength="4"> it isn't possible use 'save' button make use of jquery script updating insert data session: $("input.updateqtyfield").keyup(function() { $.post("update.php", { product_id: $(this).data('product_id'), qty: $(this).val() }, function(result) { if (result != 1) { alert(result); } }); }); unfortunately, there possibility $.post request didn't update field , have absolutely no idea why. because users of system working quick: insert value - tab - insert value - tab - etc. via log i've seen keyup trigger works well, $.post doesn't job. looks there isn't respons post job. i've tried use workaround via onchange action, isn't preforming well, again not fields updated correctly. opti

c# - Attribute Routing Values into Model/FromBody Parameter -

when using attribute routing in web api (2), able route parameters url model parameter automatically. reason validation performed in filter before reaches action, , without additional information not available. consider following simplified example: public class updateproductmodel { public int productid { get; set; } public string name { get; set; } } public class productscontroller : apicontroller { [httppost, route("/api/products/{productid:int}")] public void updateproduct(int productid, updateproductmodel model) { // model.productid should == productid, default (0) } } sample code post this: $.ajax({ url: '/api/products/5', type: 'post', data: { name: 'new name' // nb: no productid in data } }); i want productid field in model populated route parameters before entering action method (i.e. available validators). i'm not sure part of model binding process need try , o

android - Creating a gauge -

i'm trying create gauge. have png of blank gauge , second one, same size showing needle. idea overlay needle on top of gauge , rotate depending on value wish display. i'm having trouble placing 1 image on top of other. know how this? image within linearlayout.

ios - Adding view controllers to stack view programmatically -

the goal have few views own controllers (for example can view pickerview, label , search text field) , main view controller create these controllers. i tryed use stackview add these controllers main view. methods inside controllers invokes stack view empty. code of child control: class lookupcontrol: uiviewcontroller, uipickerviewdatasource, uipickerviewdelegate { @iboutlet weak var picker: uipickerview? var pickerdatasource = ["t1", "t2", "t3"]; override func viewdidload() { super.viewdidload() picker?.datasource = self picker?.delegate = self } func numberofcomponentsinpickerview(pickerview: uipickerview) -> int { return 1 } func pickerview(pickerview: uipickerview, numberofrowsincomponent component: int) -> int { return pickerdatasource.count } func pickerview(pickerview: uipickerview, titleforrow row: int, forcomponent component: int) -> string? { return pickerdatasource[row] } } code of parent contr

NullPointerException in Opening Android Activity -

this question has answer here: what nullpointerexception, , how fix it? 12 answers when cast elements other layout got error. final spinner maining = (spinner) findviewbyid(r.id.spinner); final edittext sub1 = (edittext) findviewbyid(r.id.sub1); final edittext sub2 = (edittext) findviewbyid(r.id.sub2); final edittext sub3 = (edittext) findviewbyid(r.id.sub3); final edittext sub4 = (edittext) findviewbyid(r.id.sub4); final edittext sub5 = (edittext) findviewbyid(r.id.sub5); final edittext sub6 = (edittext) findviewbyid(r.id.sub6); heres error caused by: java.lang.nullpointerexception: attempt invoke virtual method 'android.view.view android.view.window.findviewbyid(int)' on null object reference place code after setcontentview in activity. if want them available in every method of activity, declare them fields. public class m

db2400 - JOIN tables inside a subquery in DB2 -

i'm having trouble paginating joined tables in db2. want return rows 10-30 of query contains inner join. this works: select * ( select row_number() on (order u4slsmn.slname) id, u4slsmn.slno, u4slsmn.slname, u4slsmn.sllc u4slsmn) p p.id between 10 , 30 this not work: select * ( select row_number() on (order u4slsmn.slname) id, u4slsmn.slno, u4slsmn.slname, u4slsmn.sllc, u4const.c4name u4slsmn inner join u4const on u4slsmn.slno = u4const.c4name ) p p.id between 10 , 30 the error is: selection error involving field *n. note join query works correctly itself, not when it's run subquery. how perform join inside subquery in db2? works fine me on v7.1 tr9 here's ran: select * ( select rownumber() on (order vvname) id, idescr, vvname olsdta.ioritemmst inner join olsdta.vorvendmst on ivndno = vvndno ) p p.id between 10 , 30; i prefer cte version however: with p ( select rownumber()

mediacodec - Video encoded and sent from Android can not be played in iOS Telegram -

telegram use meidacodec encode video android api 16. works fine api 18. there error in api 16, 17. video encoded , sent android cannot played in ios. think problem in process converting color between output of decoder codec , input of encoder codec. https://github.com/drklo/telegram/blob/2114024ab1d9cf209916bcdb3a4a7d44e51a3b0c/tmessagesproj/src/main/java/org/telegram/messenger/mediacontroller.java#l3223 my application uses ffmpeg encode video. it's slow. mediacodec faster ffmpeg . works api 18. can solve problem video cannot played in ios? thanks.

java - What is the default for Optional data members in lombok using @Builder? -

suppose have class such : @builder class anidentifier { @nonnull //to indicate required builder private string mandatoryidpart; private optional<string> optionalidpart1; private optional<string> optionalidpart2; } when client creates object using builder generated lombok class , not set optional parts, set to? client have pass value wrapped in optional or value builder optional parts? here's tried out : public static void main(string[] args) { anidentifier id = anidentifier.builder().mandatoryidpart("added") .optionalidpart1(optional.of("abs")).build(); //line 1 id.optionalidpart2.ispresent(); //line2 } firstly line2 generated npe optionalidpart2 set null not optional.empty() secondly line1, setting optional value required putting string in optional, lombok doesn't take care of that. so use constructor such annotation: @builder public anidentifier(@nonnull string mandatoryi

javascript - React.js react-throttle with Meteor.js breaks in IE and Android Browser -

i'm writing meteor app (version 1.3.5.1) using react , version 15.2.0 , module react-throttle (version 0.3.0). when running on firefox, chrome, opera, safari (desktop , mobile) works fine. when running on ie or android browser (6.x), following error thrown: uncaught typeerror: _this.handlerstowrap.includes not function this line in file: /node_modules/react-throttle/lib/classes/processors/base.js if comment out line, works charm on browsers. to me seems handlerstowrap array . method includes on arrays seems es6 or es7 method , supported firefox,opera etc. not ie , android browser (i tested that). so question: how fix that? why meteor send es7-method client @ all? shouldn't transpile first? of course replace includes indexof or something... don't want mess around react code auto updated npm... few es7 features include not supported meteor babel package ecmascript . others spread/rest operators on objects implemented. see note here , un

python - Vectorizing three nested loops - NumPy -

i have 2 arrays x.dim = (n,4) , y.dim = (m, m, 2) , function f(a, b) , takes k , l dimensional vectors respectively arguments. want obtain array res.dim = (n, m, m) such that for n in range(n): in range(m): j in range(m): res[n, i, j] = f(x[n], y[i, j]) can't how use apply in case. in advance help! def f(a, b): return max(0, 1 - np.sum(np.square(np.divide(np.subtract(b, a[0:2]), a[2:4])))) here's vectorized approach work listed function using numpy broadcasting , slicing - # slice out relevant cols x x_slice1 = x[:,none,none,:2] x_slice2 = x[:,none,none,2:4] # perform operations using slices correspond iterative operations out = np.maximum(0,1-(np.divide(y-x_slice1,x_slice2)**2).sum(3))

Google map API reverse geocoding lookup country -

i want country longitude , latitude user enters.but can't country's using following $country = $code->results[0]->address_components[6]->long_name; because country name comes in $country1 = $code->results[5]->formatted_address; how common code country? you should checking types of country instead of index before getting long name. highly doubt country in same position addresses. https://developers.google.com/maps/documentation/geocoding/intro

Follow up on refering-a-parameter-to-another-parameter-in-testng-xml-file -

regarding post, refering parameter parameter in testng.xml file : 1. feature implemented? 2. alternative? thanks yes, put answer in question referred to.

xcode - Add device UDID to Free iOS Development Provisioning Profile -

i have created free ios development provisioning profile test app. want share app friend , have udid of device. don't have device run app run on xcode. how can add device udid provisioning profile share app. go developer portal (developer.apple.com) > account > certificates, identifiers, , profiles. in left menu, select devices , click + button add new device. give name , enter udid here. now go provisioning profile. click on , select edit. says devices, select new device added. generate provisioning profile , download xcode. your new device added provisioning profile , can run app on device.

php - MySQL stored procedure or function to return a person's name in a specific format -

i'm little fuzzy on difference between stored procedures , functions. have employee directory database data table containing, among other details, following name fields: first_name, varchar(45) mi, char(3) last_name, varchar(45) suffix, varchar(10) i'd able have function/procedure return full name in last_name ( suffix ), first_name ( mi ) format, fields in parentheses null optional in table. can build formatted name string in php select last_name, suffix, first_name, mi employee; , use series of conditionals test empty suffix , mi fields. but, i'd able use sql statement like select getdisplayname() last_name '%smith%'; to return result like smith iii, john q smith, susanne l smithers, waylon can point me in right direction or @ least tell me if need function or procedure? thanks. you can use function: drop function if exists getdisplayname; delimiter $$ create function getdisplayname(last_name text, suffix text, first_name tex

datetime - Unix Timestamp to PHP Year Month and Day Conversion Off -

we in process of moving our domain new dedicated server purchased. new server's time zone causing issues our attachments php code. our forum software uses following folder structure store attachments: /public_html/forum/files/2016/february/14/[filename] the year, month , day obtained file upload time stamp unix timestamp such "1455426488". timestamp converted year, month , day using following php code: $date = getdate((int)$attachment['filetime']); $filepath = $config['upload_path'] . '/' . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday']; this worked fine on our old server , server before it, on new server "day" either 1 day behind or 1 day ahead when converted, causes "february 14" file uploads either end in "february 13" folder or "february 15". keep in mind file upload time of 1455426488 in unix timestamp 02/14/2016 @ 5:08am u

rest - Secure HTTPS connection to Node.js server from client -

i developing backend mobile application using node.js handle https requests. have set ssl connect client server , wondering if secure enough. i don't have experience intercepting endpoints mobile devices, have seen possible people monitor internet traffic out of cellphones , pick endpoints server requests. have seen hacks on tinder people can see response json , automate swipes sending http requests tinder's endpoints. my real concern people able update/read/modify data on backend. can implement oauth2 schema still see cases in people abuse system. my main question whether or not using https secure enough protect data, or if session authentication system needed oauth2. thanks. https, providing configured, ensure message not read or changed en route , client can know server talking not fake. it secure transport. not secure application. for example supposing have app allows send message saying https://www.example.com/transfermoney?from=kyle&to=bazzad

javascript - Different intervals between images -

i studying gcse computing , need able change interval between different images. code @ moment looks this... <!doctype html> <html> <body> <h1> traffic lights can change on own </h1> <img src="red.jpg" id= "traffic" width="155" height="198"> <script> var myimage = document.getelementbyid("traffic"); var imagearray = ["red.jpg", "red-orange.jpg", "green.jpg", "orange.jpg"]; var imageindex = 0; function changeimage() { myimage.setattribute("src",imagearray[imageindex]); imageindex++; if (imageindex >= imagearray.length) { imageindex = 0; } } setinterval(changeimage,1000); </script> </body> </html>+ if include of code whilst changing intervals ideal. supposing want solve using javascript only: source documentation // save var timeoutid = window

python - Compare two datetime values with pandas? -

i make following comparison between 2 datetime values using pandas: for i1, df1_row in df1.iterrows(): i2, df2_row in df2.iterrows(): if df1['time'] >= df2['time']: print 'time 1 greater time 2' but getting following error: typeerror: can't compare datetime.time series both dates have been formatted same way using pd.to_datetime. know problem be?

c++ - How to get string from IFileDialogCustomize GetEditBoxText() in C# -

i trying use ifiledialogcustomize interface in c# using com calls. have call geteditboxtext(id, buffer) defined as: [methodimpl(methodimploptions.internalcall, methodcodetype = methodcodetype.runtime)] hresult geteditboxtext([in] int dwidctl, [out] intptr ppsztext); which got https://msdn.microsoft.com/en-us/library/windows/desktop/bb775908(v=vs.85).aspx the code have written is: intptr buffer = marshal.alloccotaskmem(sizeof(int)); string textboxstring; var customizedialog = getfiledialog() ifiledialogcustomize; if (customizedialog != null) { hresult result = customizedialog.geteditboxtext(id, buffer); if (result != hresult.s_ok) { throw new exception("couldn't parse string textbox"); } } textboxstring = marshal.ptrtostringuni(buffer); marshal.freecotaskmem(buffer); return textboxstring; the string returns odd character

javascript - ajax not posting form variables -

i have form uses ajax post variables php handler. now, what's weird on same page have couple of other forms work correctly (and more echo variables). work correctly , doing things same, reason 1 won't. can spot error? also, actual request successful, because if put echo in php, returned console.log in success callback. form: <div class="doctor_register" > <form id = 'doctor_register' method ='post'> <input type ='hidden' name ='type' value='doctor'> <input type ='hidden' name='act' value='create'> <table> <tbody> <br></br> <tr> <td><input type="text" name ='first_name' size='8' placeholder='first name'/></td> <td>