Posts

Showing posts from August, 2014

android - Newbie here! How to create a detail page activity for a list view item, without including an action bar in it? Help required -

i need create detail page activity open on clicking list view item. want no action-bar in layout , there image starts on top , ends @ middle , have button on top left corner. there 2 ways hide actionbar in activity. first programmatically example in oncreate() method in activity don't want have actionbar: actionbar actionbar = getactionbar(); or getsupportactionbar(); actionbar.hide(); and second way xml in android manifest xml-file example: <activity android:name=".detailsactivity" android:label="@string/app_name" android:theme="@android:style/theme.notitlebar"> <!--or android:theme="@android:style/theme.noactionbar">--> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity>

python - Exit graph window using matplotlib.pyplot in terminal? -

i wrote command-line program in python using matplotlib.pyplot , argparse . input data , scatterplot i'm looking , window pops graph. cool how can exit window terminal ? i ended adding argparse argument --exit sys.exit() it's not working...when ctrl+z stops script graph window stays open. how can exit matplotlib.pyplot graph window terminal? #!/usr/bin/env python2.7 import matplotlib.pyplot plt import argparse, sys def main(): #(i). add arguments parser = argparse.argumentparser(description=__doc__) parser.add_argument('--exit', action = 'store_true', = 'exit graph') options = parser.parse_args() x_coordinates = [1,2,3,4,5] y_coordinates = [3,3,3,3,3] size_map = [20,20,20,20,20] plt.scatter(x_coordinates,y_coordinates, s = size_map) plt.show() if options.exit: sys.exit() #initiate if __name__ == '__main__': main()

sql server - Insert into linkedserver from local table -

i trying insert data local table linkedserver via sql server. doing keeps on throwing syntax error. try 1 exec( 'insert test.testschema.testoperation (viasatsubscriptionid, subscriptionrowdate, phonenumberday, viasatcustomerid) select * rdata.dbo.testoperation' )at redshift64 try 2 exec( 'insert test.testschema.testoperation (viasatsubscriptionid, subscriptionrowdate, phonenumberday, viasatcustomerid)' )at redshift64 select * rdata.dbo.testoperation both fails. any thoughts going wrong? testoperation local table, , since query runs on remote server, table not exist. why don't try inserting directly remote table: insert redshift64.test.testschema.testoperation (viasatsubscriptionid, subscriptionrowdate, phonenumberday, viasatcustomerid) select * rdata.dbo.testoperation

CSS HTML Image with Text Overlay & Button -

i'm newbie stuff & i'm sure it's simple enough fix, i'm struggling find way format text on image css button - need code responsive works on mobile devices also. any advice hugely appreciated. thanks all, johnny_p here's css: /* set custom square call action button */ #ctasquare-button-container { text-align: center !important; } #ctasquare-button { text-align: center !important; border: solid #000000 2px; border-radius: 2px; -moz-border-radius: 2px; -webkit-box-shadow: 0 0px 0 0 #b13f21; -moz-box-shadow: 0 0px 0 0 #b13f21; box-shadow: 0 0px 0 0 #b13f21; position: absolute; margin: 0 0 0 -115px; top:30; -webkit-transition: .1s background-color linear; -moz-transition: .1s background-color linear; -o-transition: .1s background-color linear; transition: .1s background-color linear; padding: 21px 35px; color: #fff; border-color: #fff; font-family: futura-pt; font-size: 15px; text-transform: uppercase; ...

jmeter - How to see the usage percentage of different components in same Virtual Machine -

i testing website through jmeter, components lms cms mongodb , mysql in same single vm how view individual usage stats? preferably in graph you need monitor processes each service want monitor on vm. example if want monitor , log top 10 cpu hungry processes log file in linux use below command: while true; (echo "%cpu %mem args $(date)" && ps -e -o pcpu,pmem,args --sort=pcpu | cut -d" " -f1-5 | tail) >> ps.log; sleep 5; done then can utilize data in log file plot graphs accordingly. other option use third party apm tools new relic or app dynamics monitor vm , can automatic reports monitored processes.

javascript - Hide elements after clicking a button -

