Posts

Showing posts from February, 2014

angularjs - Is it possible to use parameterized URL templates with angular $http service -

i'm using $resource restful api's , love parameterized url template example 'api/clients/:clientid' this works great crud operations. of api's reports or read-only end points without need full restful treatment. felt overkill use $resource , instead used custom data service $http. the drawback lose parameterized url templates. love define url like 'api/clients/:clientid/orders/:orderid' , pass { clientid: 1, orderid: 1 } . realize can build url dynamically hoping $http supported parameterized template , haven't found yet. all best update 7/5 the word missing in searches 'interpolate'. more information comes when search 'url interpolation in angular $http'. short answer looks 'no' $http doesn't support url interpolation. there few easy ways accomplish however. 1. use $interpolate: documentation $interpolate here var exp = $interpolate('/api/clients/{{clientid}}/jobs/{{jobid}}', false, null, true);

How to import a maven module to an Android Studio project -

i include retrofit module in android studio project (because plan on making few modifications retrofit library support json web tokens). problem retrofit maven project , android studio won't let me import it. there way around this? a similar question has been asked before , received no answers. use custom group and/or artifact in pom of clone, clone cannot confused original. build , install clone of retrofit using maven usual: mvn install . (using command line or ide other android studio.) have build retrofit clone manually after each change make it, gradle see changes. add local maven repository gradle script. see https://docs.gradle.org/2.5/dsl/org.gradle.api.artifacts.dsl.repositoryhandler.html#org.gradle.api.artifacts.dsl.repositoryhandler:mavenlocal() : repositories { mavenlocal() } add gav of clone dependency gradle script: dependencies { compile 'com.yourgroup:retrofit:1.9.0-custom' }

How to optimize query when join on varchar column in Sql Server -

i have 2 tables , b select a.id, b.name inner join b on a.name = b.name how optimize query? name column varchar(8) you should create index on both tables , b create index index_name on table_name (column_name) http://www.w3schools.com/sql/sql_create_index.asp

javascript - Wating for all finished request in a loop with node request -

i use node request ajax package. so, have loop, in every iteration makes request server. // realitems needs complete value of items assigned var realitems; var items = []; _.foreach(json.parse(body), (value, key) => { request('myurl/' + id, (error, response, body) => { items = json.parse(body) }); }); how can bundle requests request package, can assign value of items variable realitems @ end? // edit: i use react js, in case realitems state, , can't trigger in every loop iteration, because render triggers on every setstate there number of ways approach this. here's brute force method not preserve order of results: var items = []; var cnt = 0; _.foreach(json.parse(body), (value, key) => { ++cnt; request('myurl/' + value.id, (error, response, body) => { items.push(json.parse(body)); // if requesets done if (--cnt === 0) { // process items here results done } }); }); here's versi

how do you check if the value is null and replace it by NA in R -

