Posts

Showing posts from February, 2013

python - How to pass a module as an argument for struct in cython? -

i have no experience cython , started learning it. trying pass module argument to struct , don't know how? sample code tried in jupyter-notebook: %load_ext cython %%cython cdef class a: pass cdef struct person: int num object info cdef person p1.idd = 94113 p1.info = a() i appreciate me that. trying replace python dict lists in code self-designed structs because read here , it's not possible use nogil python dicts. if find way overcome problem in way code runs fast possible , highly appreciated. thanks. the things can go c definition - cdef describes - c types. something start, if want keep using structs: ctypedef struct info: char[256] address char[256] name <..> ctypedef struct person: int num info info cdef class person: cdef person my_struct for simplicity, , since aim defined class , use object in python anyway, can make cdef class , let cython generate structures you. cdef class person:...

c# - GET api controller generating errors when eager loading -

i'm trying setup api controller in .net core pass model json jquery datatable keep getting connection errors when try eager load related model. /api/projectscontroller.cs using system.collections.generic; using system.linq; using system.threading.tasks; using microsoft.aspnetcore.http; using microsoft.aspnetcore.mvc; using microsoft.entityframeworkcore; using projectlogic.models; namespace projectlogic.controllers.api { [produces("application/json")] [route("api/projects")] public class projectscontroller : controller { private readonly projectlogicdbcontext _context; public projectscontroller(projectlogicdbcontext context) { _context = context; } // get: api/projects [httpget] public async task<ienumerable<project>> getprojects() { var projects = await _context.projects //.include(p => p.pmemployee) .t...

ruby - Take a string, capitalize only words with more than three characters unless it is in the beginning -

when enter input, "war , peace", want, "war , peace". idea take string , make appear headline or movie title. capitalize words in string, unless word equal or less 3 , not in beginning. when run code: def titleize(string) string.split(" ").take(1).join.capitalize string.split(" ").map |x| x.capitalize! if x.length > 3 end.join(" ") end it returns " peace". try this: title = 'war , peace' def titleize(input) input.split(' ').map.with_index { |word, index| index == 0 || word.length > 3 ? word.capitalize : word }.join(' ') end titleize title => "war , peace"

struct - Error Packing and Unpacking bytes in Python -

my code has error(see below code) after enter in value. can pack bits unpacking doesn't work. suggestions? don't understand packing , unpacking , documentation bit confusing. import struct #binaryadder - def binaryadder(input): input = int(input) d = struct.pack("<i", input) print d print type(d) d = struct.unpack("<i",input) print d #test pack count = 0 while true: print "enter input" = raw_input() binaryadder(a) count = count + 1 print "while loop #%s finished\n" % count this code throws following error after enter in string: enter input 900 ä <type 'str'> traceback (most recent call last): file "c:\pythonpractice\binarygenerator.py", line 25, in <module> binaryadder(a) file "c:\pythonpractice\binarygenerator.py", line 17, in binaryadder d = struct.unpack("<i",input) struct.error: unpack requires string arg...

python - Split Sentance Into Even Lines (With full words) -

this question has answer here: split string pieces of max length x - split @ spaces 1 answer i using 16 x 2 character lcd. using show recent tweets. i need method returns list of strings display on display. for example input = "lorem ipsum dolor sit amet, consectetur adipiscing elit. donec aliquet lorem ac eros lobortis laoreet." it takes strings , splits list of strings 16 characters each. however, these strings must complete words not split word in two. so expected output ["lorem ipsum", "dolor sit amet,", "consectetur", "adipiscing elit.", "donec aliquet", "lorem ac eros", "lobortis", "laoreet."] each string not split words , strings no more 16 charcaters long. i can display on lcd fine need method can return list of strings meet criteria above i have seen other...

php - in laravel When run Logout route twice consecutively , i get csrf token mismatch error -

