Posts

Showing posts from February, 2013

android - I am trying to get Json Object into my mobile app, and parse it to be added in Map -

here json object { "shops": [ { "shop_id": "916tcr", "lat": "10.512573", "long": "76.255868", "address": "******" }, { "shop_id": "rktcr", "lat": "10.527642", "long": "76.214435", "address": "sanfrncisco,usa" }, { "shop_id": "lstcr", "lat": "10.527642", "long": "76.214435", "address": "afgfagra" }, { "shop_id": "wbstcr", "lat": "10.527642", "long": "76.214435", "address": "agkangj" }, { "shop_id": "bhttcr", "lat": "10.226967", "

schema.org - Multiple rich snippets on homepage? -

i creating website form enterprise , wonder how/how many snippets should use on homepage. i know separate multiple categories such local business or more generic organization, events, product etc. i have read post: homepage rich snippets , one: multiple schema.org product items & how in search engine result? in case on homepage (let's index.html) want present activity, put links services/products propose, , show incoming events. which snippet(s) should use? 1) 1 such organization? (my services not available directly suppose not local business category) 2) or should put several snippets: organization + event + products because 3 categories described/present on homepage? according google employee , google search won’t show rich snippets homepages. not documented, , might change anytime. from perspective of schema.org, it’s fine provide data possible. if have multiple entities on homepage, can use multiple schema.org types describe them. if 1 of th

javascript - How to prevent chrome extension to mess with my site events? -

i using mousewheel event in site. have webgl frontend, scrollbars disabled, mousewheel used manipulating objects. works good, if not chrome wheel smooth scroller extension. bastard scrolls page not meant scrolled, , - blocks mousewheel event. i attach event listener this: window.addeventlistener('mousewheel', mousewheel); what should do? attaching event div instead of window not option

Problems with css for my navigation bar -

i trying make when user hovers on link in navigation bar font colour changes blue cant change it. have tried this: #nav a:hover{ color: #1b8ad8; background: none; text-decoration: none; } but still not working. help? jsfiddle: https://jsfiddle.net/0k6wnvs6/ try below css ul#nav li a:hover{ color: #1b8ad8; background: none; text-decoration: none; }

How do I replicate PHP's PRNG algorithm implementation in C#? -

i've created procedural image generator uses default pseudo-random number generator built in php5. i can set seed mt_srand($id); , same numbers sequence (with mt_rand(0,255); ). what need: a prng implementation work exact same way in php , c# example: php: mt_srand(123); echo mt_rand(0,255); //returns 34 echo mt_rand(0,255); //returns 102 echo mt_rand(0,255); //returns 57 echo mt_rand(0,255); //returns 212 echo mt_rand(0,255); //returns 183 c#: setseed(123); print getrand(0,255); //returns 34 print getrand(0,255); //returns 102 print getrand(0,255); //returns 57 print getrand(0,255); //returns 212 print getrand(0,255); //returns 183 ( ^ function names not referring existing ones, named example's sake ) thanks tips! i resolved problem implementing custom prng algorithm myself both in c# , php. since needed , didn't have time go through whole mersenne twister theory , 2 languages incompatibilities (like different behaviors of types , op

jenkins - Elevate creditals with powershell via Local System Account -

i want deploy code using powershell via jenkins job. works fine in powershell ise. $username = "mydomain\builder" $password = "notmypassword" $credentials = new-object system.management.automation.pscredential -argumentlist @($username,(convertto-securestring -string $password -asplaintext -force)) $arguments = "-executionpolicy bypass -file c:\test.ps1 -nonewwindow -workingdirectory c:\windows\system32\windowspowershell\v1.0 -nologo -noninteractive" start-process "c:\windows\system32\windowspowershell\v1.0\powershell.exe" -credential $credentials -argumentlist $arguments but when run jenkins use local system following error message. start-process : command cannot run due error: access denied. @ c:\windows\temp\hudson5557889306949142167.ps1:7 char:1 + start-process powershell.exe -credential $credentials -argumentlist $ if change change jenkins service account works. why won't elevated permission work under local system account?

Greedy algorithm implementation, Haskell -

i need implement haskell function receives 1 int (truck load capacity), , list of ints (boxes models can loaded on truck). to define box models must placed preferably in truck, it's requested boxes greater capacity in relation available space, placed first. the algorithm should return list of models of boxes placed on truck. have no idea how program functional paradigm :/ maximizeload 103 [15, 20, 5, 45, 34] [45, 45, 5, 5] thanks! bruce force approach smart filtering maximumload n = head . head . group length . last . group sum . filter ((<= n) . sum) . map concat . sequence . map (rep n) . reverse . sort rep n x = take ((div n x)+1) $ iterate (x:) [] group f = groupby ((==) `on` f) . sortby (comparing f) > maximumload 103 [15, 20, 5, 45, 34] [34,34,20,15] update greedy algorithm,

r - Can't drop column - select() with dplyr -

i'm using dplyr , have grouped data.frame. tried drop column select function in grouped_df, got error message > tbl %>% select(-names) error: corrupt 'grouped_df', contains 42 rows, , 965 rows in groups my data below. > print(tbl_df(tbl), n = 1000) source: local data frame [42 x 15] household names x2003 x2004 x2005 x2006 x2007 x2008 x2009 x2012 last.avail last.avail.year abschange.last annchange.last translation (chr) (fctr) (int) (int) (int) (int) (int) (int) (int) (int) (int) (dbl) (int) (dbl) (fctr) 1 households bostad 59280 61850 62760 63210 66950 73340 72350 77750 77750 2012 18470 0.030594980 accomodation 2 households fritid och kultur 45

JQuery UI - Autocomplete not a function -

i getting following error code below. i'm not quite sure how fix problem, know has imports. ideas on how resolve this? uncaught typeerror: $(...).autocomplete not function index.php: <link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <style> .ui-autocomplete-loading { background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat; } </style> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script> <script> $(function () { function log(message) { $("<div>").text(message).prependto("#log"); $("#log").scrolltop(0); } $("#birds").autocomplete({ source: "search.php&quo

php - Yii2. Setting a custom controller namespace -

i have controller in components/test/test/controllers folder, called mycontroller. if set namespace "namespace app\components\test\test", , try call controller if says "page not found". i have been reading , know default yii2 sets namespace controllers "app\controllers". also know can change namespace controllers config: 'controllernamespace' => 'app\\components\test...' but wanted change 1 controller not all. similar modules, there can do: $this->controllernamespace = 'app\modules\test\test'; i found there called "controllermap", maybe solution? ideas? example have created inside "components" (basic template) controller locationcontroller content: namespace app\components; use yii\web\controller; class locationcontroller extends controller { public function actionadd() { return "hola1"; } public function actionremove() { return "hola2&q

python - Symbol not found: _BIO_new_CMS -

i new mac , don't understand why scrapy doesn't seem work more. suspect openssl not valid in el capitan. i tried: pip install cryptography pip install pyopenssl brew install openssl and still error below. there way can fix this? $ python python 2.7.10 (v2.7.10:15c95b7d81dc, may 23 2015, 09:33:12) [gcc 4.2.1 (apple inc. build 5666) (dot 3)] on darwin type "help", "copyright", "credits" or "license" more information. >>> import openssl traceback (most recent call last): file "<stdin>", line 1, in <module> file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/openssl/__init__.py", line 8, in <module> openssl import rand, crypto, ssl file "/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/openssl/rand.py", line 11, in <module> openssl._util import ( file "/library/frameworks/python.framewo

oop - C++ prefered way to share objects between methods within the same class -

given class has 2 methods need share variable best way pass/share variable between them? assuming variable not needed anywhere else in class. if variable stl container, change anything? i'm considering following 3 options: instantiate variable in 1 method , return pointer, delete in other method. class myclass { public: std::vector<int>* method1(); void method2(); }; std::vector<int>* myclass::method1() { std::vector<int> *my_int_vector = new std::vector<int>; //manipulate vector in way return my_int_vector; } void myclass::method2() { std::vector<int> *myvector; myvector = this->method1(); //manipulate vector in way delete myvector; } this separates new , delete between methods seems to begging go wrong. alternatively can use class private member property hold variable. class myclass { private: std::vector<int> myvector; public: void method1(); v

angularjs - ECONFLICT Unable to find suitable version for angular-bootstrap while installing datetimepicker -

i having error: econflict unable find suitable version angular-bootstrap when trying install datetime picker in angularjs. i have angular.js 1.2.16 defined on bower file , datetime picker seems requiring newer version of angularjs guess. dont know how fix problem, there way fixed? this bower.json { "name": "venture", "version": "0.0.0", "dependencies": { "angular": "1.2.16", "json3": "~3.3.1", "es5-shim": "~3.1.0", "angular-resource": "1.2.16", "angular-cookies": "1.2.16", "angular-sanitize": "1.2.16", "angular-animate": "1.2.16", "angular-touch": "1.2.16", "angular-route": "1.2.16", "font-awesome": "4.3.0", "angular-bootstrap": "0.12.0", "oclazyloa

Sort elements of an array in ascending order (java) -

im trying sort array in ascending order. reason performs loop once. why doesn't keep going until sorted? help public class sudoku { public static void main(string[] args) { int[] = { 1, 4, 3, 5, 2 }; system.out.println(arrays.tostring(sortarray(a))); } public static int[] sortarray(int[] nonsortedarray) { int[] sortedarray = new int[nonsortedarray.length]; int temp; (int = 0; < nonsortedarray.length - 1; i++) { if (nonsortedarray[i] > nonsortedarray[i + 1]) { temp = nonsortedarray[i]; nonsortedarray[i] = nonsortedarray[i + 1]; nonsortedarray[i + 1] = temp; sortedarray = nonsortedarray; } } return sortedarray; } } try using existing java api, after modifying code public static void main(string[] args) { int[] = { 1, 4, 3, 5, 2 }; arrays.sort(a); system.out.println(arrays.tostring(a)); } or public static int[] sortarray(int[] nonsortedarray) {

php - Pass Multiple parameters Angularjs resource -

i have usersservice.js app.factory('usersservice', function($resource) { return $resource('api/users/:id', {}, { update: {method:'put'}, }); along index.php (api php slim framework) ... $app->get('/users/:id', 'getuser'); $app->get('/users/:username', 'getuserbyusername'); function getuser(){ ... } function getuserbyusername(){ ... } ... now, when try call somewhere usersservice.get({id:15}); works, when try call usersservice.get({username:'test'}); doesn't work... i tried every possible way find on google couldn't make work. can make separate service user username, i'd keep in 1 service if possible. please help, thanks! you have tell angular $resource value :username. for more details @ documentation change yout userservice.js : app.factory('usersservice', function($resource) { return $resource('api/users/:id/:username', {id:'@id',username:

Store form data in a list jsp -

i have form submits jsp page , want save data list whenever user clicks on submit button, display on jsp page. tried request.getparameter("submit") returns null value , arraylist overwrites data. should do? <form action="messages.jsp" target="msgframe" method="post" > <label for="entrer">entrez votre message:</label> <input type="text" name="msg"/> <input type="submit" name="submit" value="envoyer"/> <input type="reset" value="quitter"/> </form> if want save value of typed message, <input type="text" name="msg"/> use : string msg = request.getparameter("msg")

c# - Why Outlook is not getting synchronized -

i developing c# application uses outlook com object library. after adding appointment calendar, shown in outlook desktop application appointment not found @ outlook web application. miserable thing appointments got synchronized , stopped synchronizing suddenly. here's how saved appointment: outlook.application olapp = new outlook.application(); outlook.namespace mapins = olapp.getnamespace("mapi"); string profile = ""; mapins.logon(profile, null, null, null); outlook.appointmentitem apt = olapp.createitem(outlook.olitemtype.olappointmentitem); apt.save(); how can make synchronized? i had call send method after save method, otherwise outlook sends appointment whenever wants. outlook.application olapp = new outlook.application(); outlook.namespace mapins = olapp.getnamespace("mapi"); string profile = ""; mapins.logon(profile, null, null, null); outlook.appointmentitem apt = olapp.createitem(outlook.olitemtype.olappointm

c++ - Inline functions in a class -

this question has answer here: defining member function inside class instead of outside in c++? 4 answers is true if function body defined inside class, compiler mark inline? (even if not marked writer) example: class f { public: void func() { std::cout << "is inline?\n"; } }; yes. [c++14: 9.3/2]: a member function may defined (8.4) in class definition, in case inline member function (7.1.2), or may defined outside of class definition if has been declared not defined in class definition. [..] however, whether has observable effects beyond associated linkage requirements predictable inline keyword ever is. the reason rule legal include class definition — member functions , — via header multiple translation units. have multiple reference linker errors otherwise.

asp.net - How to incorporate another controller's view and behavior into "this" controller's view? -

i have jqueryui tabbed html page, , in content area 1 of tabs, have put follows: <div id="tabs-1ua"> @renderpage("~/views/admin/create.cshtml") </div> the create.cshtml page correctly appear within tab, when create user (this view basic user creation page) , click button, nothing happens. no user created , no error presented. "this" html tabs in different controller not have model associations. user creation inside admincontroller, pertinent methods shown below: public actionresult create() { return view(); } [httppost] public async task<actionresult> create(createmodel model) { if (modelstate.isvalid) { appuser user = new appuser { username = model.name, email = model.email}; identityresult result = await usermanager.createasync(user, model.password); if (result.succeeded) { return redirecttoaction("index"); } e

php - Non-overlapping minutes per day -

Image
i have been cracking head trying resolve problem. i need know how many minutes of day being worked staff member alone in shop. here data daynumber = 0 (monday): for day, staff member staffid = 32 alone 11:00 11:05 in shop. what have far, adding starting times, i'm thinking is, if have way of knowing staff member alone, can calculate time between index , next. for($i=0; $i<count($results); $i++){ if(isset($results[$i+1])){ if($results[$i]->starttime < $results[$i+1]->starttime) $start = strtotime($results[$i]->starttime); $end = strtotime($results[$i+1]->endtime); $minutes += idate('i', $end - $start); } } } any thoughts? update 1: still no luck; for($i=0; $i<count($results); $i++){ if(isset($results[$i+1])){ $startdate1 = strtotime($results[$i]->starttime); $enddate1 = strtotime($results[$i]->endtime); $startdate2 =

git - This branch is 1 commit ahead of -

i have no idea doing wrong. trying sync fork upstream several commits behind. followed guide here: https://help.github.com/articles/syncing-a-fork/ after steps described above , push them new commit appears: merge remote-tracking branch 'upstream/master' now fork 1 commit ahead of upstream. why , can do? well makes sense. pushed own fork. original repo, has not yet pulled new commits, fork ahead of upstream/original repo. contribute original repo want make pull request.

What is the shortest possible way to write a block scope in JavaScript? -

is shortest possible way block scope in body of for loop? x = {}; (i of ['a', 'b']) { (function(i) { x[i] = function() { this.v = i; } })(i); } or there syntactic sugar not able find? explanation: with block scope created objects have different values. new x.a ⟹ x.(anonymous function) {v: "a"} new x.b ⟹ x.(anonymous function) {v: "b"} without block scope y = {}; (i of ['a', 'b']) { y[i] = function() { this.v = i; } } the created objects have same value. new y.a ⟹ y.(anonymous function) {v: "b"} new y.b ⟹ y.(anonymous function) {v: "b"} given using es6 for of loop, have block scope iteration variable anyway - don't forget use let / const declaration! there no need iefe. let x = {}; (let of ['a', 'b']) x[i] = function() { this.v = i; }; if don't use es6, i'd recommend use 1 of array iteration methods , like var x = ['a',

python - Best way to eliminate columns with only one value from pandas dataframe -

i'm trying build function eliminate dataset columns 1 value. used function: def onecatelimination(dataframe): columns=dataframe.columns.values column in columns: if len(dataframe[column].value_counts().unique())==1: del dataframe[column] return dataframe the problem function eliminates column more 1 distinct value, i.e. index column integer number.. just df.dropna(thresh=2, axis=1) will work. no need else. keep columns 2 or more non-na values (controlled value passed thresh ). axis kwarg let work rows or columns. rows default, need pass axis=1 explicitly work on columns (i forgot @ time answered, hence edit). see dropna() more information.

javascript - How to dynamically check radio buttons with one or multiple -

i have case radio button groups generated dynamically in form. requirements: the number of buttons per group 1 or many. there function checks whether radio button selection has been made , alerts error if no selection made. when there 1 radio button check fails , alerts error, when button selected. when log (or in case alert) form element different object type single group or multiple group: htmlinputelement vs radionodelist . since check function checkkrb() iterates through list , htmlinputelement returns length of undefined, in single button group selection not caught. why object types different? why not radionodelist of length 1 single radio button? how can check variety of radio button groups when number of buttons unknown? here stripped down example: html <form action=""> <!-- single radio button --> <label for="single">single</label> <input type="radio" id="single" name="

c# - MediaRecorder throw java.lang.illegalstateexception at Start() -

Image
i facing issue using mediarecorder in android xamarin. when try start or stop record exception raised : 07-15 21:06:40.984 w/system.err(13609): java.lang.illegalstateexception 07-15 21:06:41.014 w/system.err(13609): @ android.media.mediarecorder.start(native method) 07-15 21:06:41.014 w/system.err(13609): @ md51ef13e2ce92dda6cb40f015673d2b702.videoansweractivity.n_btntakevideo(native method) 07-15 21:06:41.014 w/system.err(13609): @ md51ef13e2ce92dda6cb40f015673d2b702.videoansweractivity.btntakevideo(videoansweractivity.java:39) 07-15 21:06:41.014 w/system.err(13609): @ java.lang.reflect.method.invokenative(native method) 07-15 21:06:41.014 w/system.err(13609): @ java.lang.reflect.method.invoke(method.java:515) 07-15 21:06:41.024 w/system.err(13609): @ android.view.view$1.onclick(view.java:3955) 07-15 21:06:41.024 w/system.err(13609): @ android.view.view.performclick(view.java:4575) 07-15 21:06:41.024 w/system.err(13609): @ android.view.view$perfor

javascript - Extract CSV from ZIP file in gmail thread and write data to a google sheets -

i'm working on script following. looks specific label in gmail, "test". find first message , attachment (which zip, containing single csv) extract csv , write google spreadsheet. i've managed csv attachment, not zip csv inside. here's i'm @ far. i'm sure it's simple i'm missing, seems reading zip , writing weird chars rather reading csv inside. function getcsv() { var mylabel = gmailapp.getuserlabelbyname("test"); var threads = mylabel.getthreads(0,1); var msgs = gmailapp.getmessagesforthreads(threads); var attachments = msgs[0][0].getattachments(); logger.log(attachments); var csv = attachments[0]; logger.log(csv); var extracted = utilities.unzip(csv); logger.log("unzipped data "+ extracted); var tostring = extracted.getblob.getdataasstring(); logger.log(tostring); var data = utilities.parsecsv(tostring); logger.log(data); //var ss = spreadsheetapp.getactivespreadsheet(); //var sheet = ss.gets

google bigquery - Random sampling complete rows -

i know question 1 can random sampling rand . select * [table] rand() < percentage but require full table scan , incur equivalent cost. i'm wondering if there more efficient ways? i'm experimenting tabledata.list api got java.net.sockettimeoutexception: read timed out when index large (i.e. > 10000000). operation not o(1)? bigquery .tabledata() .list(tableref.getprojectid, tableref.getdatasetid, tableref.gettableid) .setstartindex(index) .setmaxresults(1l) .execute() i recommend paging tabledata.list pagetoken , collect sample rows each page. should scale better. another (totally different) option see use of table decorators can in loop grammatically generate random time (for snapshot) or time-frame (for range) , query portions of data extracting needed data. note limitation: allow sample data less 7 days old.

xml - android.view.MenuItem android.view.MenuItem.setVisible(boolean)' on a null object reference -

public boolean onprepareoptionsmenu(menu menu) { boolean draweropen = mdrawerlayout.isdraweropen(mdrawerlist); menu.finditem(r.id.action_websearch).setvisible(!draweropen); return super.onprepareoptionsmenu(menu); } <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/action_websearch" android:icon="@drawable/action_search" android:title="@string/action_websearch" android:showasaction="ifroom|withtext"/> </menu>

Python - making my code more economic -

i need on making code more economical - sure that, there lot of lines can cut down on. the code quiz ask 10 questions , score outputted @ end. import random studentname=input("what name?:") score=0 trueanswer=0 def question(): global operation global number1 global number2 global studentanswer global score number1=random.randrange(1,10) number2=random.randrange(1,10) operation=random.choice(["*","-","+"]) print("what is", number1,operation,number2,"?:") studentanswer=int(input("insert answer:")) def checking(): global score if operation == "*": trueanswer = number1*number2 if studentanswer == trueanswer: print("correct") score=score+1 else: print("incorrect") score=score elif operation == "-": trueanswer = number1-number2 if stude

Python Sphinx/rest substitution for long names defining substitution rule in same source file -

post python sphinx referencing long names provided 1 answer close looking regards substitution directives long class names. def examplefunction(): '''here example docstring referencing |reallylongexampleclassname| .. |reallylongexampleclassname| replace:: :class:`.reallylongexampleclassname` in example provided however, definition replacement rule within same pydoc block. hoping this: """define rst links/substitutions used in file .. |reallylongexampleclassname| replace:: :class:`.reallylongexampleclassname` .. |anotherexampleclassname| replace:: :class:`.anotherexampleclassname` """ # more code # more code def examplefunction(): '''here example docstring referencing |reallylongexampleclassname| # define function since every file in question specific, use of rst_epilog doesn't extend well. possible. you can variable rst_epilog in conf.py

Creating and argsorting a Python-numpy array with a structured dtype leaks memory -

this week i've been hunting memory leak in python application has been causing memoryerrors, , have managed distill logic appears causing down 20 lines. following snippet of code consumes steadily increasing amounts of memory when run (even after calls gc.collect every 5000th iteration), observed task manager. why? bug in numpy? import gc import numpy np while true: names = ["poh"] + \ ["head %d long data field name many words" % in xrange(200)] formats = [">f"] + [">i"] * 200 offsets = range(0, 804, 4) dt = np.dtype({"names": names, "formats": formats, "offsets": offsets}) array = np.zeros((1000,), dt) sortedindices = np.argsort(array, order=["poh"]) n += 1 if n % 1000 == 0: print n if n % 5000 == 0: gc.collect() i running numpy 1.11.0 python 2.7.11 on 64-bit windows 7.

java - Swing Component (re)paint mechanism fails to properly draw, when requests are too fast -

from java's documentation says repaint mechanism of component optimized , cached, if called lot of times, won't clog drawing pipeline. it seems though under heavy invocation, fails draw latest frames. consider following example: import java.awt.graphics; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.windowconstants; public class testrepaint extends jpanel { public static void main(string[] args) { jframe frame = new jframe(); frame.setcontentpane(new testrepaint()); frame.setsize(300, 100); frame.setdefaultcloseoperation(windowconstants.dispose_on_close); frame.setlocationrelativeto(null); frame.setvisible(true); } private long start; { addmouselistener(new mouseadapter() { @override public void mouseclicked(mouseevent e) { start = system.currenttimemillis();

r - How to create bipartite network in igraph with duplicate vertices names -

i want create bipartite network connects nfl teams colleges drafted players from. have 1955 rows in data - 1 row each player. have 2 csv files (edge.csv , node.csv). edge data set such: team college arizona alabama arizona alabama arizona arizona st. arizona arizona st. arizona auburn and node data set such: team player no. type arizona 1 true arizona b 2 true arizona c 3 true arizona d 4 true arizona e 5 true the other variables in node data age, position, games played, games started, weight, height, birthdate, pro years played, team drafted, round drafted, overall pick, year drafted. and added colleges team column starting @ row 1956 , filled in type false, other variables across na. when try convert these files graph in rstudio, keep getting error: error in graph.data.frame(edge.df, node.df, directed = false) : duplicate vertex names which assume because names of teams , colleges

python 2.7 - Cannot update table , when comparing data between two cursors -

i wanted compare rows of table find out if equal or not , did create 2 cursors 1. select links table visted = yes 2. select links table visted = no using loop , if statement want compare visited links not visited links if equal or not , if equal update visted of link "yes" not done yet (my aim exit program if links visted , marked yes or cursor " visited=no " returns null value) portion code: import sys import mysqldb import urllib import urlparse import re import htmlparser htmlparser import htmlparseerror bs4 import beautifulsoup mydb = mysqldb.connect(host='localhost', user='root', passwd='shailang', db='mydb') cursor = mydb.cursor() def process2(url): flag=0 cursor.execute("select links data_urls visited = 'ye'") yes_rows = cursor.fetchall() cursor.execute("select links data_urls visited = 'no'") no_rows = cursor.fetchall()

java - In Thymeleaf how can you use separate resolvers for HTML and JavaScript to copy JavaScript from a file into the generated HTML -

Image
i creating proof of concept program later brought larger project. thymeleaf seemed template engine try (natural templates active development) , seems fit have been having following issue. goal: take json , generate html file work offline report viewing. trying convert premade html template single html page no external references other files or internet. problem: can't javascript resolve correctly inside template resolver. detailed description: have attempted keep javascript , html in separate directories. way javascript can use '.js' suffix , html can use '.html' suffix. in order created 2 resolvers, 1 html , 1 js. have seen similar things done html fragments , seemed work other people. the problem js resolver never seems used when hits <script th:include="jquery.min></script" part of demo.tpl.html file. figured because .setorder(1) on html resolver , .setorder(2) on js resolver when can't find 'jquery.min' template

haskell - How can i find an item in a list then return its pair? -

this question has answer here: operating on return maybe contains “just” 2 answers i have list, [('a',1),('b',2),..] i'd key value search. found lookup returns 'maybe int'. there function returns value key, , gives normal int back? what should function in case key not in list? if sure key in list, then import data.maybe and run result (i.e. maybe int) through fromjust . you'll plain int, , when key not in list you'll exception.

OBDII data pass to wxpython staticText continues update issues(raspberry PI2) -

i total beginner in programming. start small project using raspberry pi connect car obd port , reading data wxpython gui. obd library using http://brendan-w.com/work/python-obd using instruction above, successful print living rpm data in python shell line line. code here: import obd import time connection = obd.async("/dev/rfcomm0") # same constructor 'obd.obd()' cmd = obd.commands.rpm connection.watch(cmd) # keep track of rpm connection.start() # start async update loop while(true): response_rpm = connection.query(cmd).value print(response_rpm) # non-blocking, returns time.sleep(0.01) #obd.debug.console = true after this, created gui using wxformbuilder , change wxpython code. test gui wxpython code in raspberry pi no problem. after add obd library code and, whole frame not working thing want using statictext.setlabel() display living data in while loop. code after add obd library here : http://pastebin.com/4h

scp - recursively copy files by creating required paths in destination directory using python -

i want recursively copy files server location machine preserving directory structure. server structure /opt/shared/dir1/dir2/dir3/sample.json /opt/shared/dir1/dir2/dir3/sample2.json /opt/shared/dir1/dir2/sample.json /opt/shared/dir1/dir2/sample2.json i want find sample.json starting /opt/shared/dir1 , copy these local machine maintaining structure. /home/users/a/dir1/dir2/dir3/sample.json /home/users/a/dir1/dir2/sample.json i using python2.7 i can use os.walk @ server files but how copy create directory structure? how use scp copy machine? import os import fnmatch top=/opt/shared/dir1 allfiles=[] filepattern="sample.json" path, dirlist, filelist in os.walk(top): name in fnmatch.filter(filelist,filepattern): allfiles.append(os.path.join(path,name))

access amazon S3 bucket from hadoop specifying SecretAccessKey from command line -

i trying access amazon s3 bucket using hdfs command. here command run: $ hadoop fs -ls s3n://<accesskeyid>:<secretaccesskey>@<bucket-name>/tpt_files/ -ls: invalid hostname in uri s3n://<accesskeyid>:<secretaccesskey>@<bucket-name>/tpt_files usage: hadoop fs [generic options] -ls [-d] [-h] [-r] [<path> ...] my secretaccesskey includes “/”. cause of such behavior? in same time have aws cli installed in server , can access bucket using aws cli without issues (accesskeyid , secretaccesskey configured in .aws/credentials): aws s3 ls s3:// <bucket-name>/tpt_files/ if there way how access amazon s3 bucket using hadoop command without specifying keys in core-site.xml? i’d prefer specify keys in command line. any suggestions helpful. the best practice run hadoop on instance created ec2 instance profile role, , s3 access specified policy of assigned role. keys no longer needed when using instance profile. http://docs.aws.

javascript - Parse.FacebookUtils.logIn returns password error but doesn't show Facebook login -

i trying use parse.facebookutils.login() authenticate user facebook login. code seems run returns error "missing user password". facbook sign in page isn't shown user enter details. goes straight error message. my ionic project app.js has following relevant code in $ionicplatform.ready() function (ids fake purposes of posting): parse.initialize("aat7gx1dhzrigeutpaqnwvzmoh9dbsebyv5auo2q", "aaj7pus7ozwodd61itsupfg04druv0npfmxrpcc8"); if(!(ionic.platform.isios() || ionic.platform.isandroid())){ window.fbasyncinit = function() { parse.facebookutils.init({ appid : '991974558512540', version : 'v2.3', xfbml : true }); }; (function(d, s, id){ var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) {return;} js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/sdk.js&

material design - ColorPrimaryDark theme android doesnt display in all Activities in android -

i hope can me. created style.xml in values-v21, put theme entire application, colorprimarydark works in main activity , other activities not working. <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:theme="@style/apptheme" .... .... </application> values-v21/styles.xml <style name="apptheme" parent="theme.appcompat.light.noactionbar"> <item name="colorprimary">@color/primary</item> <item name="colorprimarydark">@color/primarydark</item> <item name="coloraccent">@color/accent</item> <item name="android:windowdrawssystembarbackgrounds">true</item> <item name="android:statusbarcolor">@android:color/transparent</item> <item name="android:textcolorprimary">@android

c# - Binding in property node -

i'm trying binding this <local:tempusercontrol> <local:tempusercontrol.foo> <local:foo name2="{binding path=name, relativesource={relativesource ancestortype={x:type local:tempusercontrol}}}"/> </local:tempusercontrol.foo> </local:tempusercontrol> and getting error cannot find source binding reference 'relativesource findancestor, ancestortype='wpfapplication1.tempusercontrol', ancestorlevel='1''. bindingexpression:path=name; dataitem=null; target element 'foo' (name=''); target property 'name2' (type 'string') any idea please wrong? for work, foo object needs logical child of tempusercontrol . frameworkelement (and frameworkcontentelement ) provides 2 methods this: addlogicalchild , removelogicalchild . so, in tempusercontrol , register property-changed callback foo dependency property. callback can pass old , new value instance metho