Posts

Showing posts from January, 2010

ios - How to check if an app is installed from a web-page on an iPhone? -

i want create web-page, page redirect iphone app-store if iphone not have application installed, if iphone has app installed want open application. i have implemented custom url in iphone application have url application like: myapp:// and if url invalid, want page redirect app store. possible @ all? if don't have application installed on phone , write myapp:// url in safari, error message. even if there exists ugly hack javascript know? as far know can not, browser, check if app installed or not. but can try redirecting phone app, , if nothing happens redirect phone specified page, this: settimeout(function () { window.location = "https://itunes.apple.com/appdir"; }, 25); window.location = "appname://"; if second line of code gives result first row never executed. hope helps! similar question: iphone browser: checking if iphone app installed browser is possible register http+domain-based url scheme iphone apps, youtube , map

What does it mean intent.setFlags(805306368) in android -

i used line of code launch app intent.setflags(805306368); , launches app , resumes if running in background. integer number 805306368 mean? resume app if running.does know. 805306368 equivalent 0x30000000 in hex , 0x30000000 used open intent following flags : intent.flag_activity_new_task|intent.flag_activity_single_top so, equivalent use above combination or 0x30000000 . from android docs flag_activity_single_top , flag_activity_new_task : flag_activity_single_top = 0x20000000 flag_activity_new_task = 0x10000000 so, combination results in 0x30000000 also, mentioned in docs new task flag i.e, flag_activity_new_task used achieve following behaviour: when using flag, if task running activity starting, new activity not started; instead, current task brought front of screen state last in. and single top flag i.e, flag_activity_single_top used achieve following behaviour, mentioned in docs : if set, activity not launched if running @ to

regex - PHP Code generator based on templates -

i want generate code based on templates. suppose in /templates have files structured as: /templates vendor/plugin/config.xml vendor/plugin/model/plugin.php vendor/plugin/view/plugin.phtml and files have following contents(variables enclosed {{ }} needs parsed): vendor/plugin/config.xml: <?xml version="1.0"?> <config> <module>{{vendor}}/{{plugin}}</module> <version>{{version}}</version> {{if $hastable}} <database> <table>{{tablename}}</table> <pk>{{primarykey}}</pk> <fields> {{foreach $fields}} <field> <name>{{fields.name}}</name> <label>{{fields.label}}</label> <type>{{fields.type}}</type> </field> {{/foreach}} </fields> </database> {{/if}} </config> vendor/plugin/m

Scala interop with Java overriding method with Object -

i have java interface public interface ifoo { list<map<string, object>> getmaps() throws exception; } how can override method ? tried : import scala.collection.javaconverters._ class foo extends ifoo{ override def getmaps: util.list[util.map[string,anyref]] = { list(map("a" -> "b")).asjava } } but getting compilation error overriding method getmaps in trait ifoo of type ()java.util.list[java.util.map[string,object]]; [error] method getmaps has incompatible type i can : import scala.collection.javaconverters._ class foo extends ifoo{ override def getmaps: util.list[util.map[string,anyref]] = { list(map("a" -> "b".asinstanceof[anyref)).asjava } } but correct way ? you need convert map java map well, , there better way provide value type: list(map[string, anyref]("a" -> "b").asjava).asjava

cocoa touch - Display interactive local push notifications on lock screen iOS -

i have configured local push notification category 2 actions. push notifications run fine, , handling these notifications in application:(uiapplication *)application handleactionwithidentifier:(nsstring *)identifier method inside appdelegate. my question how can go only displaying such notifications on user's lock screen? assumptions willresigninactive method app can still run after user locks device, while @ least. way fire notification after user locks device custom actions usable lock screen. any appreciated. i don't think have access specific event out of app jurisdiction thats why there applicationdidbecomeactive , applicationwillterminate etc. borders, can time after 10 mins , hope locked phone? or more accurate can check if did put phone down, check answer: lock unlock events iphone

Finding standard deviation in c++ with file -

Image
write program takes input file of numbers of type double. program outputs screen standard deviation of numbers in file. file contains nothing numbers of type double separated blanks and/or line breaks. standard deviation of list of numbers x1, x2, x3, , forth defined square root of: ((x1 – a)2 + (x2 – a)2 + (x3 – a)2 + ...) / (n - 1) where number average of numbers x1, x2, x3, , forth , number n count of how many numbers there are. your program should take file name input user. i have created file in computer. when finish code , try compiled it, cannot open file in compiler. don't know problem going on. can give me advices? #include <stdio.h> #include <iostream> #include <cmath> #include <fstream> #include <string> using namespace std; int main() { double next, avg,var,stddev, sum=0, sumsq=0; int count=0; cout << "enter filename:" << endl; std::string filename; cin >> filename; ifst

java - Standard Input/Output ignoring content -

i have writtten code accepts user input console , stores file on desktop. works fine when run program on ide. run on network (xinetd exact) when enter "localhost" on browser, xinetd redirects std input/output displayed on browser. in case, user input entered via console displayed on browser: here code: public static void main(string[] args) throws ioexception { arraylist<string> output = new arraylist<>(); try (bufferedwriter bw = new bufferedwriter(new filewriter(new file("c:\\users\\anthony\\desktop\\out.txt"))); bufferedreader br = new bufferedreader(new inputstreamreader(system.in))){ system.out.println("enter text"); for(string in=br.readline(); !in.equals(""); in=br.readline()){ bw.write(in); output.add(in); } system.out.println(output); } system.out.println("zugriff aufgezeichnet"); } when run on network: 1) i'm prompted ente