suppose user has opened 2 pages. in 1 of them, touches logout button. on other page, again, touch logout button. which error: (1/1) tokenmismatchexception in verifycsrftoken.php (line 68) @ verifycsrftoken-> handle (object (request), object (closure)) in pipeline.php (line 148) ...... . have solution? in app\exceptions\handler.php return user form new valid csrf token, page refreshed , logout button not exist. public function render($request, exception $exception) { if($exception instanceof tokenmismatchexception) { return redirect() ->back() ->with('your msg'); } return parent::render($request, $exception); } this looking like, page refreshed . don't replace post get . not safe , standard .

java - How do I run a Play Framework 2.1 project in IntelliJ? -

i have existing play 2.1 project. i've been running console , works fine. however, when try run intellij using these instructions doesn't work: https://www.jetbrains.com/help/idea/getting-started-with-play-2-x.html#run_debug_playapp first tried running right clicking on app , selecting "run play 2 app". not run , gave me error: sbt.incompatiblepluginsexception: binary incompatibility in plugins detected. after research issue added -djline.terminal= jvm options , tried again. time ran, gave error when tried open page in browser: global : unsupported major.minor version 52.0 finally, tried reimporting project intellij. before import, forced me update sbt version in build.properties 0.12.2 0.12.4. did this, still getting same errors listed above. note: have java 7 set jdk. here full stack trace: play.api.playexception: cannot init global object[global : unsupported major.minor version 52.0] @ play.api.withdefaultglobal$$anonfun$play$api$...

java - setconfig , setattribute and setheader cant be solved -

