Posts

Showing posts from May, 2014

graphics - Why the GPU works only in games -

i know don't have knowledge subject have questions can understand how graphics app work , please correct me cause i'm sure have mistakes. why normal ui app works without lags when comes drawing animation , other stuff , doesn't use gpu @ all. games using opengl , directx uses gpu draw objects. wondering if because 3d objects should rendered rendered 2d image before being displayed , guess gpu job. why can't cpu job instead? makes gpu better rendering components in 3d game? but why can't cpu job instead? makes gpu better rendering components in 3d game? the cpu can render 3d graphics. , there 3d games before gpus or other 3d graphics chips existed, did. what's thought seminal 3d game, quake, written cpus rendering. specialized hardware 3d rendering exists same reason there specialized hardware on cpu ieee-754 floating-point computations: can faster special hardware through emulated instructions. though there different reasons it. renderin...

java - Showing Confidence level for Alternatives -

i'm transcribing audio file speech api , shows confidence level top result. there field can add config json can see confidence levels of alternative results? below have config right now(in python) config = types.recognitionconfig( encoding=enums.recognitionconfig.audioencoding.flac, sample_rate_hertz=44100, language_code='en-us', speech_contexts=[speech.types.speechcontext( phrases=['low'] )])

C- Determining start of a Bit-field using a Union -

for example below, based on how bits.b.a set value of bits.byte, mean head of bit-field? know machine little-endian doesn't mean least significant bit or significant bit. there better way determine order of bit-field through coding? struct bit_fields { unsigned int a:4, b:8, c:20; } union myunion { bit_fields b; uint8_t byte; } int main(void) { union myunion bits; bits.byte=1; printf("%u, %u, %u\n", bits.b.a, bits.b.b, bits.b.c); return 0; } output: 1, (random int less 2^8), (random int less 2^20)

algorithm - Clustering nodes on a graph -

say have weighted, undirected graph x vertices. i'm looking separate these nodes clusters, based on weight of edge between each connected vertex (lower weight = closer together). i hoping use algorithm k means clustering achieve this, seems k means requires data in @ least 2d space, while have weights of each edge go from. is there way cluster nodes of weighted graph together? don't have preference whether need specify number of clusters or not. i suspect i'm missing relatively simple here, rather late. i've considered whether need traverse graph, , each node find y closest immediate neighbours, seems simple. edit: apologies: more specific: graph isn't large (around 150 vertices, maximum), , not complete. i'm using python.

nsautoreleasepool - How to use autopoolrelease in swift -