CSS - Centering a footer background image -

in mvc app, have footer on each page containing image. i'd center image if possible. current css looks follows: footer { position:absolute; bottom:-150px; /* puts footer 100px below bottom of page*/ width:70%; height:175px; /* height of footer */ background-image: url("/images/footer/footer3.png"); background-repeat: no-repeat; border-top: 1px solid darkgray; } what need add center image? you need add background-position property like: see here footer { position:absolute; bottom:-150px; /* puts footer 100px below bottom of page*/ width:70%; height:175px; /* height of footer */ background-position: center; background-image: url("/images/footer/footer3.png"); background-repeat: no-repeat; border-top: 1px solid darkgray; }

angularjs - Angular templates - inject paramters -

i developing lot of popups same set of buttons: save, apply, , cancel. thinking have cached template hold these buttons. adding template this: <ng-include src="'templates/popupbuttongrouptemplate.html'"></ng- include> and loading templates this: $http.get('templates/popupbuttongrouptemplate.html', { cache: $templatecache }); that works. need manipulate these buttons. specifically, set them true or false depending on user changes form template added to. how can have code included alone template every time template added form , how send parameter code specify form name use while watching user changes? thanks

android - How to find all the esp8266 connected to a router -

hi want connect multiple esp8266 devices router , create mobile app can find devices , send messages them using udp. plan let esp devices listen port , app send message on port, esp respond , app store ip. is there better way that? friend of mine told me approach fail if routers's gateway changed. true? i calling wifi.begin(ssid, password); connect wifi without doing changes wifi.conf(). i using arduino sdk. one way check mac addresses on network. first 6 digits unique code company made wifi dongle. this assuming not have other devices on network using same dongle , aren't you're trying search for. you can find mac addresses on network performing arp request on each ip. but devices have on same subnet. if devices remote, go original plan, friend correct if gateway changes require little more robust. use dynamic dns service along domain name. dynamic dns update dns records in real time if gateway address changes.

android - How do I change color of RadioButtons in PopupMenu? -

how set color of radiobutton s in checkable popupmenu . using appcompat version. set background color , text color via styles, cannot figure out how set color of radio buttons. this have far; <style name="apptheme" parent="theme.appcompat.daynight.noactionbar"> <item name="popupmenustyle">@style/mypopupmenustyle</item> <item name="textappearancelargepopupmenu">@style/mypopupmenutextappearancelarge</item> <item name="textappearancesmallpopupmenu">@style/mypopupmenutextappearancesmall</item> </style> <style name="mypopupmenustyle" parent="widget.appcompat.popupmenu"> <item name="android:popupbackground">@color/accent</item> <item name="android:textcolor">@android:color/white</item> </style> <style name="mypopupmenutextappearancesmall" p

apache - CSS/JavaScript not getting loaded inextended URL created using wordpress path based multisite network -

need assistance here respect rewrite rules of apache httpd . the issue configuring multisite using wordpress . able create extended url using path based multisite feature of wordpress . extended url http://www.example.com.au/support/ the issue extended url is not loading css/java scripts when loading extended url . that's why ui looks broken extended url . looks not able load files css/java scripts available. telling contents of access log file shown below. 10.200.64.39 "-" - - [02/nov/2015:00:29:37 +1100] "get /support/wp-content/themes/twentyfifteen/js/functions.js?ver=20150330 http/1.1" 404 9402 "http://www.example.com.au/support/wp-admin/" "mozilla/5.0 (windows nt 6.1; wow64; rv:40.0) gecko/20100101 firefox/40.0" 39020 "-" "cookies:wordpress_test_cookie=wp+cookie+check; it showing 404 not found following file get /support/wp-content/themes/twentyfifteen/js/functions.js?ver=20150330 http/1.1"