i need write web service call returns data json: {"application":"web","host":"prodwebserver01","datacenter":"nevada","pod":"1"} sometimes data can this: {"application":"null","host":"prodwebserver01","datacenter":"nevada","pod":"1"} or {"application":"web","host":"prodwebserver01","datacenter":"nevada","pod":"null"} sometimes, values application:"null" or datacenter:"null" , when this: zlinux<-data.frame(cbind(tolower(d$guestid),tolower(d$host),d$application,d$pod,tolower(d$datacenter))) keys have null values not show on zlinux data frame. if value null, replace n_a , have 4 columns in data frame. the following code: suppressmessages(library(rcurl)) suppressmessages(library(rvest)) guests<-c("web0

wpf - VB.net: How to format money/numbers? -

i not know how come code format numbers. example: input textbox : 1000 result in textbox2: 1k example: input textbox : 1000000 result in textbox2: 1m example: input textbox : 1000000000 result in textbox2: 1b example: input textbox : 2147483647 result in textbox2: 2.147483647b example: input textbox : 583967 result in textbox2: 583.967k how do that? please help!! this can achieved conditional arithmetic grouping imports system public module module1 public sub main() dim input ulong console.write("enter number: ") input = convert.touint64(console.readline()) console.writeline(formatnumber(input)) end sub public function formatnumber(byval input ulong) string dim result string = input.tostring() if input >= 1000000000 result = string.format("{0}b", input / 1000000000) else if input >= 1000000 result = string.format("{0}m", input /

Getting Oauth token in app engine endpoints -

i looking way of obtaining oauth2 token app engine java endpoint. i aware of doing this, example: @apimethod(name = "getmyresponse", path = "getmyresponse", httpmethod = apimethod.httpmethod.get) public myresponse getmyresponse(final user user, httpservletrequest request) throws userunauthorizedexception { string authorizationheader = request.getheader("authorization"); string token = authorizationheader.substring(7); //do token here } however, looking bit more "civilized", parsing strings http header (like using api, example). ideas? if need token, seems uncivilized, i'd suggest writing yourself. api possibly use add weight codebase. write helper function : private static string gettoken (httpservletrequest req){ string authorizationheader = req.getheader("authorization"); string token = authorizationheader.substring(7); return token; } and in code reference string token = getto

asp.net mvc - Scaffold Add Controller dialog has empty Data Context class drop-down -

i'm using linq sql database first approach , have generated data classes dbml file adding connection database (under servers panel) , dragging tables design surface. in designer file (intrinsic.designer.cs) can see 'intrinsicdatacontext' defined when attempt scaffold controller views, data context class dropdown empty. [global::system.data.linq.mapping.databaseattribute(name="intrinsicroadrunner")] public partial class intrinsicdatacontext : system.data.linq.datacontext { private static system.data.linq.mapping.mappingsource mappingsource = new attributemappingsource(); everything 1 project there no namespace issues , have performed usual 'clean', 'build', 'rebuild' repeat exercises several times no benefit. dumped files , started scratch same proble i can manually reference data context class within existing controller below: intrinsicdatacontext dbcontext = new intrinsicdatacontext(); var drivers = dbcontext.drivers

if statement - how to fix error "missing value where TRUE/FALSE needed" at R? -

my code : for(k in 1:length(dat)){ if(dat==boxplot(dat)$out[k]){ dat<-na } } and result error in if (dat == boxplot(dat)$out[k]) { : missing value true/false needed how fix it? could 1 of 2 things; fix specific error for(k in 1:length(dat)){ if(length(boxplot(dat)$out ) & dat==boxplot(dat)$out[k]){ dat<-na } } but that's clunky r code. better might be: dat[ dat %in% boxplot(dat)$out ] <- na (it is, however, statistical malpractice remove outliers.)

javascript - Toggling Multiple DIVs with JQuery: Codes Included -

i need toggling multiple divs codes below. works 1 div multiple divs looped php impossible target each loop give unique ids or classes. below codes, please out correct jquery function clickhandler() { $('#hide').toggle(); $('#show').toggle(); $('.more-content').toggle('slow'); } $(document).ready(function(){ $('#hide, .more-content').hide(); $('#hide, #show').on('click', clickhandler); }); html <div class="more-content"> <!--these contents--> </div> <button id="hide" class="more_arrow">collapse <span class="fa fa-chevron-up"></span></button> <button id="show" class="more_arrow">expand <span class="fa fa-chevron-down"></span></button> when working repeating components don't want use id's want use common classes common elements. use oute

javascript - Recursive iterate by nested objects with angularjs -

here json nested objects not constant nesting level { "level": 2, "title": "subcat_in_cat2", "url": "subcat_in_cat2_url", "id": 5, "parent": { "level": 1, "title": "cat2", "url": "cat2_url", "id": 2, "parent": { "level": 0, "title": "cat1", "url": "cat1_url", "id": 1, "vertical_order": 0 }, "vertical_order": 0 }, "vertical_order": 0 } how iterate objects creating breadcrumbs data this: <ul class="breadcrumb"> <li><a href="cat1">cat1</a></li> <li><a href="cat2">cat2</a></li> <li><a href="subcat_in_cat2_url">subcat_in_cat2</a

python - Plain notation in seaborn plots -

Image
i started using seaborn , use pyplot.plot function, , whenever use log scales axis ticks presented 10 power. before using seaborn, line ax.xaxis.set_major_formatter(formatstrformatter('%.0f')) was fixing problem, seaborn not. ideas how can have plain notation on axes? below example of code. x axis of form: 0.1, 1, 10 , 100 .. , not now. import matplotlib.pyplot plt import seaborn sns sns.set_style('ticks', {'font.family': 'sans-serif'}) sns.set_context("paper", font_scale=1.3) plt.rc('text', usetex=true) x_lim=[0.1,100] y_lim=[1.2001, 2.2001] f = plt.figure() plt.xscale('log') plt.ylim(y_lim) plt.xlim(x_lim) plt.hlines(1.5, *x_lim, color='grey') plt.show() the key thing placement of formatter line. has after ax.set_xscale('log') . rather using %.0f removes numbers after decimal place (leaving 0 rather 0.1 ), use %g , round 1 significant figure. i've extended example use subpl

.net - How to retrieve IFileOpenDialog interface in C# from IUnknown_QueryService SID_SExplorerBrowserFrame? -

i'm trying hook file dialogs in custom namespace extensions project. done in c#. i'm trying follow post: http://blogs.msdn.com/b/winsdk/archive/2015/03/24/how-to-register-for-file-dialog-notifications-from-shell-namespace-extension.aspx in c++ works, , ifileopendialog interface: done under setsite method: hresult hr = iunknown_queryservice(m_punksite, sid_sexplorerbrowserframe, iid_ppv_args(&m_fileopendialog)); where m_fileopendialog ifileopendialog i'm trying same in c#, doesn't work... i've tried several ways: filedialognative.ifileopendialog o2 = marshal.getobjectforiunknown(m_punksite) filedialognative.ifileopendialog; o2 null. i've tried intptr ptr; guid g = new guid("000214f1-0000-0000-c000-000000000046"); int rc = marshal.queryinterface(m_punksite, ref g, out ptr); this succeeds, have no idea how convert "ptr" required interface. any appriciated. **update comment **, i tried doing this: [dllimport(

sql - How to declare a bulk collect into when I dont know how many columns I'll get - ORACLE -

i'm creating dynamic query have columns "x , y, z, z1...zn" this: `type var table of varchar2(4000); tnivel var; t_local_code var; tperm var; tval_perm var; temp1 var; temp2 var; temp3 var; temp4 var; temp5 var; temp6 var; temp7 var; begin vquery:='select z.nivel, y.cod_local_perm, z.permiso,y.valor_permiso valor_perm,'; in 2 .. p_checkboxes.count loop if <> p_checkboxes.last vquery:=vquery||' fun_perm_perm('||p_checkboxes(i)||',c.cod_local_perm ),'; else vquery:=vquery||' fun_perm_perm('||p_checkboxes(i)||',c.cod_local_perm ) '; end if; end loop; (select distinct level nivel,a.cod_master , b.cod_local_perm, lpad(chr(9),level,chr(9)) || replace(replace(replace(a.nom_permiso, '' " '' ,null) ,chr(10),null),chr(13),null) perm '; vquery:=vquery||'

asp.net - URL rewrite rule fails match when adding + -

the following rewrite rule works url: https://www.example.com/muziek/liedjes-start+meeting/modern but url http error 404.0 - not found https://www.example.com/muziek/liedjes-start+meeting/rhythm+and+blues <rule name="song overview occasion + genre"> <match url="^(muziek/liedjes|music/songs)-([a-za-z-+]+)/([a-za-z-+]+)$"/> <action type="rewrite" url="songs.aspx?category={r:2}&amp;genre={r:3}" appendquerystring="true"/> </rule> so fot second url rewrite not work...why not?

powershell - Uninstalling Patches from list of Machines -

i trying write script pulls list of machines , uninstalls hotfixes listed below. can't seem find right cmdlet says -hotfixid not cmdlet. can me out this. $mycomputers = get-content "c:\mycomputers.txt" foreach ($computer in $mycomputers) { uninstall-hotfix -computername $computer -hotfixid kb123456 -hotfixid kb925673 } you need repeat command each hotfix so: $mycomputers = get-content "c:\mycomputers.txt" foreach ($computer in $mycomputers) { uninstall-hotfix -computername $computer -hotfixid kb123456 uninstall-hotfix -computername $computer -hotfixid kb925673 }

javascript - Styling of charts externally -

is possible translate(detach) bar colors stated in js file separate css stylesheet. how assign classes values? /* bar dashboard chart */ morris.bar({ element: 'dashboard-bar-1', data: [ { y: 'oct 10', a: 100, b: 35 }, { y: 'oct 11', a: 34, b: 156 }, { y: 'oct 12', a: 78, b: 39 }, { y: 'oct 13', a: 200, b: 70 }, { y: 'oct 14', a: 106, b: 79 }, { y: 'oct 15', a: 120, b: 80 }, { y: 'oct 16', a: 126, b: 41 } ], xkey: 'y', ykeys: ['a', 'b'], labels: ['unique', 'returned'], barcolors: ['#588007', '#b64645'], fillopacity: 0.6, gridtextsize: '10px', hidehover: true, resize: true, gridlinecolor: '#e5e5e5' }); /* end bar dashboard chart */ /* donut dashboard chart */ morris.donut({ element: 'dashboard-donut-1', data: [ {label: "returned", value: 1513}, {label: "new", value: 764},

c# - Why does VS2015RC says "The ViewBag doesn't exist in the current context", where as VS2013 says no errors? -

Image
i opening same mvc solution in vs2013 , vs2015rc, exact same code, vs2015rc tells me there bunch of errors on .cshtml pages vs2013 says no errors. main problem don't intellisense because of errors in vs2015. what causing this? also, when build solution in vs2015, says succeeded? code snippet: <!doctype html> <html> <head> <title>@viewbag.title</title> <link href="@url.content("~/content/site.css")" rel="stylesheet" type="text/css" /> <script src="@url.content("~/scripts/jquery-2.1.3.min.js")" type="text/javascript"></script> <meta name="description" content="the description of page" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> </head> <body> <div id="header"> <div class="title">abc</div> &l

ruby - How to store the nested hash path of the xml response? -

i have following xml response converted hash savon {:read_measurements_list_response=>{:read_measurements_list_result=>{:sensor_data_list=>{:sensor_data=>[{:type=>"humidity", :value=>"26.20"}, {:type=>"temperature", :value=>"33.12"}, {:type=>"light", :value=>"5501.0"}, {:type=>"soilmoisture", :value=>"0.223"}, {:type=>"conductivity", :value=>"0.031"}, {:type=>"groundtemperature", :value=>"26.9"}]}}, :@xmlns=>"http://tempuri.org/"}} so can dig inside sensor_data key-pairs with res_body[:read_measurements_list_response][:read_measurements_list_result][:sensor_data_list][:sensor_data] how can store path variable can change whenever xml response changes structure? have tried using several things none work. nice able res_body[hash_path]. you're asking 2 things: how can store path

java - Heroku cannot detect the buildpack - Spring Boot -

i'm trying deploy web service on heroku spring boot project (java) , gives me following error when try push heroku: fetching custom git buildpack... done remote: remote: ! push rejected, no cedar-supported app detected remote: hint: occurs when heroku cannot detect buildpack remote: use application automatically. remote: see https://devcenter.heroku.com/articles/buildpacks i tried using custom build pack of java still doesn't work. have idea on how can fix this. appreciated. i have jetty-runner dependency , plugin. created procfile defined following: web: java $java_opts -jar target/dependency/jetty-runner.jar --port $port target/*.war my directory project follows (i don't know if matters): -root |___projectdirectory | |____code... | |____procfile |___readme i had, believe, same problem , caused git root directory not being same project root. project structure: -gitroot |___projectdirectory |____code.

python - Django Rest Framework: How do I order/sort a search/filter query? -

i'm building out api django rest framework, , i'd have feature allows users search query. currently, http://127.0.0.1:8000/api/v1/species/?name=human yields: { count: 3, next: null, previous: null, results: [ { id: 1, name: "humanoid", characters: [ { id: 46, name: "doctor princess" } ] }, { id: 3, name: "inhuman (overtime)", characters: [ ] }, { id: 4, name: "human", characters: [ { id: 47, name: "abraham lincoln" } ] } ] } it's pretty close want, not quite there. i'd first object inside results 1 id of 4 since name field relevant search query (?name=human).

git - How to to selectively edit and accept changes committed in another branch without editing hunks? -

i trying select/edit changes branch before merging - e.g., after fetch. when there conflicts, easy go conflicted file , remove/edit text between '>>>' , '<<<'. when there no conflict seems usual way edit hunks have found in answers answer1 , answer2 : git checkout -p or git add -p however, despite simplicity of hunk editing , single (after splitting) long hunk not practical correctly edited. suppose difficulty comes when number of lines changes or ' ' lines unwittingly removed or transformed '+' lines. problem, maybe more important, whole file not available. there text gaps between hunks otherwise make editing more comfortable. one solution think of simulate changes conflicts. possible? answer suggests complex sequence of commands comment suggesting equally complex (to used @ git root) alias: git config --global alias.remerge '!sh -c "git show head:${2} > ${2}.head; git show ${1}:${2} > ${2}.${1};

Why Yii2 module separate configuration does not work in basic app? -

i have yii2 basic application 2 parts (web , service mobile). i have created module handle restful requests fired mobile . want configure module rest. created config file module in side module directory. mentioned in yii2 documentation modules /config/config.php: return [ 'components' => [ 'urlmanager' => [ 'class' => 'yii\web\urlmanager', // disable index.php 'showscriptname' => false, // disable r= routes 'enableprettyurl' => true, 'enablestrictparsing' => false, 'rules' => array( [ 'class' => 'yii\rest\urlrule', 'controller' => 'mobile/mobile-clients', 'extrapatterns' => ['get search' => 'search'] ], ), ], 'request' => [ 'class' => '\yii\web

python help separating lists in a text file -

i have text file hundreds of lists stored in text file. how separate lists , store them lists , search smallest second value between lists. open new ways of tackling problem. here first few 'lists' , attempt separate them var line1=[["apr 02 2014 01: +0",0.6,"295"],["apr 03 2014 01: +0",0.641,"245"],["apr 04 2014 01: +0",0.625,"246"],["apr 05 2014 01: +0",0.665,"267"],["apr 06 2014 01: +0",0.632,"226"],["apr 07 2014 01: +0",0.672,"170"],["apr 08 2014 01: +0",0.655,"147"],["apr 09 2014 01: +0",0.654,"121"],["apr 10 2014 01: +0",0.62,"136"],["apr 11 2014 01: +0",0.629,"176"],["apr 12 2014 01: +0",0.68,"190"],["apr 13 2014 01: +0",0.677,"176"],["apr 14 2014 01: +0",0.73,"153"],["apr 15 2014 01: +0",0.587,"

android - How to make a gradient shape stay behind CollapsingToolbarLayout title -

i've been playing around chris bane's cheesesquare example application regarding collapsing toolbar layout , i'm having trouble adding gradient behind title on collapsing toolbar title remains readable if backdrop bright. i've seen 1 solution here on stackoverflow deals in way. that solution places gradient "attached" image instead of bottom of collapsing toolbar. happen is, scroll down, gradient disappear image parallaxes out of sight. want make gradient follow toolbar collapses (and keep parallax effect). this short video should make issue clear: https://vid.me/j225 activity_contact_detail.xml <android.support.design.widget.appbarlayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="@dimen/detail_backdrop_height" android:theme="@style/themeoverlay.appcompat.dark.actionbar"> <android.support.design.widget.collapsingtoolbarlayout a

javascript - GET working with Postman, but not with Ajax? -

i'm attempting simple request server hosting account data. request requires authorization header in order function correctly. have performed request , retrieved data in postman, attempting in javascript via ajax results in "invalid http status code 405" error. below link fiddle , screenshot of postman settings. thanks.! $.ajax({ beforesend: function(xhrobj){ xhrobj.setrequestheader("authorization","bearer tj7ltlycpqc6drup5bkhuo7uvbyaazi40"); }, type: "get", url: "https://api05.iq.questrade.com/v1/accounts", success: function(e){ console.log(e) } }); http://jsfiddle.net/ldjbp2j8/1/ postman settings from chrome's js console: failed load resource: server responded status of 405 (method not allowed) because adding authorization header, have made request complex . requires browser make preflight options request ask permission send complex request. the ser

android - ListView (height) inside DrawerLayout doesn't fill the screen -

Image
i use listview navigationview inside custom drawerlayout when removed items listview this later doesn't fill screen. screenshot layout.xml <ma.www.helpers.hackydrawerlayout android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:layout_width="fill_parent" android:layout_="0dp" android:orientation="vertical" android:weightsum="15"> <!-- framelayout display fragments act/profe/rechercher --> <framelayout android:id="@+id/frame_container" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="9"/> <!-- framelayout display menu--> <framelayout android:id="@+id/frame_menu"

unix - shell script to display the calendar of the current month with current date replace by * -

i want result this: may 2014 su mo tu th fr sa 1 2 3 4 5 * 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 i able extract date using date |cut -d' ' -f4 but when execute command, cal|sed "s/date|cut -d' ' -f4/*/" there no change calender output. can 1 tell me going wrong?? thanks. running data|cut -d' ' -f4 single script , using word boundary around selection select particular date. cal|sed -r "s/\b$(date|cut -d' ' -f4)\b/*/" here putting $(date|cut -d' ' -f4) run script , output used in sed selection: cal|sed -r "s/\boutput\b/*/" using \b important since indicates word boundary. else, current date (say 5), occurrence of 5 replaced * . output: july 2015 su mo tu th fr sa 1 2 3 4 * 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

file io - How do I read data line by line in Ruby? -

i new ruby , creating poker game application. trying read in each player's cards text file. data in text file looks this: 8c ts kc 9h 4s 7d 2s 5d 3s ac 5c ad 5d ac 9c 7c 5h 8d td ks 3h 7h 6s kc js qh td jc 2d 8s and forth. first 5 on each line 1 player's cards, , other 5 other's. how go reading in data? have written card class can create cards based on how represented in file. io.foreach('cards.txt') |line| cards = line.chomp.split.map { |c| card.new(c) } hand1 = cards[0, 5] hand2 = cards[5, 5] #... end or... handpairs = file.open('cards.txt') |f| f.each_line.map { |line| line.chomp.split.each_slice(5).map { |cs| cs.map { |c| card.new(c) } } } end

html - Bootstrap Column size -

i'm trying use bootstrap 2 separated columns (not in same row) have same height, height of bigger element (a picture). my layout illustrated here: http://jsfiddle.net/v30u5zjd/ code: <div class="row"> <div class="col-md-6"> <div class="row"> <div class="col-md-12 col-sm-height"> <img src="http://www.onlinegamblingbible.com/wp-content/uploads/2014/02/small-android_logo.png"></img> </div> </div> <div class="row"> <div class="col-md-12"> <h2 class="articlerecenttitre">my great title 1</h2> </div> </div> <div class="row"> <div class="col-md-12"> <h3 class="articlerecentresume"> excerpt here gregregfdsxgrezgttretgretre

javascript - adding extra html tags within angularjs loop -

i need add html tags within angularjs loop so: <div ng-repeat="fixture in fixtures.fixtures "> <tr> <th class="date" colspan="5">{{fixture.date | cmdate:'mm/dd/yyyy'}}</th> </tr> <tr> <td>{{teamname(fixture.hometeam) }}</td> <td>&nbsp;{{score(fixture.goalshometeam)}}</td> <td>-</td> <td>{{score(fixture.goalsawayteam)}}&nbsp;</td> <td>{{teamname(fixture.awayteam)}}</td> </tr> </div> however no data retrieved when that, if have coded follows work: <tr ng-repeat="fixture in fixtures.fixtures "> <td>{{fixture.date | cmdate:'mm/dd/yyyy'}}</td> <td>{{teamname(fixture.hometeam) }}</td> <td>&nbsp;{{score(fixture.goalshometeam)}}</td&g

Django custom user page -

i’d design django page custom user, lets teacher class, can manage student users in list ability remove them site. sort of custom admin page, teacher have ability manage students, not have access actual django admin site. in actual function of site, students , teachers see different pages based on user type. what’s best way go implementing not versed in django? edit: should clarify user manager page not actual admin site, list box users , ability manage them. come in adminis , there tab , users , select user ( teacher ) , gave him 'user rights :' want. or: do 'custom user model' example: teacher = models.booleanfield(verbose_name='teacher', default=false) and in admin real teacher == booleanfield == true @login_required def deleted(request, id): context = {} complaint = complaint.objects.get(id=id) if request.user.: complaint.is_deleted = true complaint.delete() context['deleted'] = complaint.is_d

ios - Can't get user location with swift using GoogleMaps -

i trying user's location using googlemaps api, reason, when run simulator, alert user location won't come , won't show current location either. class uimapsviewcontroller: uiviewcontroller, cllocationmanagerdelegate { @iboutlet weak var mapview: gmsmapview! let locationmanager = cllocationmanager() override func viewdidload() { super.viewdidload() locationmanager.delegate = self locationmanager.requestwheninuseauthorization() } the info.plist targeted app, isn't issue. assume issue in key in info.plist file. i've tried both "nslocationwheninuseusagedescription" , "nslocationalwaysusagedescription" interestingly neither of keys come suggestions in list. there different key use now, or not issue? thanks! the problem you've run code , you've granted or denied authorization. once happens, you'll never see authorization alert again app. need reset simulator forgets previous answer. as other part of que

Tree representation using list in python -

Image
for tree, as beginner, below list representation, tree = [ [ [ [ [], 3, [] ], 10, [ [], 17, [] ] ], 25, [ [ [], 30, [] ], 32, [ [], 38, [] ] ] ], 40, [ [ [], 50, [] ], 78, [ [], 93, [] ] ] ] is representation correct using python list? can avoid empty list [] in representation? you representation makes lot of sense since uses 2 simple rules. tree list can be: [] #empty tree [list, number, list] #non-empty tree this simplicity makes easy write code , treat things in

android - Offline maps OSM -

i bit stuck idea of offline maps in android application. i want use open street maps. how can redesign styles , use in project? way, resource, looking for, has free.. are there tutorials this? new this, thankful helpful information. here basics: raster tiles awful . mind, approach of mobile mapping old-fashioned , has no advantages (unless plan make bad-looking application). the other thing vector tiles . data saved in more efficient way , can displayed beautifully. and solutions (nominees) are: mapsforge - @dkiselev osmand app - @dkiselev mapbox gl (the android version has no releases now, working hard on it). if mapbox, can think mapbox android sdk, uses raster tiles, believe, switching mapbox gl not hard, when gl lib released. airbnb airmapview - open source , has release version urban labs sputnik demo - interesting solution, didn't use it. mapzen open - open source android app, uses best everywhere. - winner! and way, mapbox gl actully a

Rails update method not working: ActionView::MissingTemplate (Missing template items/update...) -

the following update method in items_controller : def update @item = item.find(params[:id]) if @item.update_attributes(item_params) flash[:success] = "item updated" redirect_to edit_item_path(@item) else render edit_item_path(@item) end end the @item seems loaded in logs, after completed 500 internal server error in 73ms occurs: item load (6.7ms) select "items".* "items" "items"."id" = ? order "items"."created_at" desc limit 1 [["id", 30]] completed 500 internal server error in 54ms actionview::missingtemplate (missing template items/update, application/update {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. searched in: * "/library/ruby/gems/2.0.0/gems/web-console-2.0.0.beta3/lib/action_dispatch/templates" * " # app route # " * "/library/ruby/gems/2.0.

how to initialize array of unknown size in c -

i doing homework assignment intro programming class in c. i need write program looks @ int array of unknown size (we given initializer list test case use), , determine duplicates in array. to make sure element found duplicate doesn't tested, want use parallel array original hold numbers of elements duplicates. i need array same size original array, of course don't know till initializer list given us. i tried using sizeof() achieve this, visual studio says error due variable size ( const int size = sizeof(array1); ) not being constant. not using sizeof correctly? or logic flawed? perhaps there way approach this, have yet come one. here code included below, hope comments don't make hard read. // dean davis // cs 1325 // dr. paulk // duplicates hw #include <stdio.h> int main() { int array1[] = { 0,0,0,0,123,124,125,3000,3000,82,876,986,345,1990,2367,98,2,444,993,635,283,544, 923,18,543,777,234,549,864,39,97,986,986,1,2999,473,776,9,23,397

html - how to run javascript and css in a angular directive output? -

i have angular directive: app.directive('templater', function() { return{ restrict: 'e', templateurl: '../../tmpl/themer.html', link: function(scope, element, attrs){ // execute metismenu plugin settimeout(function(){ $(element).templater(); }, 1); } } }); the intent push html themer.html main page. right inside my_profile.html have tag <templater></templater> . now, html displays perfectly, css , js non-operational. css tags in template referenced directive affect , affected same js , css files associated parent document. how tell directive enforce rules of parent file on inserted file? thanks use $timeout of angular instead of settimeout. inject $timeout dependency in directive

objective c - How to implement hashCode() in Swift for use by NSDictionary? -

i'm trying use swift object key in nsmutabledictionary. i've implemented hashvalue , equality usual , works in native swift dict. nsmutabledictionary never calls hash function. missing? public final class holder : hashable, nscopying { var val : int = 0 public init( _ val : int ) { self.val = val } public var hashvalue: int { return val } @objc public func copywithzone(zone: nszone) -> anyobject { return self } } public func == (lhs: holder, rhs: holder) -> bool { return lhs.val==rhs.val } //var dict = dictionary<holder,string>() var dict = nsmutabledictionary() dict[ holder(42) ]="foo" dict[ holder(42) ] // nsmutabledictionary not call hash function, returns nil here. answer: i had implement explicitly hash() , isequal() so: @objc public func hash() -> int { return hashvalue } @objc public func isequal( obj : anyobject ) -> bool { return (obj as? holder)?.val == val }

javascript - How to show numeric keyboard in android 5.0 (lollipop) -

using moto g, supposedly running stock android 5.0, browser , webview showing full keyboard when input (type=number) in focus. this different behavior android 4.x used show numeric keyboard. is there workaround tricks android showing numeric keyboard? here markup: <input type="number" id="number1" /> try change type tel if want phone-like keyboard <input type="tel" id="number1"> iv'e used ionic framework on project , can confirm on nexus 5 android 5.1

r - Is it possible to replicate shiny element across application -

i'm working on simple shiny application consists of multiple panels, the ui.r structured code below: shinyui(navbarpage("example", tabpanel("sample analysis", sidebarlayout( sidebarpanel( sliderinput("bins", "number of bins:", min = 1, max = 50, value = 30) ), mainpanel( plotoutput("distplot") ) )), tabpanel("sample analysis 2", sidebarlayout( sidebarpanel(

java - How do they do? - Overriding Dalvik File.delete() -

recently, attention drawn of recycle bin applications on play store, , thought nice put of methods practice make other useful applications people out there, seems not quite simple. according stackoverflow post , impossible! but if closely, applications gt trash , dumpster working charm without root permissions ! what want achieve overriding android system file.delete() deleted file moved our desire location before user permanently delete it. tried andrey petrov post witch shows solution similar situation not providing enough details. we appreciate successful finding out magic behind these apps.

parsing - Python for creating a set operations Calculator -

i'm trying create calculator, not numbers, set operations. illustrate concept lets have file 2 columns. keyword, userid hello , john hello , alice world , alice world , john mars , john pluto , dave the goal read in expressions like [hello] and return set of users have keyword. example [hello] -> ['john','alice'] [world] - [mars] -> ['alice'] // - here difference operation [world] * [mars] -> ['john','alice'] // * here intersection operation [world] + [pluto] -> ['john','alice','dave'] // + here union operation i used plyplus module in python generate following grammar parse requirement. grammar shown below grammar(""" start: tprog ; @tprog: atom | expr u_symbol expr | expr i_symbol expr | expr d_symbol | expr | '\[' tprog '\]'; expr: atom | '\[' tprog '\]'; @atom: '\[' queryterm '\]' ; u_symbol: &#

directx - Where does WorldViewProj get definenition in hlsl -

as tile,i in fxcomposer play shader code this float4x4 worldviewproj : worldviewprojection; struct c2e1v_output{ float position :position; float color : color; } float4 mainvs(float3 pos : position) : position{ return mul(float4(pos.xyz, 1.0), worldviewproj); } float4 mainps() : color { return float4(1.0, 1.0, 1.0, 1.0); } technique technique0 { pass p0 { cullmode = none; vertexshader = compile vs_3_0 mainvs(); pixelshader = compile ps_3_0 mainps(); } } but dont know how var "worldviewproj " define,seems there's no code give vlue.can me,thanks.

c - How to correctly use socket close for fork? -

i have questions how correctly close socket file descriptor. let's assume server forks procedure whenever accepts new connection. original socket file descriptor sockfd , new socket file descriptor new_sockfd . sockfd = socket(...) bind(...); listen(...); while(1) { new_sockfd = accept(...); if(fork() == 0) { // child process dosomething(...); } else { } } my question is, should put close(sockfd) , close(new_sockfd) . have seen examples in website ( http://www.tutorialspoint.com/unix_sockets/socket_quick_guide.htm "handle multiple connection") put close(sockfd) inside if block , close(new_sockfd) in else block. but, after fork, aren't 2 processes running in parallel? if parent process closes new_sockfd , won't affect child process handle socket? also, if child process executes close(sockfd) , won't affect entire socket program? when process forks, file descriptors duplicated in child process. however, these file d

javascript - onsubmit validateForm funxtion is not working -

here validation used onsubmit event. how not working. want check textbox filed empty or not. <!doctype html> <html> <head> <title>temple3</title> <link rel="stylesheet" type="text/css" href="temple3css.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> </head> <body> <div id="popup-content" class='container'> <div id="container1"> <form id="form" class="form" onsubmit="return validateform()"> <h1>feedbak form</h1> <div class="content"> <div class="intro"></div> <div id="section0" > <div class="field roption"> <input type="radio" name="view" value=

c# - Build failed: cyclic build dependencies are not supported -

i've been trying build project in monodevelop, bitches project having cyclic build dependency. project1 main project. project2 1 has cyclic dependency. project3, 4 , 5 other projects. project2 references 1, 3 , 4. project4 references 3 , 5. project2 , 4 have same names. honestly, don't see cyclic build dependency there. disabling cyclic build dependency project works fine, want compile using monodevelop. okay, fixed renaming project4. both had same name, , monodevelop couldn't resolve it.

How we can use dynamo db local to save cognito ID of authenticate users -

is there specific way create cognito identity pool in amazon dynamodb local setup? have setup javascript shell , created several tables , have queried it. need provide authenticated mode user login (facebook, amazon, google) node application. found several tutorials how set using aws dynamodb, need know how can create using local dynamodb without accessing aws dynamodb. amazon dynamodb local doesn't validate credentials, doesn't matter how set amazon cognito identity pool or roles pool. able interact cognitocredentials object same way if using amazon dynamodb or dynamodb local. it important note not hoever able validate fine-grained access control unless use full service, again because dynamodb local doesn't validate credentials.

jquery - Cannot handle file upload in Django when request comes from Ajax and a form -

i'm trying handle file upload in django ajax post, doesn't work :( below code in html file upload : <form action="{% url 'saveprof' %}" method="post" enctype="multipart/form-data" id="form1"> {% csrf_token %} <div class="profpic" style="background:url(../../../static/app/img/profile.png)"> <input type="file" id="picpath" name="picpath" class="uploadpic" value=""/> </div> </form> {% csrf_token %} save below ajax method used post data : function saveprof() { var formdata = { 'picpath_aj': $('#picpath').val() }; $.ajax({ type: "post", url: "saveprof", enctype: 'multipart/form-data', async: true, data: {

java - Is it possible to check heap memory usage by pool? -

i've been working on optimizing program having lot of issues memory leaks. leaks gone now, occasional runs of major gc still put dent in ps old gen. know can check basic overall memory information through runtime, possible check usage in ps eden, ps survivor, , ps old within program? this article can out you can write custom code analyze memory & output in form collection time: 82037 collection count: 116 ps survivor space: init = 1703936(1664k) used = 65536(64k) committed = 32047104(31296k) max = 32047104(31296k) ps eden space: init = 10551296(10304k) used = 0(0k) committed = 69795840(68160k) max = 113049600(110400k) ps old gen: init = 27983872(27328k) used = 239432344(233820k) committed = 357957632(349568k) max = 357957632(349568k) code cache: init = 2555904(2496k) used = 19949568(19482k) committed = 20185088(19712k) max = 50331648(49152k) ps perm gen: init = 21757952(21248k) used = 148450536(144971k) committed = 155058176(151424k) max = 268435456(262144k)