i'm developing anti theft application , connection http class. i have errors in couldn't solve ((cannot resolve setconfig , setattribute , setheader)) should resolve ? here code : package com.example.fatooma.location; /** * created fatooma on 26/07/2017. */ import java.io.bufferedreader; import java.io.inputstreamreader; import org.apache.http.httpresponse; import org.apache.http.httpstatus; import org.apache.http.httpversion; import org.apache.http.client.config.requestconfig; import org.apache.http.client.methods.httpget; import org.apache.http.client.protocol.httpclientcontext; import org.apache.http.impl.client.closeablehttpclient; import org.apache.http.impl.client.httpclients; import com.example.fatooma.location.core; public class httprmi { static string url = "http://localhost/projectserver"; closeablehttpclient httpclient = httpclients.createdefault(); // request configuration can overridden @ request level. // take precedence on 1 set @ ...

javascript - Execute PHP code on form submit without text input -

i want know if possible execute php post request ajax click on form submit button not have text input. have form <form action="connecting.php" id="connect" method="post" enctype="multipart/form-data"> <input type="submit" name="userconnect" id="userconnect" value="connect"> </form> and want execute block of php code on submit button connecting.php <?php require_once ("db.php"); $db = new mydb(); session_start(); if (isset($_post['userconnect'])) { $my_id = htmlspecialchars($_session['log_id'], ent_quotes, 'utf-8'); $user_id = (int) htmlspecialchars($_session['userid'], ent_quotes, 'utf-8'); $rand_num = rand(); $hsql =<<<eof select count(hash) count connect (user_one = '$my_id' , user_two = '$user_id') or (user_two = '$my_id' , user_one = '$u...

excel - Arrange columns based on the order of values in an array - and buttons disappearing -

i have code looking in column (on different sheet @ xfd1) , creating array values in column. searching values 1 @ time across row on current sheet. when finds match, cuts column , inserts @ location corresponds order of values in array. i'm not getting compile errors. placed button (not activex) on worksheet , used execute code. here see: nothing appears happen. columns not moved @ all. the computer "thinking " because whirly-gig spinning away. and here mysterious part - button disappears! never comes back. placed several buttons on worksheet , tried them all. button disappears every time. i need working. want reorder columns same order list on other sheet (95 items in list). thought code seem have entered twilight zone , things not seem (at least perspective)! here is: sub reorder_columns() dim arrcolumnorder(1 95) string dim index integer dim found range dim tick integer index = 1 95 arrcolumnorder(index...

bash - Parsing the GnuPG secret key list -

you can parseable list of secret keys in gnupg doing: gpg2 --list-secret-keys --with-colons the format of output described here: http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/details i want write bash function tells me if have both valid encryption , signing keys. based on above url, came with: has_valid_secret_keys() { return "$(gpg2 --list-secret-keys --with-colons 2>/dev/null | \ awk -f: 'begin { sign = 0; encrypt = 0; } ($1 ~ "sec|ssb") && ($2 ~ "[mfu]") { if ($12 ~ "s") sign++ if ($12 ~ "e") encrypt++ } end { print !(sign * encrypt) }')" } that is, awk script matches secret keys , secret subkeys (field 1) marginal, full or ultimate validity (field 2), maintains counter of signing , encryption keys based on matched records' capabilities (fi...

python 2.7 - percentage bins based on predefined buckets -

i have series of numbers , know % of numbers falling in every bucket of dataframe. df['cuts'] have 10, 20 , 50 values. specifically, % of series in [0-10], (10-20] , (20-50] bin , should appended df dataframe. i wrote following code. feel improvised. appreciated. bin_cuts = [-1] + list(df['cuts'].values) out = pd.cut(series, bins = bin_cuts) df_pct_bins = pd.value_counts(out, normalize= true).reset_index() df_pct_bins = pd.concat([df_pct_bins['index'].str.split(', ', expand = true), df_pct_bins['cuts']], axis = 1) df_pct_bins[1] = df_pct_bins[1].str[:-1].astype(str) df['cuts'] = df['cuts'].astype(str) df_pct_bins = pd.merge(df, df_pct_bins, left_on= 'cuts', right_on= 1) consider sample data df , s df = pd.dataframe(dict(cuts=[10, 20, 50])) s = pd.series(np.random.randint(50, size=1000)) option 1 np.searchsorted c = df.cuts.values df.assign( pct=df.cuts.map( pd.value_counts( ...

mysql - Returning value from Stored Procedure and using it in C# -

i have created function "recover(string useremail)" takes in user's email when he/she forgets login information. function runs stored procedure called "recover_password", return username , password can send email user. not familiar syntax creating simple stored procedure returns information. not familiar storing returned value in c# can make use of it. recover_password: create definer=`root`@`localhost` procedure `recover_password`(in email char(40)) begin select username,password userdata email=contactemail; end recover(string useremail): public actionresult recover(string useremail) { login model = new login(); mysqlconnection connect = dbconnection(); mysqlcommand cmd = new mysqlcommand("recover_password",connect); cmd.commandtype = commandtype.storedprocedure; cmd.parameters.addwithvalue("@email", useremail); mysqldatareader rd = cmd.executereader(); while (r...

javascript - How to get access to a background script variable from content script -

i'm creating extension own use, have problem. want assign value variable background.js content.js . variable background.js must exist despite refreshing of content page. how this? manifest.json { "manifest_version": 2, "name": "slownik", "version": "1.0", "description": "slownik", "background": { "scripts": ["background.js"] }, "content_scripts": [ { "matches": ["*://*.sjp.pl/*"], "js": ["content.js"] } ] } background.js : var test = "test"; content.js : test = "testa"; exactly desire not possible. background script(s) , content scripts execute in different contexts and, in cases, different processes. not possible directly share variable between 2 contexts. however, can share information. .storage.local exists able store information within exte...

p5.js - How do I make a random spawn outside a specific area -

i'm trying make basic little game there platform in middle of screen , there circles spawn randomly around area when touch food items in game snake. problem circle spawn inside platform in middle making impossible touch. i'm using random function x , y value in play area each time spawns it's given random location. there way make sure doesn't show in specific platform in middle? i'm doing in basic javascript in p5js function coin () { this.x = random (16, width-16); this.y = random (16, height-91); this.show = function() { ellipse (this.x, this.y, 32, 32); } } think how in head. try write out set of steps, in english (not in code) follow when come random number 2 ranges. how i'd this: flip coin decide side number should come from. now side chosen, use plain old random() function generate number range. for example, let's want choose number 1-30, don't want 11-19 options. here's how i'd that: ...

javascript - Sending multi dimensional query parameters via RequestOptionsArgs -

Image
i need send http request query strings resembling following: https://website.com/logs?filters[types][]=exception&filters[types][]=log in attempt this, i've written following code: getlogs(filters: any): observable<log[]> { const opts: requestoptionsargs = { params: filters }; return this.http.get('https://website.com/logs', opts) .map((res: response) => { return entitybuilder.buildmany<log>(log, res.json().data); }) .catch((error: any) => observable.throw(error)); } the filters object i'm passing in getlogs() has following structure: as can see, types property array of strings. when sending request however, angular producing url: https://website.com/logs?types=log&types=exception i'm not sure kind of object structure filters object needs in order produce query strings need. my other option of course use string building build query strings manually, i'd avoid if @ possible.

apache - Errors resulting from upgrading my CXF version from 2.7.7 to 3.1.8 -

pom.xml <cxf.core>3.1.8</cxf.core> <cxf.version>3.1.8</cxf.version> <jsr311.api.version>1.1.1</jsr311.api.version> <javax.ws.rs.api.version>2.0.1</javax.ws.rs.api.version> <dependency> <groupid>com.sun.xml.bind</groupid> <artifactid>jaxb-api</artifactid> <version>2.1.14</version> </dependency> <dependency> <groupid>com.sun.xml.bind</groupid> <artifactid>jaxb-impl</artifactid> <version>2.1.14</version> </dependency> <dependency> <groupid>com.sun.xml.bind</groupid> <artifactid>jaxb-core</artifactid> <version>2.1.14</version> </dependency> <dependency> <groupid>javax.ws.rs</groupid> <artifactid>javax.ws.rs-api</artifactid> ...

c++ - Image Magick slow drawing -

i trying draw bunch of lines on image using image magick library (magick++ api) , total execution time appears quite large. are there ways optimize imagick drawing performance? int size = 700, lines_num = 6000; image outputimage(geometry(size, size), color("white")); (int = 0; < lines_num; i++) { outputimage.draw(drawableline(lines[i].x1,lines[i].y1, lines[i].x2,lines[i].y2)); } try avoid repeat magick::image.draw calls. std::vector<magick::drawable> drawlist; (int = 0; < lines_num; i++) { drawlist.push_back(drawableline(lines[i].x1,lines[i].y1, lines[i].x2,lines[i].y2)); } outputimage.draw(drawlist); also ensure imagemagick libraries have been compiled openmp support. if going speed, , not quality, recommend recompiling without high dynamic range imagery --enable-hdri=no , , low quantum depth --with-quantum-depth=8 .

SQL query challenge - find top frequent items in columns and summarize result to a pivot table -

Image
i looking query following transformation. basically want find top 3 frequent sell_country , top 3 frequent category, on per website, per day bases. (for example, website 1, date 6-5-2017, there 2*us, 1*jp , 1*uk sell_country, therefore top1_sell_country us, , jp , uk going top2_sell_country , top3_sell_country. same idea category column) my current solution involves many subqueries, works, feel complicated. interested in how sql master in elegant way. currently know how uses from to i in 3 steps: group country , rank count group category , rank count blend results using conditional aggregate (which place values in necessary cells because result of case value , many null values, min() outputs value) like this: with countries ( select *, row_number() on (partition website,date order count desc) ( select website ,date::date ,sell_country ,count(1) your_table group 1,2,3 ) ) ,categories...

Is it possible to change tinyMCE custom Toolbar ListBox values after tinymce init -

following example add custom dropdown tinymce, possible change again after init tinymce? example, after init tinymce, update list again button different list. https://codepen.io/tinymce/pen/jywjvr tinymce.init({ selector: 'textarea', height: 500, toolbar: 'mybutton', menubar: false, content_css: [ '//fonts.googleapis.com/css?family=lato:300,300i,400,400i', '//www.tinymce.com/css/codepen.min.css'], setup: function (editor) { editor.addbutton('mybutton', { type: 'listbox', text: 'my listbox', icon: false, onselect: function (e) { editor.insertcontent(this.value()); }, values: [ { text: 'menu item 1', value: '&nbsp;<strong>some bold text!</strong>' }, { text: 'menu item 2', value: '&nbsp;<em>some italic text!</em>' }, { text: 'menu item 3', value: '&nb...

multithreading - Java HttpClient 4.5.2: the thread hangs after the logger outputs "Starting handshake" -

i create spider using java , chose httpclient4.5.2 deal http request. multithreading. when running 1 of thread hangs after few minutes , last log "debug:starting handshake". hangs no error output. it needs execute lots of httprequset. not sure if connection not close correctly or maybe stack overflow. the following httpclient part of code. public static string get(string url,string proxyhost,string proxyport) throws ioexception { httpclientbuilder httpclientbuilder = httpclientbuilder.create(); //httpclient closeablehttpclient closeablehttpclient = httpclientbuilder.build(); httpget httpget = new httpget(url); requestconfig requestconfig = null; httpget.setheader("accept", "accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); httpget.setheader("accept-charset", "gb2312,utf-8;q=0.7,*;q=0.7"); httpget.setheader("accept-encoding", "gzip, defla...

css - Buttons overlay in xs viewport because not auto resize -

i have 1 line (div tag class col-xs-6 ) 2 columns of same width. inside each column, there 1 auto-resizing button max width 150px depends on length of text inside. input long text inside buttons got same max width, 150px. auto resize window xs viewport, until 1 size (i think width of window smaller 300px plus padding) buttons overlay on each other. input[type="submit"] { position: relative; min-height: 34px; margin: 0 auto; min-width: 80px; max-width: 150px; padding: 0 10px; width: auto; display: block; border-radius: 5px; background-color: #ff7900; color: white; border: 1px solid #ff7900; } .nf-filler-control input[type="submit"] { display: inline-block !important; } .nf-button { display: inline-block; position: relative; color: white; } <!-- latest compiled , minified css --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.cs...

liquibase formatted sql file containing multiline rollback statements to allow Oracle PL/SQL -

i using liquibase version 3.5.3, writing "formatted sql" files need execute pl/sql (to our oracle 11g database). the changeset uses "enddelimiter:/" option allow this. --liquibase formatted sql --changeset mike:51.9 enddelimiter:/ /* -- 'create/modify triggers fin_plans' -- */ begin hist_pkg.trig_hist_tab('fin_plans'); end; / the rollback changeset needs execute pl/sql, despite numerous searches can not find way this. have tried specifying multiple rollback statements, each rollback line executed individually (as in "sql statements") , don't know how make recognise pl/sql "block". i've tried enddelimitor option on rollback not recognised. i've tried assuming enddelimitor option changeset applies rollback, alas no. what want ... --liquibase formatted sql --changeset mike:51.9 enddelimiter:/ /* -- 'create/modify triggers fin_plans' -- */ begin hist_pkg.trig_hist_ta...

c - Why does this function not correctly multiply the values in the array by the given multiple? -

i'm trying write function in c takes pointer array , returns pointer values multiplied multiple. have: int* returnnpledarray(int *a, int n){ int = 0; for(i = 0; < size; i++){ *a++ *= n; } return a; } but when call it, in main way: int sample2[] = {-10,-8,-6,-4,-2,0,2,4,6,8}; returnnpledarray(sample2, 3); int d = 0; (d = 0; d < size; d++){ printf("%d\n", *sample2); } the entire array prints out first value in multiplied n. thought because in function, *a++ *= n; both dereferencing value @ spot in , incrementing pointer. how can work? you have following in loop: for (d = 0; d < size; d++){ printf("%d\n", *(sample2 + d)); } or for (d = 0; d < size; d++){ printf("%d\n", sample2[d]); }

assembly - How to use LDREX and MMU in bare metal for pi2-arm cortexA7 -

blockquote ----describe---- i'm trying run splash2 benchmark in pi2 bare metal. modify pthread library pi2. in implementation if mutex_lock(...), use instruction ldrex function fail. if use ldr replace ldrex function works in situation of single core. when comes multi-core, fail. ----question---- how make ldrex works? there should local/global monitor? i try open mmu , set pthread memory session shareable in bootcode. not sure if mmu works correctly. following test special memory mapping. result >before 0c000000 : 45515555 >after 0c000000 : 00000666 >_before 0a000000 : aaaaabaa >_after 0a000000 : 00000666 ---code--- bootcode.s _start_mmu: //------------------------------------------------------------------- // cortex-a7 mmu configuration // set translation table base //------------------------------------------------------------------- // cortex-a7 supports 2 translation tables // configure translation table base (ttb) control register cp...

internet explorer - What is msxml used for except ajax in javascript? -

as know, creating dom features of msxml used xml document response ajax requests internet explorer , version of msxml used can specified passing string of version name of msxml activexobject constructor, follows: var ajaxobject = new activexobject("msxml2.xmlhttp"); in view of web client(browser), ajax process ie thing uses msxml feature know, above. anywhere else msxml used web client except ajax??

javascript - Why during animation between two 'div' there is an empty space? -

can me remove white space in between them during animation? do need add 1 more div wrap both div one? i have chosen use position-top adjust div animations causing problem , please suggest me better method animation if any? <!doctype html> <html> <head> <style> #top { background: white; color: white; width: 300px; height: 300px; display: inline-block; overflow: hidden; } #first { background: blue; transition: 0.5s; height: 300px; position: relative; } #second { background: green; transition: 0.5s; height: 300px; position: relative; } </style> <script> var = true; var down = false; function animations() { if (up) { document.gete...

how to move a folder as subfolder within the same repository in github -

eg: parent->1.test 2. source want test folder move source, how move in github web app? can previous versions tracked after moving? just move folder inside source folder , if app under git version control, track move , before moving things tracked in previous commit. there nothing special need take care, move lots of folder while doing code-refactor , common scenario. let me know if need more information.

Common ways of creating interactive terminals in browser? -

apologies if vague question, if has experience this, curious-- how people creating interactive terminals in browser windows, such @ play-with-docker.com ? in looking @ html elements @ site, 'terminal' windows appear series of div tags, 1 each line, nothing super special there. there's virtual machine / container behind scenes that's supplying text displayed, how commands being forwarded these vms/containers, , responses returned, along when color-code responses might done in xterm or other shell?

javascript - Accordion within Accordion -

i trying embedded accordion within accordion it's not working, embedded accordion expand size of first expand accordion, need add space in order show content, appreciated! css button.accordion { background-color: #73560b; border: 2px solid #ffc600; border-radius: 0px 10px 0px 10px; box-shadow: 7px 7px 5px #cccccc; color: #fff; cursor: pointer; padding: 10px 15px 10px 15px; margin: 4px 0px 7px 0px; width: 100%; font-size: 18px; transition: 0.4s; outline: none; text-align: left; } button.accordion.active, button.accordion:hover { background-color: #926c0e; } button.accordion:after { content: '\002b'; color: #ffc600; font-weight: bold; float: right; } button.accordion.active:after { content: "\2212"; } div.panel { padding: 0 18px; background-color: white; max-height: 0; overflow: hidden; transition: max-height 0.2s ease-out; } html <button class="accordion">background</button> <div class="panel"> content <button...

actionscript 3 - Load swf on loaded swf? -

i'm on project created in flash builder 4.7 , flash professional cs6, nice. need project load's swf inside "preloaded swf", the first swf, loads second swf, this second swf "home" of project. at point, work's perfectly. when "home" try load other external swf, says : [ioerrorevent type="ioerror" bubbles=false cancelable=false eventphase=2 text="error #2124"] the code of first swf: public class initialswf extends movieclip { private var _loader_:loader; private var _applicationcontent_:displayobject; private var _loadercontent_:movieclip; private var _loadericon_:movieclip; public function initialswf() { super(); _loader_ = new loader(); _loader_.contentloaderinfo.addeventlistener(event.complete,_oncomplete_,false,0,true); _loader_.contentloaderinfo.addeventlistener(ioerrorevent.io_error,_onioerror_,false,0,true); _loader_.contentloaderinfo.addeventlistener(progre...

haskell - simple example of monad that takes integers -

i writing monad composes functions, f , g, based on explanation of monads ( https://www.youtube.com/watch?v=zhuhctr3xq8 ). explanation stops @ crucial part: compose function (say f) a -> ma (say g) a -> ma , need way convert ma a , take stuff out of monad container (otherwise how feed output of f g??) , not addressed. assume have f , g map integer , return maybe: f :: int -> maybe int f = \x -> (just x) g :: int -> maybe int g = \x -> (just x) i want make monad allows me compose f , g, (g o f)(x) (meaning f(g(x)) ) can evaluated. work need way convert maybe int (the output of f) int can sent g. when maybe container has value in it, pull out value. when g's output nothing, can consider value 0 (i know g's output can't nothing g above lets assume f). this failed attempt define monad mymonad this: f :: int -> maybe int f = \x -> (just x) g :: int -> maybe int g = \x -> (just x) data mymonad = maybe instance monad mymonad ...

Python-Function object creation -

as understand book function in python nothing object of function class. have doubts below: 1.when object gets created? @ time define function or @ time call function? 2.if getting created @ time define function, not waste of memory if not call function anywhere in program ? looking detail answer. as define function or method (which nothing bound function), python creates function instance. happens when code run first time. yes, "waste" of memory, consider how memory compared big arrays, binary files etc. python not performant or resource-light language/interpreter, saves lots of time on writing code (because write less) , caring optimisation (you don't). mean seriously, few kb in file size matter nowadays? surely loss in value less minute of attention. the reason unused functions can't optimised away might used later on in same script or other scripts.

How to change placeholder text in an autocomplete activity of android google place? -

Image
i using option 2: use intent launch autocomplete activity is possible change "search" place holder text such "enter city". found a solution javascript, suppose support android well. it seems done a placeautocompletefragment , using own edittext launch autocomplete using intent, not helpful. no there no way , if want have create own. u use edittext(mention in comment section) may technique useful your. code: placeautocompletefragment autocompletefragment; autocompletefragment = (placeautocompletefragment) getfragmentmanager().findfragmentbyid(r.id.place_autocomplete_fragment); autocompletefragment.setonplaceselectedlistener(this); autocompletefragment.sethint("search new location"); xml : <linearlayout android:layout_width="match_parent" android:layout_height="@dimen/left_drawable_padding" android:layout_margintop="@dimen/margin_five" android:layout_marginleft="@dimen/marg...

c# - Cancelling background worker tasks -

this question has answer here: cancel backgroundworker 2 answers cancelling background tasks 5 answers how cancel working backgroundworker? 1 answer i have background worker performs time consuming task, i'm having trouble cancelling issue because can manage flag cancellation , not terminate process. in order solve it, tried put check points in heavy function want exit , seems not quite efficient. code looks : in points in heavy function put 2 lines : if (general.backgroundworker1.cancellationpending) { return; } private void button4_click(object sender, eventargs e) //button invokes heavy function { if (!backgroundworker1.isbusy) backgroundworker1.runworkerasync...

javascript - XMLHttpRequest cannot load https://www.[website].com/ -

i have grunt process initiates instance of express.js server. working absolutely fine until when started serving blank page following appearing in error log in developer's console in chrome (latest version): xmlhttprequest cannot load https://www.[website].com/ no 'access-control-allow-origin' header present on requested resource. origin ' http://localhost:4300 ' therefore not allowed access. what stopping me accessing page? about same origin policy this same origin policy . security feature implemented browsers. your particular case showing how implemented xmlhttprequest (and you'll identical results if use fetch), applies other things (such images loaded onto <canvas> or documents loaded <iframe> ), different implementations. the standard scenario demonstrates need sop can demonstrated three characters : alice person web browser bob runs website ( https://www.[website].com/ in example) mallory runs we...