the use of autoreleasepool{} in swift follows. autoreleasepool { // usage here } but not know how use in public. example class viewcontroller: uiviewcontroller { autoreleasepool { var results: results<item>! } override func viewdidload() { super.viewdidload() ..... } } if public, error occurs. autoreleasepool{} need in func only?

multithreading - Doesn't executor service in java submits tasks parallelly? -

i playing java multithreading code. created executor service fixed thread pool. submitting 2 tasks sequentially. tried make first task long thread.sleep. thinking these 2 tasks run parallelly. however, when run program, programs waits sometime, prints b, means compiler finished first task @ first before going second task. actually, expecting, second task short task, complete before first task. explanation please? public static void main(string[] args) { executorservice executor = executors.newfixedthreadpool(10); map<string, string> map = new hashmap<>(); readwritelock lock = new reentrantreadwritelock(); executor.submit(() -> { lock.writelock().lock(); try { thread.sleep(10000); map.put("boo", "mar"); system.out.println("a"); } catch (interruptedexception e) { // todo auto-generated catch block e.printstacktrace(); } { ...

javascript - ES6 Import some functions as a object -

actions.js export const setx = () => {...} export const sety = () => {...} export const sett = () => {...} somecomponent.js import {setx, sety, sett} 'actions' export class somecomponent extends react.component { constructor(props,context) { super(props) this.state={ x, y, t } } componentwillmount() { let reduxstate = this.store.getstate() object.keys(this.state).foreach(n => { let fn = n + '-changed'; this[fn] = evt => { let update = {}; update[n] = evt.target.value; this.setstate(update); retrievedfunction = ****//how retrieve imported actions setx,sety , sett name**** this.store.dispatch(retrievedfunction(evt.target.value)) } this.state[n] = reduxstate[n] }); } will imported functions in global 'window'. not able find imported function access them name allimportedfunction['set'+n ](evt.targ...

python - How to find which shared libraries that a program linked to -

i have python script use opencv , other third party libraries. script needs shared library in folder /usr/local/lib run. there many files such libhogweed.a or libpgtypes.dylib in folder /usr/local/lib is there way can identify shared libraries script needs run?

double - C - erroneous output after multiplication of large numbers -

i'm implementing own decrease-and-conquer method a n . here's program: #include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> double dncpow(int a, int n) { double p = 1.0; if(n != 0) { p = dncpow(a, n / 2); p = p * p; if(n % 2) { p = p * (double)a; } } return p; } int main() { int a; int n; int a_upper = 10; int n_upper = 50; int times = 5; time_t t; srand(time(&t)); for(int = 0; < times; ++i) { = rand() % a_upper; n = rand() % n_upper; printf("a = %d, n = %d\n", a, n); printf("pow = %.0f\ndnc = %.0f\n\n", pow(a, n), dncpow(a, n)); } return 0; } my code works small values of , n, mismatch in output of pow() , dncpow() observed inputs such as: a = 7, n = 39 pow = 909543680129861204865300750663680 dnc = 909543680129861348980488826519552 i'm ...

How to Iterate every 5th index over numpy array -

i want learn basic logic in python . have 2 numpy array . want subtract every 5th index 1 array another. far have tried below code: x=np.arange(25,100).reshape(25,3) y=x[:,0] z=x[:,1] in range(0,25,5): # till these 2 loop looks fine print y[i] j in range(0,25,5): print z[j] # problems portion in range(0,25,5): j in range(0,25,5): print y[i]-z[j] -1 -16 -31 -46 -61 14 #output -1 -16 -31 -46 29 14 -1 -16 -31 44 29 14 -1 -16 59 44 29 14 -1 please suggest making mistake.why output above one? in advance ! you're missing simple beauty of numpy. >>> y - z array([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) to subtract every fifth position, use slice notation: >>> y[::5] - z[::5] array([-1, -1, -1, -1, -1]) anyway, you're iterating on pairs instead of pairs @ same position. way, use 1 loop: ...

python 3.x - Python3 - what are the meanings of brackets after a method -

looking @ last line of code, ["message"][0] part confuses me , i'm not sure means. able explain meaning of it? def do_post(self): length = int(self.headers.get('content-length', 0)) data = self.rfile.read(length).decode() message = parse_qs(data)["message"][0]

rxjs/Subscription undefined value of another subscription -

i need use value of subscription subscription. here code. product value undefined, best method access value? code: @component({ selector: 'product-page', templateurl: 'product-page.html' }) export class productpage { private product: product; this.store.select('products').subscribe(({ product }) => { if (product) { this.product = product; } }); this.store.select('plc').subscribe((value: any) = > { console.log(this.product); // undefined }) } you can combine 2 selections using combinelatest operator : import 'rxjs/add/operator/combinelatest'; // ... this.store .select('products') .combinelatest(this.store.select('plc')) .subscribe(([products, plc]) => { // ... });

javascript - call url from url id instead form -

i have code play google drive video. play when put url in browser form , click play. want remove form , directly play video when user visit url google drive file id. i want play video url below mydomain.com/index.php?id=0byard0r0qyatcmw2dvhqs0ndu0u but not able that. can me please. below php code http://i.imgur.com/0lu5rlv.png my index.php code https://pastebin.com/kugcghk7 <?php error_reporting(0); include "curl_gd.php"; if($_post['submit'] != ""){ $url = $_post['url']; $linkdown = drive($url); $file = '[{"type": "video/mp4", "label": "hd", "file": "'.$linkdown.'"}]'; } ?> <form action="" method="post"> <input type="text" size="80" name="url" value="https://drive.google.com/file/d/0byard0r0qyatcmw2dvhqs0ndu0u/view"/> <input type="s...

bash - How, in a Jenkins publish session, get past the error "rm: command not found"? -

i have a_version.jar , b_version.jar deployed server through jenkins publish on ssh. a_version.jar contains lib/b.jar need remove b.jar , replace symlink b_version.jar create symlink a_version.jar , place in root folder. here commands tried in execute command window, with a-version.jar deployed in /bin/dist/ ; symlink b-version.jar deployed in /bin/b/dist/b.jar : cd /bin/dist/ rm -rf temp mkdir temp cd temp cp /bin/dist/a-${version}.jar . export java_home=/usr/lib/jvm/jdk1.8.0_111 export path=$path:/usr/lib/jvm/jdk1.8.0_111/bin jar -xvf /bin/dist/a-${version}.jar cd lib rm -rf b.jar cp bin/b/dist/b.jar /bin/dist/temp/lib/ cd /bin/dist/temp/ jar -cvf a-${version}.jar cp a-${version}.jar /bin/dist/ ln -s /bin/dist/a-${version}.jar /root/a.jar exit at rm -rf b.jar step, rm command not found . , checked permission rw-r--r-- how can make work? in order debug this, try , display path in script echo windows path %path% echo linux path ${path} ...

django - Git Push Error ( Local to Remote ) in VPS Git Server? -

i've written small django site in mac(sierra os), , wanna put in new vps(digital ocean centos 7) . have created git server there. my local django project has local git repository,i set remote url centos git server site. , going well.. push project server … , finally, weird when push task has done, enter remote file, , found the ‘push task’ has push local .git file directory server .. and other project file ignored! later, added more commits, made no difference. i tried create new repo in github.com. , push project github in same way, it works in github platform --- of project files have sucessfully pushed github server. how solve problem? try reinstall vps , setup again git server. after setup new server try push ssh debug, example: git add * git commit -m "commit description" git_trace=1 git push origin master

computer science - How to construct this turing machine? -

how can construct tms such accepts(give description only): a + b = c a . b = c input of form a#b#c. a,b , c belongs {0,1}* , positive binary unsigned integers. i know can construct tms if input has unary representation how solve if has binary representation? well, binary addition , multiplication bit more involved in unary case, not difficult. addition: sum 2 lowest bits. if sum 0 or one, lowest bit of result. if sum two, lowest bit 0 , have carry. proceed next-lowest bit. sum 2 , possible carry.if sum 0 or one, current bit of result. if sum two, current bit 0 , have carry. if sum three, current bit 1 , have carry. repeat 2 until bits processed. for multiplication can use method this one . work program on tm if have in detail.

How to select a word from a string containing a specific character or symbol in PHP? -

i want usernames post , send them notification. the post may this. congratulations @user1 @user2 @user3 have won! i want select words above string contains @ symbol , store them elements of array can use them individually send notification them. i using following code gives on 1 user. how rest of them? <?php $post = "congratulations @user1 @user2 @user2 have won!"; if (strpos($post, "@")) { $fetch = explode("@", $post); $show = explode("\r\n", $fetch[1]); $users = count($show); foreach ($show $value) { echo "$value <br>"; } echo "<br>total $users users."; } ?> update: i tried users suggested @pharaoh <?php $post = "congratulations @user1 @user2 @user2 have won!"; if (strpos($post, "@")) { $matches = []; preg_match_all('/@(\w+)/', $post, $matches); $users = count($matches); $matches = array_values($matches); foreach ($matches $value) { echo ...

php - how to upload a laravel project on server for clients -

i have developed mvc project laravel 5.4. whenever want develop on localhost, use php artisan serve command access via localhost:8000 on browser. have uploaded project on linux server centos 6 , run php artisan serve --host 0.0.0.0 --port 8080 access via x.x.x.x:8080 on browser temporary way access project browser. permanent way access laravel project clients via public ip? i have apache,php , ... separately installed on server. can not see x.x.x.x/projectname/public or x.x.x.x/projectname. project in /var/www/html directory. you can access laravel project yoursite.com/projectname/public if upload project on web root. if want access directly yoursite.com need map public folder in virtual host configuration. # location of our projects public directory. documentroot /path/to/your/public

In Java Where does the PrintWriter write() method write the data -

import java.io.file; import java.io.printwriter; public class printwriterexample { public static void main(string[] args) throws exception { //data write on console using printwriter printwriter writer = new printwriter(system.out); writer.write("hello world"); system.out.write(65); system.out.write(' '); system.out.flush(); system.out.close(); // writer.flush(); //writer.close(); } } iam having trouble understanding write() method. description says writes specified byte stream. mean 'this stream'. written? kind of buffer?? mean pass system.out argument printwriter class constructor? in code data buffered? temporary memory created when use writer.write() , system.out.write()? when tried comment , uncomment flush , close methods randomly got results confused me.in particular instance why doesnt "hello world" printed on screen though have flushed , closed buffer. if buffers di...

How can I calculate the expression "A = D[2] – D[4] " in MIPS assembly language? -

i have been learning assembly language (mips) couple of weeks (so suppose new @ this) , have found myself being confused using arrays , right registers when try code in assembly language. at moment trying program this: a program supposed calculate , print out values of following expression: = d[2] – d[4] has "d" array 10 words , "a" array 1 word. this have coded far , don't know how calculate value of "x" here. hope question clear enough! please clarify in comments if not :) :) # variable in register $s1 # base address of array d in $s2 #allocating array .data .align 2 d: .word 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 .space 320 #main function .text .globl main main: addu $s7, $0, $ra #calculate value of #this value of supposed calculated. #first load number @ d[3] temporary reg...

database - MYSQL - Returning results with special characters while searching with non special characters -

i have videogame database table ocasionally has fields special characters, rÅŒblox. i need return results "rÅŒblox" querying select * videogames game "%roblox% . how can that? i have tried collation select * videogames game "%roblox% collate latin1_spanish_ci seems not working me.

Django models: Fields name clashes -

i facing error in 1 of django practice projects. following apps , respective models: project name: django03 app: home home/model.py from __future__ import unicode_literals django.db import models django.conf import settings # create models here. user = settings.auth_user_model home_type = ( ('1','1'), ('2','2'), ('3','3'), ) class home(models.model): home_owner = models.foreignkey(user,null=false, verbose_name='owner') hometype= models.charfield(max_length=100, null=false, default=1, choices=home_type, verbose_name='home type') licenseid= models.charfield(max_length=200, null=false, unique=true, verbose_name='license id') archive = models.booleanfield(default=false) def __str__(self): return self.licenseid app: furniture furniture/model.py # -*- coding: utf-8 -*- __future__ import unicode_literals django.conf import settings django.db import models # create mo...

javascript - send ajax to a django application from static html with CSRF -

i want submit form in html static page , send data django application, using jquery $.ajax function. how can add csrf token form accepted django? in form use {% csrf_token %} (in usual manner), , on ajax call , pass $(form).serialize() data. that's it.

C++ console application using double buffer size limitation -

# include "display.h" doublebuffer::doublebuffer() { coord size = { window_x_size , window_y_size }; small_rect rect; rect.left = 0; rect.right = window_x_size - 1; rect.top = 0; rect.bottom = window_y_size - 1; hbuffer[0] = createconsolescreenbuffer(generic_read | generic_write, 0, null, console_textmode_buffer, null); setconsolescreenbuffersize(hbuffer[0], size); setconsolewindowinfo(hbuffer[0], true, &rect); hbuffer[1] = createconsolescreenbuffer(generic_read | generic_write, 0, null, console_textmode_buffer, null); setconsolescreenbuffersize(hbuffer[1], size); setconsolewindowinfo(hbuffer[1], true, &rect); console_cursor_info cursorinfo; cursorinfo.dwsize = 1; cursorinfo.bvisible = false; setconsolecursorinfo(hbuffer[0], &cursorinfo); setconsolecursorinfo(hbuffer[1], &cursorinfo); nbufferindex = 0; } void doublebuffer::writebuffer(int x, int y, char *string) { dword dw;...

glsl - Bug in OpenGL? Identical float computation leads to different results -

the "minimial example" quite long unfortunately bug disappears if drop seamingly irrelevant code. here c++ code: #define _use_math_defines #include <iostream> #include <iomanip> #include <vector> #include <math.h> #include <time.h> #include <fstream> #include <sstream> //opengl includes #include <gl/glew.h> //opengl extension wrangler #include <gl/freeglut.h> //free opengl utility toolkit (includes gl.h , glu.h) void fpressenter(){ std::cout << "press enter exit."; std::cin.get(); } void fcompileshaderfromstring(const std::string& source, const gluint shaderid){ const char* code = source.c_str(); glshadersource(shaderid, 1, &code, null); glcompileshader(shaderid); int status; glgetshaderiv(shaderid, gl_compile_status, &status); if(status == gl_false){ int length = 0; glgetshaderiv(shaderid, gl_info_l...

javascript - Unexpected Identifier while coding in React -

i making 'markdown previewer' using reactjs. however, stuck @ code seems me fine. error of 'unexpected identifier ='. can't seem wrap head around why displays error. following code snippet .. class markdown extends react.component { static defaultprops = { text : 'this comes defaultprops !' }; static proptypes = { text : react.proptypes.string.isrequired, onchange : react.proptypes.func.isrequired; }; constructor(props) { super(props); this.handlechange = this.handlechange.bind(this); } handlechange(e) { this.props.onchange(e.target.value); } render() { const style = { width : '100%', fontsize : '18px', border : '1px solid grey', padding : '20px' }; return ( <textarea style={style} rows='20' placeholder='// enter text here ..' onc...

ios - How to move line? -

how move horizontal line in vertical direction? can draw straight horizontal line , need move using long press. how can that? override func touchesbegan(_ touches: set<uitouch>, event: uievent?) { if let touch = touches.first { let currentpoint = touch.location(in: self.view) drawline(frompoint: currentpoint, topoint: currentpoint) } } func drawline(frompoint: cgpoint, topoint: cgpoint) { uigraphicsbeginimagecontext(self.view.frame.size) imageview.image?.draw(in: cgrect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)) let context = uigraphicsgetcurrentcontext() let linewidth : cgfloat = 5 context?.move(to: cgpoint(x: frompoint.x, y: frompoint.y)) context?.addline(to: cgpoint(x: frompoint.x + 200, y: frompoint.y)) context?.setblendmode(cgblendmode.normal) context?.setlinecap(cglinecap.round) context?.setlinewidth(linewidth) context?.setstrokecolor(uicolor(red: 0, green: 0, blue: 0,...

html - Background img not showing up -

i trying make background header image responsive. need 100% of viewport height or image height, whichever smaller. an example header banner similar https://brittanychiang.com/v1/ the div size looks correct image don't seems showing up? created jsfiddle here : https://jsfiddle.net/pnnxm1yf/2/ header { height: 100vh; max-height: 850px; } #header-banner { color: #fff; background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)),url(https://unsplash.com/?photo=gzh1qxplxta) center center no-repeat; background-size: cover; position: relative; } <p>why image not showing up?</p> <header> <section id="header-banner"> </section> </header> <p>content after image</p> add height: 100% #header-banner . height 0 atm.

regex - whole word match in javascript -

i using javascript in webpage. trying search single whole word through textbox. search: 'me' , should find 'me' in text, not find 'memmm' per say. i using javascript's search('my regex expression') perform current search (with no success). thank you! edit: after several proposals use \b switches [which don't seem work] posting revised explanation of problem: amm, reason doesn't seemt tricks. assume following javascript search text: <script type='text/javascript'> var lookup = '\n\n\n\n\n\n2 pc games \n\n\n\n'; lookup = lookup.trim() ; alert(lookup ); var tttt = 'tttt'; alert((/\b(lookup)\b/g).test(2)); </script> moving lines essential to use dynamic regular expression see updated code: new regexp("\\b" + lookup + "\\b").test(textbox.value) your specific example backwards: alert((/\b(2)\b/g).test(lookup)); regexp...

csv - How to write out line of error for error exception (as well as actual error) in Python -

i running script fails lot on cron jobs. has issues encoding (utf etc) i'm trying sort , head around. i've made script writes errors out csv when crop up, fine, doesn't tell me line error happening on, struggling find out put .encode('utf-8') in sort out problem. can tell me if there's way add error writing function line of error too? the function use catch errors (for other bits of code too) follows... def error_output(error): t = datetime.now().strftime('%y-%m-%d %h:%m:%s') new_data = [t, error] f = open('outputs/errors.csv', 'a') csv.writer(f, lineterminator='\n').writerows([new_data]) f.close() ...and script uses thus: if condition: try: except exception e: error_output(e) ...this works nicely give me csv tells me things like: 2017-08-19 23:58:47 'ascii' codec can't encode character u'\u2019' in position 69: ordinal not in range(128) 2017-08-20 00...

docker - Logs not showing up in google cloud console when running cron jobs in GKE -

#assume have ubuntu, selenium , chrome driver in image add crontab /etc/cron.d/simple-cron # add crontab file in cron directory add crontab /etc/cron.d/simple-cron # add shell script , grant execution rights run wget myjava.jar [from central repository] run chmod +x /myjava.jar add script.sh /script.sh run chmod 777 /script.sh # give execution rights on cron job run chmod 0644 /etc/cron.d/simple-cron # create log file able run tail run touch /var/log/cron.log add run.sh /run.sh run chmod +x /run.sh cmd ["/run.sh"] crontab: * * * * * root /script.sh script.sh: export display=:99 cd / /usr/bin/java -jar myjava.jar run.sh: #!/bin/bash xvfb :99 -screen 0 1024x768x16 & cron -f i using above mentioned dockerfile, have cron job run every minute. don't see logs getting captured in google cloud console. i see similar post discusses similar problem. don't see solution. google container engine stdout logs not showing up i cannot move cron script ent...

database - Delphi: TDBGrid not update -

i had form has datasource,adoquery,adoconnection,dbgrid plus couple edit , memo . user enter username,street address, etc.. , hit 'save' button. on time application write details in comma separated txt file, connected access linked table. when user hit 'save' button write memo instantly not live update dbgrid database, when reopen app. i search lot has different suggestions: dbgrid refresh, adorequery, post, append, showmodal, open , close database etc. my question why dbgrid liveupdate doesn't work? sourcecode following: unit test; interface uses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, strutils, grids, buttons, pngimage, extctrls, comctrls, dbgrids, db, dbtables, colorgrd, diroutln, adodb, fmtbcd, sqlexpr, dbctrls, dbclient, jpeg; type tform1 = class(tform) memo1: tmemo; exit: tbutton; resetbtn: tbutton; label3: tlabel; groupbox1...

javascript - unable to display sum in footer using datatable -

i have created datatable using jquery. table has 7 columns , among 1 column grand total (column 6). have display sum of grand total (column 6) in grand total (column 6) @ bottom of grand total (column 6). how can that? have tried code nothing worked. outout blank column. here code found. below html code html <table class="display table table-bordered table-striped" id="dynamic-table"> <thead> <tr> <th>invoice type</th> <th>invoice no</th> <th>invoice date</th> <th>customer name</th> <th>city </th> <th>grand total</th> <th class="hidden-phone">action</th> </tr> </thead> <tbody> </tbody> <tfoot> <tr> <th></th> <th></th> <th></th> <th></th> <th>total:</th> ...

java - JVM invokeinterface without type information -

i'm generating code java asm5 , wondering, why can invoke interface method on parameter, declared of type java/lang/object. methodvisitor mv = cw.visitmethod(acc_public | acc_static, "test", "(ljava/lang/object;)v", null, null); mv.visitvarinsn(aload, 0); mv.visitinsn(dup); mv.visitmethodinsn(invokeinterface, "org/mydomain/foo", "foo", "()v", true); mv.visitmethodinsn(invokeinterface, "org/mydomain/bar", "bar", "()v", true); mv.visitinsn(return); mv.visitmaxs(-1,-1); mv.visitend(); generally have expected code require additional cast before invoking method ensure, object implements interface. safe call method without additional cast, long guarantee object implements interface or can run pitfalls? type checking of vm doesn't seem care it. if invoke object, doesn't implement interface java.lang.incompatibleclasschangeerror, not surprising. maybe have performance loss? you encounte...

selenium - How to download all images from webpage using Python? -

i have script open browser page desired webpage want download images page, how can given script: from selenium import webdriver import urllib class chromefoxtest: def __init__(self,url): self.url=url def chrometest(self): self.driver=webdriver.chrome() self.driver.get(self.url) self.r=self.driver.find_element_by_tag_name('img') self.uri=self.r.get_attribute("src") self.g=urllib.urlopen(self.uri) if __name__=='__main__': ft=chromefoxtest("http://www.google.com") ft.chrometest() from selenium import webdriver import urllib class chromefoxtest: def __init__(self,url): self.url=url self.uri = [] self.folder = '/home/palladin/imgs' def chrometest(self): self.driver=webdriver.chrome() self.driver.get(self.url) self.r=self.driver.find_elements_by_tag_name('img') v in self.r: src = v.get_...

google spreadsheet - Retrieve spreadsheetId from spreadsheetName using Java -

in following snippet : batchupdatevaluesrequest body = new batchupdatevaluesrequest() .setvalueinputoption("raw") .setdata(data); batchupdatevaluesresponse result = mservice.spreadsheets().values().batchupdate(spreadsheetid, body).execute(); i want fetch spreadsheetid spreadsheetname in java code. spreadsheetname name have saved google spreadsheet in google drive.

android - Control an LED through internet -

Image
i creating android app control led through internet. first built application using app inventor , it's working fine shown in video: https://www.youtube.com/watch?v=b-2cygm9qns&list=llog_1ypenk_yx8ypnprgpua&index=2 now trying build same application using android studio , facing problem, not getting exact output got app inventor here code button: public void on(view view) { intent led_on = new intent(intent.action_view,uri.parse("192.168.43.104/led=on")); startactivity(led_on); } created button should turn on led, it's going webpage how without going webpage done in app inventor? you don't want start activity when clicking on button, doing get request instead. update: it seems don't care response of request, can like: public void on(view view) { httpclient httpclient = new defaulthttpclient(); httpclient.execute(new httpget("192.168.43.104/led=on")); } make sure have internet perm...

ios - Alamofire HTTP Request -

i want send http post request alamofire. there code send request in sampleviewcontroller , response request. there problem got response server when want print response in sample view controller response return nil. how can check response after response server? public class persistencymanager { func sendposthttprequest(baseurl: string, parameter: [string:any?], content: string) -> any? { let url = url(string: constant.baseurl) var result : any? var urlrequest = urlrequest(url: url!) urlrequest.setvalue("text/html; charset=utf-8", forhttpheaderfield: "content-type") urlrequest.seturlencodedformdata(parameters: parameter) alamofire.request(urlrequest).responsejson { response in switch response.result { case .success : if let json = response.result.value as? [string:any] { print("json: \(json)") result = json ...