Posts

php - Quickest most efficient way to run a loop to find and verify over 1 million usernames off a different website? -

using php current script work it's going take extremely long time since there on 1 million usernames verify. this checks against external websites api , returns <span class="user">{userid}</span> if it's valid username , returns <span class="user">0</span> if it's not. $query = $db->query('select id, username users_to_verify'); // on 1 million. foreach($query $row) { $userid = $row['id']; $username = $row['username']; if(!preg_match("/<span class=\"user\">0<\/span>/", file_get_contents("http://website.net/api.php?username=".$username))) $db->query('update users_to_verify set verified = 1 id = $userid'); } } is quickest way this? i've dabbled curl both file_get_contents , curl seem have same performance, know of dependent on external websites response time, want make sure side using quickest , ...

ios - How to find view controller of screen -

i have seen following code allows screen orientation of device: if(uiinterfaceorientationisportrait(viewcontroller.interfaceorientation)) { //do portrait work } else if(uiinterfaceorientationislandscape(viewcontroller.interfaceorientation)){ //do landscape work } the problem not sure substitute "viewcontroller" placeholder code. worth noting making keyboard app not sure if can use same view controllers might work other circumstances. controller can use tell orientation of screen? you can in 2 ways. uiinterfaceorientation orientation = [[uiapplication sharedapplication] statusbarorientation]; if (orientation == uiinterfaceorientationportrait || orientation == uiinterfaceorientationportraitupsidedown) { //portrait } if (orientation == uiinterfaceorientationlandscaperight || orientation == uiinterfaceorientationlandscapeleft) { //landscape } or if (uideviceorientationislandscape([uidevice currentdevice].orientation)) { //l...

java - Camel Spring JavaConfig Maven-Camel-Plugin without any xml -

how can setup camel projects rely on spring dependency injection system while being xml free using maven camel run plugin. have tried ton of configurations, still seem stuck "shell context" file imports java configuration file. there anyway rid of this? note: on latest camel version of 2.17.1 camel route @component public class testroute extends springroutebuilder { @override public void configure() throws exception { from("timer://foo?repeatcount=1") .log("hello world"); } } java config @configuration @componentscan("com.mcf.xml.free.route") public class routejavaconfig extends camelconfiguration { } maven camel plugin <plugin> <groupid>org.apache.camel</groupid> <artifactid>camel-maven-plugin</artifactid> <version>${camel.version}</version> <configuration> ...

Making cells bold in a table using python-docx -

the code snippet below creates table required number of rows , columns in new word document i.e 2 columns , 14 rows. adds content rows , columns accordingly. from docx import document newdoc=document() newdoc.add_heading ('gis request form') newdoc.add_paragraph() #inserting table , header , value objects table table=newdoc.add_table(rows=14,cols=2) table.style='table grid' table.autofit=false table.columns[0].width=2500000 table.columns[1].width=3500000 #inserting contents table cells in range(0,14): row=table.rows[i] row.cells[0].text=reqdheaderlist[i] row.cells[1].text=reqdvaluelist[i] i have been trying make contents of in column 1 bold, not working. #inserting contents table cells in range(0,14): row=table.rows[i] row.cells[0].text=reqdheaderlist[i] row.cells[0].paragraphs[0].add_run(line[0]).bold=true row.cells[1].text=reqdvaluelist[i] help? you can achieve using following loop: bolding_columns = [0...

dojo - Modify dijit.editor filters to allow tags -

i new dojo , trying use dijit.editor. i able create editor , adding html editor whenever pushes button. example, <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>title</title> <script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js" data-dojo-config="async: true,parseonload: true"></script> <style type="text/css"> /* bring in claro theme */ @import "//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css"; </style> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mtjoasx8j1au+a5wdvnpi2lkffwweaa8hdddjzlplegxhjvme1fgjwpgmkzs7" crossorigin="anonymous"> <script> function ondrag(event) { event.datatransfer.setdata('text'...

How to compile/eval a Scala expression at runtime? -

new scala , looking pointers idiomatic solution, if there one. i'd have arbitrary user-supplied scala functions (which allowed reference functions/classes have defined in code) applied data. for example: have foo(s: string): string , bar(s: string): string functions defined in myprog.scala . user runs program this: $ scala myprog data.txt --func='(s: str) => foo(bar(s)).reverse' this run line line through data file , emit result of applying user-specified function line. for points, can ensure there no side-effects in user-defined function? if not, can restrict function use only restricted subset of functions (which can assure safe)? @kenjiyoshida has nice gist shows how eval scala code. note when using eval gist, not specifying return value result in runtime failure when scala defaults inferring nothing . scala> eval("println(\"hello\")") hello java.lang.classcastexception: scala.runtime.boxedunit cannot cast scala.r...

Use Python in C -

i need use features available in python program written in c. found several sources me one of them gives me command compile code: gcc -i/usr/include/python2.7 prog.c -lpython2.7 -o prog -wall && ./prog i had change gcc -i/usr/include/python3.4 prog.c -lpython3.4 -o prog -wall && ./prog but compiler returns: /usr/bin/ld: cannot find -lpython3.4 collect2: error: ld returned 1 exit status it's 1 of first times have used gcc don't understand when @ examples. have tried interface c , python using cython? the manual can found here: https://python.g-node.org/python-summerschool-2011/_media/materials/cython/cython-slides.pdf in section 4.10 talks briefly interfacing python , c. thoughts call c code cython, way have complete , direct access python features want use. here's more on interfacing external c code: http://cython-docs2.readthedocs.io/en/latest/src/userguide/external_c_code.html