using jquery, when click on search documents want hide li elements have aria-label contains company in vlaue. here html: <ul class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" tabindex="0" style="display: none; top: 30px; left: 0px; width: 236px;"> <li class="search-documents-btn ui-menu-item" aria-label=" search documents &amp;raquo;" id="ui-id-111" tabindex="-1"> search documents » </li> <li class="search-category ui-menu-item" id="ui-id-112" tabindex="-1"> companies </li> <li aria-label="test" class="ui-menu-item" id="ui-id-113" tabindex="-1"> </li> <li aria-label="test1" class="ui-menu-item" id="ui-id-114" tabindex="-1"> </li> <li class=...

swift - Error: Could not cast value of type NSKVONotifying_MKUserLocation to Park_View.AttractionAnnotation -

when using func: func mapview(mapview: mkmapview!, viewforannotation annotation: mkannotation!) -> mkannotationview! { let annotationview = attractionannotationview(annotation: annotation, reuseidentifier: "attraction") annotationview.canshowcallout = true return annotationview } this error occured: could not cast value of type 'nskvonotifying_mkuserlocation' (0x7e8a62b0) 'park_view.attractionannotation' (0xf7948). it working when try add corelocation find user location code start having error. i found out mkuserlocation annotation too. here solution came out , solve error. func mapview(mapview: mkmapview!, viewforannotation annotation: mkannotation!) -> mkannotationview! { if (annotation mkuserlocation) { return nil } else { let annotationview = attractionannotationview(annotation: annotation, reuseidentifier: "attraction") annotationview.canshowcallout = true ...

c++ - What can be a possible reason for segmentation fault in this piece of code? -

basically, following code takes input n pairs, each of them having 2 parts, a , b . sorted entire vector using custom comparator, puts values first have higher second value (b) and, if b same, have higher a value. here code, #include <iostream> #include <utility> #include <vector> using namespace std; struct mycomp { bool operator() (const pair<int,int> &p1, const pair<int,int> &p2) { if (p1.second > p2.second) // here return true; else if (p1.second == p2.second && p1.first >= p2.first) return true; else return false; } }; int main (void) { int i,n,a,b,foo; cin>>n; = n; vector<pair<int,int> > myvec; while ( != 0 ) { cin>>a>>b; myvec.push_back(make_pair(a,b)); i--; } int val = 0; sort(myvec.begin(),myvec.end(),mycomp()); val = val + myvec[0].first; int ...

Elasticsearch data issue -

today faced weird problem elasticsearch , don't know how fix issue. scenrario this elasticsearch cluster 2 nodes : total docs 1000 now 1 of server goes down , write , reads handled second server. there 10000 docs in es2. due system problem whole elasticsearch network down , both es1 , es2 down. somehow manually go , make es1 , taking write requests. es2 comes , discovers es1 master. es2 syncs master , data written es2 node lost. is there way recover lost data. expected behaviour in distributed system? please let me know if not clear.

debugging - Unable to see variable's value in Razor under debug mode in Visual Studio 2015 -

Image
i having problem seeing variable's value inside .cshtml page in visual studio 2015 rc under debug mode. think may bug. hovering on variable gives me tooltip describing variable's type , namespace belongs. way can see variable's value adding watch list. btw runnig code under windows 10 pro insider preview , below screenshot of page of visual stuio using. any suggestions be? i had same problem days ago rtm version of vs2015. able solve performing following steps: rename corresponding cshtml file create new file same name previous cshtml file. copy on contents previous file. however, today ihad same issue , did more digging. tracked down code block in cshtml file @ defined string constants: const string value = "abc"; when remove const keyword, works fine: string value = "abc"; this not real solution hope helps others face same problem

python - "Float" object is not iterable when applying reduce + sum in python2 -

i want apply reduce(sum, iterable) list of float numbers flist = [0.2, 0.06, 0.1, 0.05, 0.04, 0.3] . print list(reduce(sum, flist)) returns typeerror: 'float' object not iterable why, when flist iterable? the actual problem sum function. accepts iterable, not 2 individual values. example, >>> sum(1, 2) traceback (most recent call last): file "<input>", line 1, in <module> typeerror: 'int' object not iterable >>> sum([1, 2]) 3 so, cannot use sum here, instead can use custom lambda function or operator.add , this >>> operator import add >>> reduce(add, flist, 0.0) 0.75 >>> reduce(lambda a, b: + b, flist, 0.0) 0.75 note: before using reduce , might want read bdfl's take on use . moreover, reduce has been moved functools module in python 3.x.

Deploying Azure Data Factory using ARM Templates -

i'm trying deploy azure data factory service using azure resource manager templates. far able create data factory couldn't add linked service, pipeline or dataset using approach. since there no example of data factory template available, created mine based on rest api documentation. following template trying implement, "bad request" returned server. { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymenttemplate.json#", "contentversion": "1.0.0.0", "parameters": { "sitename": { "type": "string" } }, "resources": [ { "apiversion": "2015-05-01-preview", "type": "microsoft.datafactory/datafactories", "name": "teststoragedatafactory", "location": "[resourcegroup().location]", "resources": [...

javascript - validation form with php - safari site -

need quick help, if can... i have quite simple html 1 page form , i'm trying validate php (check blanks , verify email) reason going wrong , doesn't show me on action form anyone have idea? me lot. icons present obvious (the text hebrew) (if knows how validate phone, bless well) the html: <!doctype html> <html lang="he" dir="rtl"> <head> <title>safari company</title> <meta charset="utf-8"/> <link rel="stylesheet" type="text/css" href="styles.css"> <script src="js/script.js"></script> </head> <body> <div id="top-wrapper"> <div id="top-background"> <p class="image-text">.אפריקה. נקודת מבט חדשה</p> <p class="credit-english">ziv koren</p> </div> </div> <div id="costumer-w...

matlab - Removing equidistant points from image -

Image
i have image- i want remove these point marked yellow circles- so, want remove points equidistant , lies on same line between given 2 points. this have tried.i found equation between 2 points , removed points lie on line.here have tried- clc; i=imread('untitled.png'); imshow(i); i=im2bw(i); l = bwlabel(i,8) ; %calculating connected components mx=max(max(l)); i=1:mx [r1,c1] = find(l==i); x1=mean(c1); y1=mean(r1); j=1:mx if i~=j [r2,c2] = find(l==j); x2=mean(c2); y2=mean(r2); slope=(y2-y1)./(x2-x1); k=1:mx [r,c] = find(l==k); rc = [r,c]; x3=mean(c); y3=mean(r); temp=((y3-y2)-(slope).*(x3-x2)); if k~=i & k~=j if temp >=-0.5 & temp <=0.5 l=1:r m=1:c i(l,m)=0; ...

Using jquery-blockui, also disallow tabbing to blocked elements -

cross-post github: https://github.com/malsup/blockui/issues/121 link plugin: http://malsup.com/jquery/block/ while elements blocked cannot clicked, it's still possible use tabulator access them, , use enter activate it. possible skip blocked element when tabbing? for now, stop user tabbing blocked elements, stops user. it'd better if skip blocked ones. var proxiedblock = $.fn.block; $.fn.block = function () { var $elem = proxiedblock.apply(this, arguments); $elem.on('focusin.kj', function (evt) { evt.preventdefault(); $(evt.relatedtarget).focus(); }); return $elem; }; var proxiedunblock = $.fn.unblock; $.fn.unblock = function () { var $elem = proxiedunblock.apply(this, arguments); $elem.off('focusin.kj'); return $elem; }; i had same problem , discussed op here: https://github.com/malsup/blockui/issues/121#issuecomment-129719120 ended going approach allows blocked elements skipped. changed...

javascript - Correct way to chain two promises when the second promise depends on the first? -

how make chain 2 jquery async calls using js promises while avoiding pyramid of doom? know can convert "jquery" promise real promise this: promise.resolve($.getjson(url, params)); if want wait 1 promise, can this: promise.resolve($.getjson(url1, params1)) .then(function(result){ // stuff }); if want wait 2 different ajax calls done, can this: promise.all( [ promise.resolve($.getjson(url1, params1)), promise.resolve($.getjson(url2, params2)) ]).then(function(results_array){ // stuff }); however, if want 1 call come after other one, doesn't work: promise.resolve($.getjson(url1, params1)) .then(function(result){ //do stuff return promise.resolve($.getjson(url2, params2)); }).then(function(result){ //result promise, not results second call getjson()... //and doesn't wait second call finish. //result.then() going bring me further pyramid of doom :( }); somehow, want call .then() on promise constructed in "do stuff" function. ...

font heart symbols are the wrong color when run through phonegap build -

i'm trying include red heart symbols (♥) in app (color:#800000 in css). appear in chrome browser on desktop when pass code through phonegap , run on (android) phone, come out black. if put standard text inside span along hearts, text comes out red not hearts. i tried both native font element (u+2663 in arial character map) , html version &hearts; , happens both. if knows how correct this, appreciated. i'm open workarounds well, though i'm trying avoid using actual heart images.

vim syntax highlighting disappeared, help files no longer found -

opened vim today strange --- syntax highlighting no longer there (have not touched vimrc) , cannot run :help (says help.txt not found). plugins seem work though. know weird question, have clue might going on here?? didn't touch of settings , think may have messed restarting computer while had vim sessions open? ok found solution problem! running vim gitbash (as usual) reason today decided run git-installed vim (version 7.3) opposed 1 had set use, vim 7.4. i'm not sure made revert resolve went git bin folder , edited vim script point vim wanted.

javascript - Selecting an element by class, then moving it -

i need select div it's classname. after selecting it, need move 100 pixels. here i've tried far: html <div style="z-index:101; position: absolute; left: 0px; top: 300px; width: 20px; height:450px; padding: 0px; border: 0px;" class="wrapper" >content</div> js var class = document.getelementbyclassname("wrapper"); var div = class[0]; div.style.top = '100px'; not sure if i'm understanding nodelists correctly. jsfiddle 1. missing s in getelementsbyclassname() ; 2. used class variable name, reserved word. name else. 3. move up, change .style.top property (300-100 = 200px). fixed code: var wrapper = document.getelementsbyclassname("wrapper"); var div = wrapper[0]; div.style.top = '200px'; <div style="z-index:101; position: absolute; left: 0px; top: 300px; width: 20px; height:450px; padding: 0px; border: 0px;" class="wrapper" >conte...

missing proceed to checkout button in Magento 1.9.1 -

i have dev site ready , have noticed in cart page proceed checkout button missing. have posted question developers of template (jm_haga) using have had no response. there similar post no clear resolution. magento ce 1.9.1 have double checked haven't disabled onepage else mentioned on forum. have double checked cart.phtml changes original uploaded. no change there. there checkout button within header , within cart pop box should not missing cart page. paypal button visible have other payment options need direct customers checkout. let me know if has ideas me or let me know if need further information , info need. there issue 1 of extensions had installed. went through each add on , disabled , refreshed cache check. came across customer comments extension causing problem. has been disabled , have notified developer of extension looking it. because had installed many extensions in 1 go had no idea until final testing of site noticed missing proceed checkout button. ...

javascript - angular call function ng-repeat -

Image
i have table different elements of ng-repeat . , json returns me date compare actual date , if less 72 hours return square green , if not red. pass elements in function return me last value in cell , print of same color. function gethour, other working. var app = angular.module('dashboard', ['ui.bootstrap','ngsanitize']); app.controller('dashboardcontroller', function ($scope, $http, $modal, $sce, $sanitize) { $scope.gethour= function (input){ //console.log(input); var datos = input; input.foreach(function(data){ console.log(data); var date1 = new date(); var date2 = new date(data.lasthwevent); var date3 = new date(data.lasttestevent) var timediff = math.abs((date1.gettime() - date2.gettime())/(1000*60*60)); var timediff2 = math.abs((date1.gettime() - date3.gettime())/(1000*60*60)); if (timediff <= 72 || timediff2 <= 72) { console.log("verde"); $scope.html = '...

indexing - how does More_like_this elasticsearch work (into the whole index) -

so first getting list of termvectors, contain tokens, create map<token, frequency in document>. method createqueue determine score deleting, stopwords , word occurs not enough, compute idf, idf * doc_frequency of given token equals token, keeping 25 best one, after how work? how compare whole index? read http://cephas.net/blog/2008/03/30/how-morelikethis-works-in-lucene/ didn't explain it, or miss point. it creates termquery out of each of terms, , chucks them simple booleanquery , boosting each term calculated tfidf score ( boostfactor * myscore / bestscore , boostfactor can set user). here the source (version 5.0) : private query createquery(priorityqueue<scoreterm> q) { booleanquery query = new booleanquery(); scoreterm scoreterm; float bestscore = -1; while ((scoreterm = q.pop()) != null) { termquery tq = new termquery(new term(scoreterm.topfield, scoreterm.word)); if (boost) { if (bestscore == -1) { bestscore = (s...

python - looping though a dataframe element by element -

if have data frame df (indexed integer) bbg.kabn.s bbg.tka.s bbg.con.s bbg.isat.s index 0 -0.004881 0.008011 0.007047 -0.000307 1 -0.004881 0.008011 0.007047 -0.000307 2 -0.005821 -0.016792 -0.016111 0.001028 3 0.000588 0.019169 -0.000307 -0.001832 4 0.007468 -0.011277 -0.003273 0.004355 and want iterate though each element individually (by row , column) know need use .iloc(row,column) let me know if need create 2 loops (one row , 1 column) , how please? i guess like: for col in rollreturnrandomdf.keys(): row in rollreturnrandomdf.iterrows(): item = df.iloc(col,row) but unsure of exact syntax. me out please? maybe try using df.values.ravel() . import pandas pd import numpy np # data # ================= df = pd.dataframe(np.arange(25).reshape(5,5), columns='a b c d e'.split()) out[72]: b c d e 0 0 1 2 3 4 1 5 6 7 ...

How to retrieve pip requirements (freeze) within Python? -

i posted question on git issue tracker: https://github.com/pypa/pip/issues/2969 can have manner of calling pip freeze/list within python, i.e. not shell context? i want able import pip , requirements = pip.freeze(). calling pip.main(['freeze']) writes stdout, doesn't return str values. there's pip.operation.freeze in newer releases (>1.x): from pip.operations import freeze x = freeze.freeze() p in x: print p output expected: amqp==1.4.6 anyjson==0.3.3 billiard==3.3.0.20 defusedxml==0.4.1 django==1.8.1 django-picklefield==0.3.1 docutils==0.12 ... etc

android adjust view bounds after animation is finished -

i have horizontal linear layout has 3 children; textview sandwiched between 2 buttons. i have set linearlayout focusable, , buttons not focusable, , added following onfocuschangelistener linearlayout: public void onfocuschange(final view v, boolean hasfocus) { if(hasfocus) { v.startanimation(_anims.expand()); } else { v.startanimation(_anims.unexpand()); } } the animations follows: expand: <scale xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fillenabled="true" android:fillafter="true" android:fromxscale="1.0" android:toxscale="1.2" android:fromyscale="1.0" android:toyscale="1.1" android:pivotx="50%" android:pivoty="50%" android:duration="200" /...

android - Problems with setting two layoutsType at CursorAdapter -

i trying set cursor adapter 2 different layouts, first 1 must unique, others - same, getitemviewtype(cursor.getposition()); return 0... here adapter: public class myadapter extends cursoradapter public static class viewholder { public viewholder (view rootview){}} public profileadapter(activity activity, cursor c) { super(activity, c); mactivity = activity; } @override public view newview(context context, cursor cursor, viewgroup parent) { int mlayoutid = -1; mviewtype = getitemviewtype(cursor.getposition()); if (mviewtype == view_type_main){ mlayoutid = r.layout.main; } else { mlayoutid = r.layout.list_items; } view rootview = layoutinflater.from(context).inflate(mlayoutid, parent, false); viewholder viewholder = new viewholder(rootview); rootview.settag(viewholder); return rootview; } @override public void bindview(view view, context conte...

javascript - Angularjs controller in ng-include -

i have blog system projects , articles. people can write articles , featured in projects. my angular application using generic archive view display element, uses custom controller based on element display. example, have projectsarchivecontroller "corrects" api data (first line title, second line description), or articlearchivecontroller (first line title, second line excerpt). everything works fine. now trying display elements in series of tabs, person profile view. want tab projects, 1 articles, etc.. (there other elements). so in personprofilecontroller created simple array-like object: [ { title: 'projects', slug: 'projects', items: vm.projects, controller: "projectsarchivecontroller" },{ title: 'news', slug: 'news', items: vm.news, controller: "newsarch...

How to use a layout file inside a plugin in CakePHP -

using cakephp 2.6.7 i have created plugin works correctly. however, layout file using default 1 inside app/view/layouts . how make use default layout place inside plugins/myplugin/view/layouts ? you can try use pluginname.layoutname for example, $this->layout = "myplugin.mylayout";

javascript - How to have asserts removed in release build? -

i use babelify + watchify + envify + uglify , set node_env watchify ... -g [envify --node_env development] so thought of having assert this: import assert 'assert'; function debug_assert(actual, expected, message = 'assertionerror'){ if(process.env.node_env !== 'production'){ assert.equal(actual, expected, message); } } uglify smart enough cut out body of debug_assert not actual calls debug_assert in code. without code possible have assert calls removed release build? you use jsfmt , code rewriting feature: jsfmt --rewrite "assert.equal(a, b, c) -> ''" file.js haven't tested, might job. replaces occurrences of assert.equal empty string.

java - looping Nested If else in a TreeMap logic -

i'm putting values in treemap follows: if (hdr.getname().equalsignorecase("ip4")) { map.put(1, f); } else if (hdr.getname().equalsignorecase("ethernet")) { map.put(2, f); } else if (hdr.getname().equalsignorecase("tcp")) { map.put(3, f); } else if (hdr.getname().equalsignorecase("udp")) { map.put(4, f); } and i'm trying retrieve using: iterator < map.entry < integer, field >> entries = map2.entryset().iterator(); while (entries.hasnext()) { map.entry < integer, field > entry = entries.next(); if ((entry.getkey() == 1)) { stringbuilder.append(entry.getvalue().getsource()); stringbuilder.append(","); stringbuilder.append(entry.getvalue().getdestination()); } else if ((entry.getkey() == 2)) { stringbuilder.append(entry.getvalue().getsource()); stringbuilder.append(","); stringbuilder.append(entry.getvalue().getdestination()); ...

Ruby merge time and date to datetime -

i want compose datetime object time (which constant in model) , date (which attribute stored in database). how can it? something that: class product < ar::base manufacture_time = '08:00' # there way better write time? def manufactured_at # method, returns # => 1 jan 2012, 08:00, if self.manufacture_date == date.new(2012, 1, 1) # => 5 oct 2012, 08:00, if self.manufacture_date == date.new(2012, 10, 5) # => 23 sep 2014, 08:00, if self.manufacture_date == date.new(2014, 9, 23) end end p.s. don't know how store time constant case... you can construct new datetime using datetime.new , passing single date components such year , month. class product < ar::base manufacture_time = '08:00' def manufactured_at hour, minute = manufacture_time.split(':') datetime.new(manufacture_date.year, manufacture_date.month, manufacture_date.day, hour, minute) end end you can store time want, in array if don...

Torch / Lua, how to select a subset of an array or tensor? -

i'm working on torch/lua , have array dataset of 10 elements. dataset = {11,12,13,14,15,16,17,18,19,20} if write dataset[1] , can read structure of 1st element of array. th> dataset[1] 11 i need select 3 elements among 10, don't know command use. if working on matlab, write: dataset[1:3] , here not work. do have suggestions? in torch th> x = torch.tensor{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} to select range, first three, use the index operator : th> x[{{1,3}}] 1 2 3 where 1 'start' index, , 3 'end' index. see extracting sub-tensors more alternatives using tensor.sub , tensor.narrow in lua 5.2 or less lua tables, such dataset variable, not have method selecting sub-ranges. function subrange(t, first, last) local sub = {} i=first,last sub[#sub + 1] = t[i] end return sub end dataset = {11,12,13,14,15,16,17,18,19,20} sub = subrange(dataset, 1, 3) print(unpack(sub)) which prints 11 12 13 in lu...

javascript - Generate random numbers in ng-repeat -

i'm trying create table random numbers filled in this: <table> <tr> <td>123</td> <td>315</td> <td>356</td> <td>441</td> </tr> <tr> <td>664</td> <td>252</td> <td>236</td> <td>742</td> </tr> ... <!-- more rows above --> </table> my html is: <table> <tr ng-repeat="item in items"> <td>{{randnumgen()}}</td> <td>{{randnumgen()}}</td> <td>{{randnumgen()}}</td> </tr> </table> my js is: app.controller('tablectrl', function($scope) { $scope.items = [1,2,3,4,5,6,7,8,9,0]; $scope.randnumgen = function() { return math.floor((math.rand()*1000)+1); } }); it returns random number how want, throws js error saying: "error: [$rootscope: infdig]" and wont run scripts below controller. ...

Python console double enter doesn't work everytime to start the loop -

after loop done use double enter start it. works example: >>> in range(0,100): ... print but can't double enter when comes 1 (a code sample studying pentesting.). starts new line no triple dots. >>> import socket >>> sniff = socket.socket(socket.af_packet, socket.sock_raw, 3) >>> sniff.bind(("eth0", 0x0003)) >>> ap_list =[] >>> while true : ... fm = sniff.recvfrom(6000) ... fm= fm1[0] ... if fm[26] == "\x80" : ... if fm[36:42] not in ap_list: ... ap_list.append(fm[36:42]) ... = ord(fm[63]) ... print "ssid -> ",fm[64:64 +a],"-- bssid ->", \ ... fm[36:42].encode('hex'),"-- channel -> ", ord(fm[64 +a+12]) edit: i'm using linux(xubuntu 14.04).

angularjs - Angular and ES6: Karma Testing with SystemJS -

afternoon all, have mean stack app developing tests for. angular code written using es6 have been trying configure karma , systemjs babel transpiler run tests. currently, when karma start karma.conf.js browser fires up, hangs—as in cannot click debug or else—, , browser closes console error: uncaught typeerror: cannot set property 'mock' of undefined. the last line before debug [web-server]: serving (cached): ( ... ) my current application structure works this: i have of module imported 1 file app.js injected app module: import homecontroller './components/home/home.js'; import homeservice './services/homeservice.js'; import homedirective './directives/homedirective.js'; import differentcontroller './components/different/different.js'; // ### filters import slugifyfilter './filters/slugify.js'; var modulename = 'app'; angular.module(modulename, ['ngnewrouter', 'ngmock', 'nganimate', '...

How can I pull user details if they're logged in username matched a username in another table on Drupal? -

i have attemped following code: <?php session_start(); // connects database $mysqli = new mysqli("localhost", "root", ""); $query = "select first_name, last_name, balance customers username = '".$_session['name']."'"; if($result = $mysqli->query($query)) { while($row = $result->fetch_assoc()) { echo "<div align=\"center\">"; echo "<br />your <b><i>profile</i></b> follows:<br />"; echo "<b>first name:</b> ". $row['first_name']; echo "<br /><b>last name:</b> ".$row['last_name']; echo "<br /><b>balance:</b> ".$row['balance']; echo "</div>"; } $result->free(); } else { echo "no results found"; } i following error: notice: session had been started - ignoring session_start() in include_once() (li...

mysql - Better database design among two -

i have 2 different following database designs achieves same kind of result i'm expecting: design 1: http://sqlfiddle.com/#!9/4cbe8/2 design 2: http://sqlfiddle.com/#!9/7e7aa/7 but i'm confused on 1 better design. database design suits perfect when size grows in terms of performance same sample query i've in sqlfiddle?

laravel 5.0 collection get method gives 999 records -

can me records. i'm facing 1 issue i'm not able records using clause model::where('key', 'value')->get() how records using get. did not solutions googling.. have tried doing diedump? if try dd(week::where('price', '0')->get()); i collection 17158 array items. collection {#17158 ▼ #items: array:16882 [▼ 0 => week {#17159 …21} 1 => week {#17160 …21} 2 => week {#17161 …21} 3 => week {#17162 …21} 4 => week {#17163 …21} etc.

python - How to get/set network connection through Appium for an android device -

i try use appium test android device: basic work need network connection status. environment: [appium server v 1.4.0 on windows 7 + python client 0.16] from appium import webdriver desired_caps = {} desired_caps['platformname'] = 'android' desired_caps['platformversion'] = '4.4' desired_caps['devicename'] = 'samsung galaxy note4' desired_caps['browsername'] = 'chrome' driver = webdriver.remote('http://localhost:4723/wd/hub', desired_caps) driver.get('http://google.com') print driver.contexts print driver.network_connection time.sleep(5) driver.quit() however, when run script, got below output: > [u'native_app', u'webview_1'] traceback (most recent call last): > file "d:/pycharmprojects/work/hello/work_ym/appium/sample_1.py", line > 15, in <module> > print driver.network_connection() file "c:\python27\lib\site-packages\appium\webdriver\web...

apache - basic use of constructor XSSFWorkbook() -

i want enable class access , information excel workbook using apache poi. using: xssfworkbook mybook = new xssfworkbook("filepath"); but throws "unhandled exception type ioexception". i sure it's obvious, don't understand why isn't working. constructor should xssfworkbook() according apachepoi documentation. know missing fundamental. if reading xlsx file. try { workbook workbook = new xssfworkbook(opcpackage.open(path)); worksheet worksheet = workbook.getsheet("sheet1"); //rest of logic } catch (exception ex) { ex.printstacktrace(); } make sure file on filepath exist.

sql server - Day Date difference between two date calculation in SQL AND C# producing varying result -

i calculating day difference in 2 dates. in c# diffdays = (enddate-startdate).days so considering enddate 6/26/2015 , startdate 6/10/2015 diffdays value 15 shown in autos section while debugging. while in sql server doing is select datediff(day, startdate, enddate ) where enddate 6/26/2015 , startdate 6/10/2015 , gives result 16. i need these 2 day difference same. doing wrong? the timespan.days property returns whole days only, dropping fractional portion. depending on time portion of 2 datetime 's, expect behavior you're seeing. try taking time portion out of equation using date property (and setting both times midnight): diffdays = (enddate.date - startdate.date).days alternatively, can round totaldays property (which includes fractional portions of days): diffdays = math.ceiling((enddate - startdate).totaldays);

Read python list from a file -

i printed list l file using f = open('a.txt', 'a') f.write(str(l)) now, how can retrieve list file. and list l list of list of dictionaries. its not best way serialize data file, conversion string list use ast.literal_eval . e.g. import ast l = [['dir/path', 'other/path'],['path/path', 'blah/xyz']] open('a.txt', 'a') f: f.write(str(l)) open('a.txt') fread: s = fread.read() l2 = ast.literal_eval(s) print type(l2) in l2: print there plenty of better ways, pickle or json standout choices. note append complete list file each time, repeated runs of code write file result in file containing invalid python syntax cannot eval led list.

underscore.js - Get coordinates of jquery element array -

i want extract array of left coordinates (simply numbers) matched jquery array. similar this: var array = element.nextall().position().left is there neat way of doing this, perhaps underscore? so in case jquery array contains number of divs, each of them want jquery position() - object , extract left coordinate. resulting array contain numbers each of div's left coordinate. please try code: array = $(element.nextall()).map(function() { return $(this).position().left; }).get(); please refer link

reactjs - componentDidMount method not triggered when using inherited ES6 react class -

i'm trying use es6 classes inside of react, , want components inherit methods, try extend component extends react.component class, componentdidmount method doesn't trigger , hence nothing gets rendered. code i'm using: basecomponent.jsx import react 'react'; class basecomponent extends react.component { constructor() { super(); console.log('basecomponent constructor'); } render() { return ( <div>hello, im base component</div> ); } } export default basecomponent; examplecomponent.jsx import basecomponent './basecomponent'; class examplecomponent extends basecomponent { constructor(props) { super(props); } componentdidmount() { console.log('examplecomponent mounted'); } render() { return ( <div>hello, im example component</div> ); } } export default example...

mongodb - Unable to get mizzao/meteor-autocomplete to work with collection -

i using mizzao/meteor-autocomplete , having problems in trying work. when viewing page in browser, getting no results @ when typing text. i've created appropriate collection: institutions = new mongo.collection("institutions"); and know there data in actual db, still no success. i've included files below. publications.js (located in server folder) meteor.publish('institutions', function(args) { return institutions.find({}, args); }); registrationstart.js i've 2 helpers; 1 powers search , other should returning institutions. have tried token: '@' argument no success. if (meteor.isclient) { template.registrationstart.helpers({ settings: function() { return { position: "top", limit: 7, rules: [{ collection: institutions, field: "name", options: '', matchall: true, ...

ios - Doesn't save editing text in UITextView -

i have viewcontroller s , 2 classes masterviewcontroller.swift , loginviewcontroller.swift . in first class have tableview in can add record , open new viewcontroller class detailviewcontroller.swift in textview in can add text , when go tableview must save text, when it doesn't save. cod masterviewcontroller : import uikit import coredata class masterviewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate, nsfetchedresultscontrollerdelegate { @iboutlet var tableview: uitableview! var isauthenticated = false var managedobjectcontext: nsmanagedobjectcontext? = nil var _fetchedresultscontroller: nsfetchedresultscontroller? = nil var didreturnfrombackground = false override func awakefromnib() { super.awakefromnib() } override func viewdidload() { super.viewdidload() self.navigationitem.leftbarbuttonitem = self.editbuttonitem() view.alpha = 0 let addbutton = uibarbuttonit...

Passing context to gorilla mux - go idioms -

i'm reasonably new golang , trying work out best way idiomatically. i have array of routes statically defining , passing gorilla/mux . wrapping each handler function time request , handle panics (mainly understand how wrapping worked). i want them each able have access 'context' - struct that's going one-per-http-server, might have things database handles, config etc. don't want use static global variable. the way i'm doing can give wrappers access context structure, can't see how actual handler, wants http.handlerfunc . thought convert http.handlerfunc type of own receiver context (and wrappers, (after playing about) couldn't handler() accept this. i can't think i'm missing obvious here. code below. package main import ( "fmt" "github.com/gorilla/mux" "html" "log" "net/http" "time" ) type route struct { name string method st...