Image is stretched vertically while using Glide in Grid View Android -

i made app displays images stored locally in grid view.i used use picasso stopped using due many issues(it didn't load images on devices).then switched glide,everything fine except image stretched vertically. causes scrolling issue.i never faced such issue while using picasso.how can fix issue ??? my mainactivity code- glide.with(mainactivity.this) .load(mthumbids[position]) .placeholder(r.raw.place_holder) .error(r.raw.big_problem) .centercrop() .into(imageview); return imageview; my activity_main.xml file code <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" xmlns:ads="http://schemas.android.com/apk/res-auto" android:background="@color/colorprimary" android:layout_

Pseudocode: Confusing syntax "<>" and "variable:2:6" -

Image
i studying pseudo code, , despite 3 year history in programming, 1 particular practice-exam question has me perplexed unconventional code (shown below): highlighted in pink, 2 main problems code. have experience across 3 languages, yet have never encountered control flow method <> , , cannot imagine used for. in addition this, variable average appears in code in form of " average:6:2 ", equally clueless. to summarise: what function of control flow method "<>" as stated in question (a) in image above, purpose of 'average:6:2'? <> common not equal while number not equal 999 number:filed_width:precision pascal formatter real number filed_width being space field , precision numer of digits after dot. 3.141519:4:1 print <space>3.1

node.js - App bundles, but can't load assets from a node module at runtime -

i'm building application loading assets node_module. bundles fine, on runtime when navigate page, it's failing find webfonts used scss file i'm importing node module. i see error in browser's javascript console: bundle.js:129 uncaught error: cannot find module "../fonts/webfonts/salesforcesans-light.woff2" the node module i'm importing scss structured so: @salesforce-ux/design-system/ ├── assets │   ├── fonts │   │   └── webfonts │   │   └── [...all fonts...] │   ├── icons │   ├── images │   └── styles ├── scss │ ├── index.scss └── swatches my webpack config: var path = require('path'); var webpack = require('webpack'); module.exports = { entry: './src/myapp.js', output: { path: path.join(__dirname, '../public/dist'), filename: 'bundle.js' }, module: { preloaders: [ {test: /\.js$/, loader: 'eslint', exclude: /node_modules/} ],

pipe - Difference between x | y and y <(x) in bash? -

is there difference between command1 | command2 , command2 <(command1) ? for example, git diff | more vs more <(git diff) my understanding both take stdout of command2 , pipe stdin of command1 . the main difference <( ... ) , called "process substitution", translated shell filename passed regular argument command; doesn't send command's standard input. means can't used directly commands such tr don't take filename argument: $ tr a-z a-z <(echo hello) usage: tr [-ccsu] string1 string2 tr [-ccu] -d string1 tr [-ccu] -s string1 tr [-ccu] -ds string1 string2 however, can put < in front of <( ... ) turn input redirection instead: $ tr a-z a-z < <(echo hello) hello and because generates filename, can use process substitution commands take more 1 file argument: $ diff -u <(echo $'foo\nbar\nbaz') <(echo $'foo\nbaz\nzoo') --- /dev/fd/63 2016-07-15 14:48:52.000000000 -0

project - Python battleship, doubble the trouble -

i have question, why ask twice want put battleship? have no clue way does. anyway in link can see full code, because don't know if necessary. http://speedy.sh/qyjwp/battleship-goed.txt i think problem occurs before //_________________________________________________________// part board1 = [] board2 = [] x in range(10): board1.append(["o"] * 10) x in range(10): board2.append(["o"] * 10) def print_board1(board): row in board: print " ".join(row) def print_board2(board): row in board: print " ".join(row) print "board user 1" print_board1(board1) print "----------------------------------------------" print "board user 2" print_board2(board2) print "let's play battleship!" print "try destroy opponents battleship!" print"good luck!" print " "

animation - Can't get my program to animate multiple patches in python matplotlib -

i attempting animate 2 different particles in matplotlib (python). figured out way animate 1 particle in matplotlib, havign difficulties trying program work multiple particles. know wrong , how fix it? import numpy np matplotlib import pyplot plt matplotlib import animation fig = plt.figure() fig.set_dpi(100) fig.set_size_inches(5, 4.5) ax = plt.axes(xlim=(0, 100), ylim=(0, 100)) enemy = plt.circle((10, -10), 0.75, fc='r') agent = plt.circle((10, -10), 0.75, fc='b') def init(): #enemy.center = (5, 5) #agent.center = (5, 5) ax.add_patch(agent) ax.add_patch(enemy) return [] def animationmanage(i,agent,enemy): patches = [] enemy.center = (5, 5) agent.center = (5, 5) enemy_patches = animatecos(i,agent) agent_patches = animateline(i,enemy) patches[enemy_patches, agent_patches] #patches.append(ax.add_patch(enemy_patches)) #patches.append(ax.add_patch(agent_patches)) return enemy_patches def animatecirc

python - Matplotlib AutoDateLocator not working with DatetimeIndex -

i have dataframe datetimeindex so: in [3]: index = pd.date_range('september 1 2014', 'september 1 2015', freq='m') ...: index out[3]: datetimeindex(['2014-09-30', '2014-10-31', '2014-11-30', '2014-12-31', '2015-01-31', '2015-02-28', '2015-03-31', '2015-04-30', '2015-05-31', '2015-06-30', '2015-07-31', '2015-08-31'], dtype='datetime64[ns]', freq='m' plotting without changing x tick labels or explicit date formatting yields x-axis 0-12. my figure contains 13 subplots in 1 column. i'm trying set x-axis on last plot using autodatelocator() @ end of code after subplots plotted: fig.axes[-1].xaxis.set_major_locator(mdates.autodatelocator()) which returns following error: valueerror: ordinal must >= 1 i tried converting dataframe index dates2num suggested here yielded same result:

vba - How to open an Excel file from MS Access? -

i trying open excel file, in ms acesss, select using filedialogfilepicker . however, when select excel file "open" prompt turns "ok" , unable open it. know how solve problem? below working code selects file. dim f filedialog set f = application.filedialog(msofiledialogfilepicker) f.show thank you! below final code: dim f filedialog, str string set f = application.filedialog(msofiledialogfilepicker) f.show str = f.selecteditems(1) dim xl excel.application set xl = new excel.application xl.visible = true xl.workbooks.open (str)

google app engine - GAE go only serves paths on localhost not domain -

i messing around small go app google app engine locally using appengine sdk. i have problem path different root can served if try hit using localhost, not domain name. my setup follows. home.mydomain.com points home ip adress my home router forwards incoming tcp , udp on port 80 laptop on port 8080 my laptop running windows 10 my go version go1.6 windows/amd64 my app.yaml: application: tasks version: 1 runtime: go api_version: go1 handlers: - url: /.* script: _go_app minimum example code: func init() { filehandler := http.fileserver(http.dir("../frontend")) http.handlefunc("/loggedout", testhandler) http.handle("/", filehandler) log.print(http.listenandserve(":8080", nil)) } func testhandler(res http.responsewriter, req *http.request){ panic("just need work") } my symptoms if access localhost:8080/ website, , if access localhost:8080/loggedout expected panic. if access home.mydoma

ios - Network Connection Checker via Reachability class swift 2.0 -

i trying check internet connection status via reachability.swift class has written in swift 2.0. here class code: import uikit import foundation import systemconfiguration public class reachability: nsobject { class func isconnectedtonetwork() -> bool { var zeroaddress = sockaddr_in(sin_len: 0, sin_family: 0, sin_port: 0, sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)) zeroaddress.sin_len = uint8(sizeofvalue(zeroaddress)) zeroaddress.sin_family = sa_family_t(af_inet) let defaultroutereachability = withunsafepointer(&zeroaddress) { scnetworkreachabilitycreatewithaddress(kcfallocatordefault, unsafepointer($0)) } var flags: scnetworkreachabilityflags = scnetworkreachabilityflags(rawvalue: 0) if scnetworkreachabilitygetflags(defaultroutereachability!, &flags) == false { return false } let isreachable = flags == .reachable let needsconnection =

ios - AVCaptureDevice.requestAccess() crash -

i created ios single view application using swift 3.0 , xcode 8 beta 2. linking avfoundation.framework . this view controller code: import uikit import avfoundation class viewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() if avcapturedevice.authorizationstatus(formediatype: avmediatypevideo) == .notdetermined { avcapturedevice.requestaccess(formediatype: avmediatypevideo, completionhandler: { (granted: bool) in if granted { print("granted") } else { print("not granted") } }) } } } when run on device app crashes after executing avcapture.requestaccess line (the completion handler not executed , no exceptions thrown). the thing in console is: 2016-07-15 14:55:44.621819 testpp[2261:912051] [mc] system group container systemgroup.com.apple.configurationprofiles path /private/var/containers/shared/systemgroup/systemgroup.com.apple.configurat

powershell - Dot sourcing a file doesn't work -

im following this question can't seem working. (for sake of testing) have powershell module 2 scripts: variables.ps1 , function.ps1 , manifest mymodule.psd1 (these files in same directory) this content of variables.ps1: $a = 1; $b = 2; this content of function.ps1 . .\variables.ps1 function myfunction { write-host $a write-host $b } when import module , call myfunction. output: c:\> import-module .\mymodule.psd1 c:\> myfunction . : term '.\variables.ps1' not recognized name of cmdlet, function, script file, or operable program. check spelling of name, or if path included, verify path correct , try again. @ c:\users\jake\mymodule\function.ps.ps1:8 char:4 + . .\variables.ps1 + ~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : objectnotfound: (.\variables.ps1:string) [], parentcontainserrorrecordexception + fullyqualifiederrorid : commandnotfoundexception why doesn't work? when use relative paths in scripts, they&

php - Redirect with Variables in Laravel | Payment Gateway -

i see lot of similar questions being asked on stack overflow none seem work me. hence asking here. the case simple. trying integrate payment gateway - asking me submit form set of data it's url. url: https://test.examplepg.com/_payment form\parameters: <form action="<?php echo $action; ?>" method="post" name="payuform"> <input type="hidden" name="_token" value="<?php csrf_token() ?>"> <input type="hidden" name="key" value="<?php echo $merchant_key ?>" /> <input type="hidden" name="hash" value="<?php echo $hash ?>"/> <input type="hidden" name="txnid" value="<?php echo $txnid ?>" /> <input type="hidden" name="amount" value="<?php echo $amount ?>" /> <input type="hidden" name="first

objective c - Signed byte array to UIImage -

i trying display picture byte-array produced web service. printing out description looks this: ("-119",80,78,71,13,10,26,10,0,0,0,13,3 ... ) header clear it's png encoded in signed integers. __nscfarray having __nscfnumber elements. my code in objective-c (based on googling): nsdata *data = [nsdata datawithbytes:(const void *)myimagearray length [myimagearray count]]; uiimage *arrayimage = [uiimage imagewithdata:data]; i receive null uiimage pointer. tried converting unsigned nsnumbers first , passing nsdata, though perhaps did not correctly. doing wrong? you cannot cast nsarray of nsnumber binary data. both nsarray , nsnumber objects; have own headers , internal structure not same original string of bytes. you'll need convert byte-by-byte along these lines: nsarray *bytes = @[@1, @2, @3]; nsmutabledata *data = [nsmutabledata datawithlength:bytes.count]; (nsuinteger = 0; < bytes.count; i++) { char value = [bytes[i] charvalue]; [dat

python - What is the correct keyword for this line of code? -

the purpose of code extract number text file assigned variable called 3; the code: with open(three) f: the_list = [int(l.strip().split()[1]) l in f] can explain reason why text file abbreviated letter 'f'. , the_list = [int(l.strip().split()[1]) l in f] it's short name. can use valid name want following as keyword. here, short, one-letter name used because there no need emphasize name of file object is. the second line creates list of integers stored in second field of each line of file. input file looks like foo 3 hello 17 whatever 0 which produces list like [3, 17, 0] ( l.strip() removes leading , trailing whitespace line; split() creates list consisting of whitespace-separated fields, indexed grab second field; , result passed int produce int object string.)

python - numpy and matplotlib entry point error in anaconda windows 64 bit -

import numpy np import matplotlib.pyplot plt x = [2,3,4,5,7,9,13,15,17] plt.plot(x) plt.ylabel('sunlight') plt.xlabel('time') plt.show() while executing in anaconda got error entry point not found:"the procedure entry point mkl_aa_fw_get_max_memory not located in dynamic link library mkl_core.dll" can please tell how resolve issue

Implement a queue type in F# -

i'm trying implement queue in f# far have think it's acting more stack: type 'a queue = nl| que of 'a * 'a queue;; let enque m = function |nl -> que(m, nl) |que(x, xs) -> que(m, que(x, xs));; let rec peek = function |nl -> failwith "queue empty" |que(x, xs) -> x;; let rec deque = function |nl -> failwith "queue empty" |que(x, xs) -> xs;; let rec build = function | [] -> nl | x::xs -> enque x (build xs);; the operations working fine except enque, want make adds new element of queue instead of front. currently putting @ front ; if want enqueue @ end of queue have progress way end , put value : let rec enque m = function nl -> que (m, nl) | que (x, xs) -> que (x, enque m xs) // note : not tail-rec

How do I load webpack resource in JSON -

i have following code... [ { "number": 0, "color": "blue", "content": require('./first-card.pug') } ... ] when try run webpack see... error in ./src/app/jg/cards/cards.json module build failed: syntaxerror: unexpected token r @ object.parse (native) do need escape or something?

c# - Is it possible to put multiple data types into a JSON file? -

i serializing , writing object list json file c# code: string json = jsonconvert.serializeobject(drawlist); file.writealltext(@"c:\my\sample\path\package.json", json); is possible write integer json file, , if how should parsed list , integer separate? sure. string json = jsonconvert.serializeobject(new {integer = 1, list = drawlist}); file.writealltext(@"c:\my\sample\path\package.json", json);

mysql - How to query database in WordPress and loop through results -

i've been used making simple pdo queries mysql this: $query = $db->prepare("select * `my_table` order `rank`"); $query->execute(); $numrows = $query->rowcount(); while($row = $query->fetch()) { $thiscolumn = $row['value']; } but want same using wordpress (not 1 of wordpress's own tables, 1 of own). simplest way of translating query? global $wpdb; $query = "select * `my_table` order `rank`"; $result = $wpdb->get_results($query); foreach ($result $instance) { echo $instance->value; }

How to hide views in android when android app is backgrounded (not to stop android to take snapshot when backgrounded) -

Image
this question has answer here: how prevent android taking screenshot when app goes background? 3 answers i want hide views when app backgrounded. e.g. want hide "live debug mode" textview when app backgrounded. add following code oncreate : @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().setflags(windowmanager.layoutparams.flag_secure, windowmanager.layoutparams.flag_secure); setcontentview(r.layout.activity_main2); //...rest of code }

jquery - Ajax download image in template -

i have image in applications directory. want use image in template. use ajax request getting path of image , want show image in template. how can it? code: def posts(request): if request.is_ajax(): offset = request.get.get('offset') limit = request.get.get('limit') all_posts = post.objects.all().order_by('-pub_date')[offset:limit] if all_posts: data = [] obj in all_posts: # image = postimage.objects.filter(pk=obj.pk) image = obj.postimage_set.all() js = { 'info': 'success', 'id': obj.pk, 'title': obj.title, 'description': obj.description, 'pub_date': obj.pub_date.strftime("%d.%m.%y %h:%m"), } if image: img = {'image': str(image[0].image)} else: img = {'image': ''

c# - Is it possible to use a dash character in variable name .net Web API? -

the request sms api delivery report information sms. one of variable posted api this: ?err-code=0. possible in .net web api solution or should use language? web api method: public httpresponsemessage get([fromuri]testmodel testingdetials) { return request.createresponse(system.net.httpstatuscode.ok); } model public class testmodel { public string foo { get; set; } public string err_code { get;set; } } i tried various solution found on website none of them work adding [jsonproperty] , [datamember] err_code property. you can use [jsonproperty(propertyname = "err-code")] provided request being received json. because jsonproperty part of newtonsoft json serializer library web api uses deserialize json. if request not json, library not used in pipeline. as mentioned can use httpcontext. if remember correctly model binding in mvc converts '-' '_' wrong. regardless continue using typed mod

c# - Dynamic Combo Box Will Not Resize -

i'm trying create dynamic form. found on web: http://csharp.net-informations.com/gui/dynamic-controls-cs.htm and works. however, needed combo box , worked, but, couldn't resize it. here code: code any appreciated. can see, tried resize before placing on form. no compile error. don't know. the height of combobox automatically adjusted specified size of font. can't change height unless increase font. this: box.font = new font(box.font.fontfamily, 16);

Rails/rspec, integration test fail with "no route matches" but route does exist -

i doing simple integration testing. want test sold_items action in users controller. have confirmed route exists , returns json accessing browser. however, rspec telling me route doesn't exist. please see below, spec, error, , route.rb. thanks! spec: require 'rails_helper' rspec.describe userscontroller, type: :controller describe "get #items" "returns http success" user = factorygirl.create(:user) "users/#{user.id}/sold_items" expect(response).to have_http_status(:success) end end end fail message: 1) userscontroller #items returns http success failure/error: "users/#{user.id}/sold_items" actioncontroller::urlgenerationerror: no route matches {:action=>"users/10/sold_items", :controller=>"users"} # ./spec/controllers/users_controller_spec.rb:8:in `block (3 levels) in <top (required)>' routes.rb rails.application.

javascript - How to pass selected option using knockout to an observable array -

i trying pass selected value of drop down list view model using knockout js. <select class="form-control" style="width:auto" data-bind="options: clients, optionscaption: 'choose...', optionstext: 'name', optionsvalue: 'value', value: 'selectedcustomer'"></select> in view model, have declared ko observable store selected value: self.selectedcustomer = ko.observablearray([]); the variable not getting populated when select value. tips? thanks! i can see 2 issues code: you're binding value observablearray , selected option single customer observable should used instead. the value ( value: 'selectedcustomer' ) should not wrapped in single quotes because you're trying bind string rather observable. try below: <select class="form-control" style="width:auto" data-bind="options: clients, optionscaption: 'choose...', optionstext: 'name

How to call functions in python files that are not in the working directory? -

say working folder . , supporting python files in ./supporting_files/ , want call function func in a.py file under ./supporting_files/ , should do? tried calling from supporting_files.a import func , not work. how suppose without changing actual working directory? add __init__.py file (it can empty) supporting_files directory, , python treat package available imports. more details available in python documentation .

getSupportFragmentManager().findFragmentById returns null for google maps in fragment in android? -

i have problem google maps, i.e. getsupportfragmentmanager().findfragmentbyid returns null. have idea how solve this? here code: fragment_map.xml: <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.myapp.something.mapfragment"> <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.supportmapfragment" /> </framelayout> mapsfragment.java: public class mapfragment extends fragment implements onmapreadycallback, android.location.locationlistener public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); supportmapfragment mapfragment = (supportmapfragment) thi

hive - Combining data based on column in spark -

i have data in following format in hive table. user | purchase | time_of_purchase i want data in user | list of purchases ordered time how do in pyspark or hiveql? i have tried using collect_list in hive not retain order correctly timestamp. edit : adding sample data asked kartikkannapur. here sample data 94438fef-c503-4326-9562-230e78796f16 | bread | jul 7 20:48 94438fef-c503-4326-9562-230e78796f16 | shaving cream | july 10 14:20 a0dcbb3b-d1dd-43aa-91d7-e92f48cee0ad | milk | july 7 3:48 a0dcbb3b-d1dd-43aa-91d7-e92f48cee0ad | bread | july 7 3:49 a0dcbb3b-d1dd-43aa-91d7-e92f48cee0ad | lotion | july 7 15:30 the output want 94438fef-c503-4326-9562-230e78796f16 | bread , shaving cream a0dcbb3b-d1dd-43aa-91d7-e92f48cee0ad | milk , bread , lotion one way of doing is first create hive context , read table rdd. from pyspark import hivecontext purchaselist = hivecontext(sc).sql('from purchaselist select *') then process rdd from datetime import d

javascript - AJAX GET request in Rails without rendering views/json -

making get request check whether or not send followup post request , don't need render following first request. i'm using render nothing: true @ base of controller action, i'm not sure what's causing actionview::missingtemplate @ /able_to_claim error when sent request through browser console: def able_to_claim role, user_id = params[:role], params[:user_id] if role == "senior editor" or role == "admin" return true else active_essays = 0 claim.where(:user_id => user_id).each {|claim| active_essays += 1 if essay.find(claim.essay_id).status != "complete"} if role == "editor" , active_essays < 5 return true elsif role == "managing editor" , active_essays < 15 return true else return false end end render nothing: true end route: get '/able_to_claim' => 'users#able_to_claim' j

r - Download ggvis plot from reactive set -

i have shiny app allows user choose plot on x , y axis based on loaded data frame. trying allow user download current plot view. opening launching app in google chrome because know not work save file if app launched within r studio. of saves png file, blank. screenshot of app ui can seen here i have used these posts try resolve issue: downloading png shiny (r) downloading png shiny (r) pt. 2 the app not work if vis() changed function rather reactive. however, when filtereddata() changed reactive function, app still works same. however, blank png still yield if within downloadhandler(... have vis() , filtereddata() or print(filtereddata()) . if print(vis()) used, window pops in browser says "key / in use". minimal working code replicates issue below , can provide appreciated. #check packages use in library library('shiny') #allows shiny app used library('stringr') #string opperator library('ggvis') #allows interactive plotin

android - No resource identifier found for attribute -

i trying learn bit of material design , have run error putting app have never seen before , cant figure out how fix. the error /users/rory/downloads/materialdesign/app/src/main/res/layout/activity_detail.xml error:(89) no resource identifier found attribute 'uirotategestures' in package 'info.androidhive.materialdesign' error:(89) no resource identifier found attribute 'uiscrollgestures' in package 'info.androidhive.materialdesign' error:(89) no resource identifier found attribute 'uitiltgestures' in package 'info.androidhive.materialdesign' error:(89) no resource identifier found attribute 'uizoomcontrols' in package 'info.androidhive.materialdesign' error:(89) no resource identifier found attribute 'uizoomgestures' in package 'info.androidhive.materialdesign' i have tried solutions show here error: no resource identifier found attribute 'adsize' in package 'com.google.example' ma

numbers - Where to use decimal.ROUND_05UP in Python? -

the decimal module in python provides option rounding decimal : round_05up what practical uses type of rounding? the ieee decimal arithmetic spec has it: the rounding mode round-05up permits arithmetic @ shorter lengths emulated in fixed-precision environment without double rounding. example, multiplication @ precision of 9 can effected carrying out multiplication @ (say) 16 digits using round-05up , rounding required length using desired rounding algorithm. in other words, if round 1 precision using round_05up , round shorter precision using other rounding mode, result same if had directly rounded shorter precision.

vb.net - Bing Streetside view & Location look up -

hi have implemented bing maps application using xaml , vb have in aerial mode know how modify when zoom in give me option go street side view, i'm implementing address lookup through use of textbox , button click. xaml <window x:class="mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:m="clr-namespace:microsoft.maps.mapcontrol.wpf;assembly=microsoft.maps.mapcontrol.wpf" title="mainwindow" height="350" width="525"> <grid > <m:map credentialsprovider="my key" x:name="bingmap"/> </grid> vb imports microsoft.maps.mapcontrol.wpf partial public class mainwindow inherits window public sub new() initializecomponent() 'set map mode aerial labels bingmap.mode = new aerialmode(true) end sub end class this current set up. streetside not av

how to plot graph of simple function in sas? -

is there way plot simple graph in sas without using data set? instance y=x^2. multiple functions in same graph? feel should easy, i'm still new sas ive had trouble figuring out. to best of knowledge, every graphing proc requires @ least 1 input dataset. isn't hard make one, though, e.g. data parabola; x = 1 10; y = x**2; output; end; run;

google compute engine - unable to create instance with gcloud command -

i'm trying create instance in google compute getting error. gcloud compute instances create 'my-instance' following instances: - [my-instance] choose zone: [1] asia-east1-b [2] asia-east1-c [3] asia-east1-a [4] europe-west1-c [5] europe-west1-b [6] europe-west1-d [7] us-central1-f [8] us-central1-a [9] us-central1-c [10] us-central1-b [11] us-east1-b [12] us-east1-d [13] us-east1-c please enter numeric choice: 11 error: (gcloud.compute.instances.create) requests did not succeed: - resource 'xxxxx@project.gserviceaccount.com' of type 'serviceaccount' not found. the resource isn't listed in iam or serviceaccount lists. first assure have initialized gcloud account ... issue gcloud auth login then explains paste browser (which have logged google) , put browser generated token onto command line ... once happy done ... go ahead , launch cluster ... if wish fancy using service account (not necessary) setup issue g

javascript - Compressing Function.prototype.bind into 140 characters -

this bind polyfill function mdn: function.prototype.bind = function(othis) { if (typeof !== 'function') { // closest thing possible ecmascript 5 // internal iscallable function throw new typeerror('function.prototype.bind - trying bound not callable'); } var aargs = array.prototype.slice.call(arguments, 1), ftobind = this, fnop = function() {}, fbound = function() { return ftobind.apply(this instanceof fnop ? : othis, aargs.concat(array.prototype.slice.call(arguments))); }; if (this.prototype) { // function.prototype doesn't have prototype property fnop.prototype = this.prototype; } fbound.prototype = new fnop(); return fbound; }; i wanted compress 140 characters or less using es2015 syntax. does following achieve same goal (albeit not method on function.prototype )? var bind=(f,t,...a)=>{ function g(...b){ return f.ca