Posts

Showing posts from August, 2014

android - Hiding/Showing ActionBar and BottomBar on content click -

i have been trying similar kindle app android https://play.google.com/store/apps/details?id=com.amazon.kindle when in reading activity if click content, actionbar , bottomsheet animated out of screen. if click again, animate inside screen. i not being able make work using getsupportactionbar().hide() maybe because using coordinatorlayout someone knows how it? advance try getsupportactionbar().hide() , getsupportactionbar().show() you can check actionbar state using getsupportactionbar().isshowing() method.

lambda - Java 8: Difference between method reference Bound Receiver and UnBound Receiver -

i trying use java 8 method references in code. there 4 typed of method references available. static method reference. instance method (bound receiver). instance method (unbound receiver). constructor reference. with static method reference , constructor reference have no problem, instance method (bound receiver) , instance method (unbound receiver) confused me. in bound receiver use object reference variable calling method like: objectref::instance method in unbound receiver use class name calling method like: classname::instance method. i have following question: what need different types of method references instance methods? what difference between bound , unbound receiver method references? where use bound receiver , use unbound receiver? i finding explanation of bound , unbound receiver java 8 language features books , still confused actual concept. the idea of unbound receiver such string::length you’re referring method object wi...

c - Trying to run MPI Matrix Multiplication Example -

i'm trying run code found online understand mpi better i'm thrown error when try compile following code. i returned following: $ mpicc -o mpimm mpimm.c mpimm.c: in function ‘main’: mpimm.c:10: error: storage size of ‘start’ isn’t known mpimm.c:10: error: storage size of ‘stop’ isn’t known here example code below #include "stdio.h" #include "mpi.h" #define n 500 /* number of rows , columns in matrix */ mpi_status status; double a[n][n],b[n][n],c[n][n]; //matrix used main(int argc, char **argv){ struct timeval start, stop; int numberoftasks, mtype, taskid, numberofworkers, source, destination, rows, averagerow, extra, offset,i,j,k; //first initialization mpi_init(&argc, &argv); mpi_comm_rank(mpi_comm_world, &taskid); mpi_comm_size(mpi_comm_world, &numberoftasks); numberofworkers = numberoftasks-1; //---------------------------- master ---------------------------...

jenkins-pipeline load scoping "method code too large" -

i'm setting pretty complex pipeline handle legacy builds. there 8 stages, , more on way - perhaps total of 12-15 stages. each stage pretty similar actions: - take list, , each item - create entry in map - allocates node, , executes set of bat scripts (yes, windows) , run list in parallel the current pipeline 1,000 lines long, , i'm getting "method large" error i'm in process of refactoring dsl separate load-able scripts. so far, good. ran test indicates loading script additive overall pipeline. i'd learn best here. test: base.groovy: def myvar //wchi global (to basref, thought) def settest() { myvar='abc' } def gettest() { return myvar } pipeline.groovy stage('one') { def basref = load('base.groovy') basref.settest() echo basref.gettest() } stage('two') { def basref = load('base.groovy') echo basref.gettest() } stage 1 shows "abc" expected. stage 2 sho...

javascript - Ajax jQuery MySql Delete field -

i have fields of phone numbers pulled database through ajax , i'm trying add delete button next info here have far seems should working not. i'm using bootstrap. html code: <input type="hidden" value="<?php echo _e($_session['id']); ?>" id="userid"> <div class="row"> <div class="col-md-4"> <p>',_e($r->label),'</p> </div> <div class="col-md-6"> <p>',_e($r->phone),'</p> </div> <div class="col-md-2"> <a class="delphone" rel="',_e($r->id),'" href="#"> delete number </a> </div> </div> ajax code $('.delphone').on('click', function() { $id = $('#userid').val(); $.ajax({ type: 'post', url: "functions.php", ...

javascript - Adding multiple custom markers on Google Maps API after returning back from backend -

i have add multiple markers on google maps api after data gets returned backend sql table. here code. <%@ page language="c#" autoeventwireup="true" codefile="publicmapnew.aspx.cs" inherits="webcontent_applicatorareas" %> <head runat="server"> <title>geolocation</title> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="utf-8"> <style> html, body { height: 100%; margin: 0; padding: 0; } #map { height: 70%; } </style> <style type="text/css"> #map_canvas { width: 400px; height: 300px; } .contextmenu { visibi...

c++: Any way to avoid typing the class name before every member function? -

this question has answer here: is possible avoid repeating class name in implementation file? 7 answers i started out programming 5 years ago in java, when moved on c++ 2 years ago, implementations of member functions rather irritating. foo::bar(){/*some stuff*/} foo::baz(){/*some other stuff*/} back kinda got used it, wondered if there way structure code avoid typing foo:: every function, perhaps like: foo::{ bar(){//some stuff} baz(){//some other stuff} } i've found after 2 years still have trouble reading own code because name of function isn't first thing in line. edit: since question duplicate, thought share 1 thing found clicking on links. definitively not possible @ moment, there proposal add standard. don't know if or when might added, if you're reading few years lead. no, there not (unless define member function co...

java - Show table modified by executeUpdate() -

i'm doing program user can queries hand , results showed in jtable, example: userquery= "delete cds nro_cd = 4;" and i'm using code if (statement.execute(userquery)){ resultset rs = statement.executequery(userquery); table.setmodel(dbutils.resultsettotablemodel(rs)); joptionpane.showmessagedialog(null, "consulta realizada"); rs.close(); } else { statement.executeupdate(userquery); joptionpane.showmessagedialog(null, "modificacion realizada"); } my problem when execute update don't resultset, there anyway select table updated? my problem when execute update dont resultset ... that correct. number of rows affected (i.e. deleted, in example) ... there anyway select table udpated? i assume asking if there way select find rows deleted / updated in previous statement. no there isn't. for start, if rows have been deleted, won't there queried. (obviously!) ...

javascript - Can't catch input ID when calling JS function from PHP -

i don't know why javascript can't catch input: mensaje: <input id="mensaje" type="text" name="mensaje" value="" style="width:30%;" placeholder="escribe un mensaje enviar...."/> is built when submit php detect , call js function: function clearfields() { var e = document.getelementbyid("mensaje"); e.value=''; } my form never reload page , can submit text without reloading. problem value of textbox kept. that's why i'm trying use javascript, clear textbox when submitted. i error in js console: (index):24 uncaught typeerror: cannot set property 'value' of null(…) full code: <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?fa...

python - Use .py or .pyc file when sharing/backing up? -

this answer tells me .pyc file gets created when .py file run, understand saves loading time when re-run. makes me wonder point of .py file after .pyc created. when backing code, or sharing it, don't want include redundant or extraneous files. filetype should focus on? side question: have 1 script calls another. after running them, called script got .pyc file written, master script calling did not. why be? if want run python script, really need .pyc bytecode generated source code. see here details on running .pyc file. warn of detials bit twisty. however recommend including source code , leaving out .pyc files generated automatically python interpreter. besides, if you, or person want revise/revisit source code @ later point, need .py files. furthermore, best practice include source code.

android - How to refresh / redraw GridView from OnSharedPreferenceChangeListener without data change? -

i have grid view inside fragment showing images (works fine). there preference set number of columns in grid view. ssharedpreferencechangelistener = new sharedpreferences.onsharedpreferencechangelistener() { @override public void onsharedpreferencechanged(sharedpreferences sharedpreferences, string key) { log.i(" onsharedprefchanged", "for preferences"); // if column number preference changed if (key.equals(mcontext.getstring(r.string.pref_columns_key))) { // read saved number of columns mcolumns = integer.parseint(sharedpreferences.getstring(key, mcontext.getstring(r.string.pref_columns_default))); log.i(" columns", mcolumns + ""); // set mgridview number of columns correspond setgridvie...

tensorflow - How bazel creates the third_party/py/numpy/numpy_include link? -

bazel version build label: 0.3.1-homebrew os: mac 10.12 during build of tensorflow end brokne link third_party/py/numpy/numpy_include pointing non-existed folder (i had removed numpy): > ls -l third_party/py/numpy/numpy_include third_party/py/numpy/numpy_include -> /library/python/2.7/site-packages/numpy-1.11.2-py2.7-macosx-10.12-intel.egg/numpy/core/include so had create correct link manually: ln -s /usr/local/lib/python2.7/site-packages/numpy/core/include third_party/py/numpy/numpy_include now build working again. however, want understand how bazel creates link , correct way update after new version of dependencies installed.

javascript - Implement d3 Click-to-zoom -

i'm new web stuff know stupid question... still can't figure out i'm doing wrong though. code on site here: http://bl.ocks.org/mbostock/2206590 seems if copy , paste html document , merely modify link us.json points full file path. however, code merely pulls blank page. inspection of page source code on demo ( http://bl.ocks.org/mbostock/raw/2206590/ )is exact same code provided on main page. missing implement this?? thanks!!! <!doctype html> <meta charset="utf-8"> <style> .background { fill: none; pointer-events: all; } #states { fill: #aaa; } #states .active { fill: orange; } #state-borders { fill: none; stroke: #fff; stroke-width: 1.5px; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; } </style> <body> <script src="//d3js.org/d3.v3.min.js"></script> <script src="//d3js.org/topojson.v1.min.js"></script>...

c# - Parsing into dictionary with regex as separator for splitting -

as said in title, think idea split this \d+?=.*?\d= not quite sure... idea how best parse string: 1=some dummy sentence 2=some other sentence 3=third sentence can in same line 4=forth sentence text shouldn't captured , spplitted and i'm hoping dictionary have number key, , string in value, example: 1, "some dummy sentence" 2, "some other sentence" 3, "third sentence can in same line" 4, "forth sentence" method parse text dictionary: public static dictionary<int, string> getvaluestodictionary(string text) { var pattern = @"(\d+)=(.*?)((?=\d=)|\n)"; //if spaces between digit , equal sign possible (\d+)\s*=\s*(.*?)((?=\d\s?=)|\n) var regex = new regex(pattern); var pairs = new dictionary<int, string>(); var matches = regex.matches(text); foreach (match match in matches) { var key = int.parse(match.groups[1].value); var value = match.groups[2].value; ...

How to Draw V Letter Shape Using Asterisk(*) in C++ -

i newbie in c++. want draw character v in c++ i did this. don't know how further required result. #include <iostream.h> using namespace std; int main() { int i, j; for() { for() { if(i == j) { cout << "*"; } else { cout << " "; } } cout<< endl; return 0; } int main() { std::cout << "* *\n" " * *\n" " * *\n" " **\n" }

sigma.js - Basic SigmaJS edgeLabel example does not work (does not show labels) with build -

i trying use edgelabel plugin https://github.com/jacomyal/sigma.js/tree/master/plugins/sigma.renderers.edgelabels here's file: <html> <head> <style type="text/css"> #container { max-width: 400px; height: 400px; margin: auto; } </style> </head> <body> <div id="container"></div> <script src="sigma.js"></script> <script src="sigma.parsers.json.js"></script> <script src="sigma.renderers.edgelabels/settings.js"></script> <script src="sigma.renderers.edgelabels/sigma.canvas.edges.labels.def.js"></script> <script src="sigma.renderers.edgelabels/sigma.canvas.edges.labels.curve.js"></script> <script src="sigma.renderers.edgelabels/sigma.canvas.edges.labels.curvedarrow.js"></script> <script> s = sigma.parsers.json('data.json', { container: 'contain...

php - Possible to break statement in foreach loop? -

Image
i have 2 tables ( user , user_group ). user table contains ------------+-------------+------------------+ | user_id | user_name | user_group(id) | ------------+-------------+------------------+ and user_group table contains +-----------------+-------------------+ | user_group_id | user_group_name | +-----------------+-------------------+ now try join them without using join query. solve problem have used double foreach() loop, no result returns. can't use break statement. how can desired result using loop? desired result be: +-----------+-------------+-------------------+ | user_id | user_name | user_group_name | +-----------+-------------+-------------------+ what have far: public function user_get_item() { $this->db->select('*'); $this->db->from('users'); $results=$this->db->get()->result_array(); $this->db->select('*'); $this->db->from('user_group'); $gr...

c# - Stopping player from spamming movement keys which causes glitches -

i wrote script player movement in c#. whenever player presses or d, moves him/her left or right 12 units , when player presses w or s, moves him/her or down 12 units. script works fine, if person starts spam of keys @ once, glitches out , player object not in line level anymore. want have script check if there movement happening before executing movement on keypress. here script: void update () { transform.translate(vector3.forward * forwardspeed * time.deltatime); if (input.getkeydown (keycode.a) && side > maxsideleft) { moveobjectto(this.transform, new vector3(this.transform.position.x - 12, this.transform.position.y, this.transform.position.z + 10), movementspeed); side -= 1; } else if (input.getkeydown (keycode.d) && side < maxsideright) { moveobjectto(this.transform, new vector3(this.transform.position.x + 12, this.transform.position.y, this.transform.position.z + 10), movementspeed); side += 1; } i...

Sending a JSON file to an iOS and Web App User -

i'm trying have node.js server send json produced running jar user on ios or in browser on web app. i'm using express , node.js aws, i'm not sure how send/receive json files server. var express = require('express'); var app = express(); var server = app.listen(80, function(){ console.log('server listening on port 80'); }); this starts server in aws port 80. how user send json file port (ip-address:80)? works fine given web interface user can directly upload files. and how server send file user? code runs jar , produces json export: var child = exec('java -jar java/executable.jar file', function (error, stdout, stderr){ // prints output console.log(stdout); if(error !== null){ // prints error console.log("error -> "+error); } }); module.exports = child;

Sorting algorithm for inconsistent (non-transitive) human preferences -

suppose have file one-liner (joke) on each line. want sort jokes how funny find them. first thought implement sorting algorithm (preferably 1 makes few comparisons possible) , having comparison algorithm take input; i'd sit there , choose of each pair of jokes presented me funnier. there's problem that. joke preference not total order. lacks transitivity. example, might think b funnier when presented them, , c funnier b, when presented , c somehow find funnier c. if “>” means “is funnier than,” means c > b , b > not imply c > a. sorting algorithms’ correctness depends on this. but still seems there should algorithm sorts list of jokes 1 @ top most preferred on other jokes, , 1 @ bottom least preferred on other jokes, if there individual exceptions. i don’t know how google this. there algorithm kind of preference sorting? answer here not applicable because forces user’s preference transitive. if represent decisions directed graph, each joke nod...

python - Reorder Multi-indexed dataframe columns based on reference -

i have multi-indexed dataframe names attached column levels. data table looks this: (df1) time tmc 111n1 111p2 111n3 111p4 date epoch 0 143 113 103 nan 1 183 nan nan nan 2 nan nan nan nan 3 143 nan nan nan i'd shuffle columns around match order specified rows index of reference dataframe (df2): a1 a2 a3 a4 a5 name 111n3 pa pl er 0.75543 35 111p4 pa pl er 0.09413 35 111n1 pa pl er 4.21557 35 111p2 pa pl er 1.31989 35 i.e. result should (df3): time tmc 111n3 111p4 111n1 111p2 date epoch 0 103 nan 143 113 1 nan nan 183 nan ...

c++ - Load gzip compressed nifti file -

i using template image processing library, found here , reading nifti files works great. problem is, nifti files gzip compressed. files example.nii.gz. idea use boost lib, found here , reading , uncompressing files , pass uncompressed file nifti reader. unfortunately sounds easier is. so here code reading gz file: using namespace std; ifstream file("example.nii.gz", ios_base::in | ios_base::binary); filtering_streambuf<input> in; in.push(gzip_decompressor()); in.push(file); boost::iostreams::copy(in, cout); and file reader nifti lib: copyright (c) 2010, fang-cheng yeh. rights reserved. std::auto_ptr<input_interface> input_stream; input_stream.reset(new input_interface); if (!input_stream->open(pfile_name)) { input_stream.reset(0); return false; } input_stream->read(&header,sizeof(header)); instead of opening file in file reader of nifti lib, use uncompressing code boost. how data filtering_streambuf (boost lib) input_stream (nifti lib)?...

ARM 7 Assembly memory areas are not initialized -

i trying write simple program using arm 7 assembly, cannot initialize memory region simple data. here example area reset, code, readwrite entry ldr r0, =sortarray ;load start address ldr r1, =sortarrayend ; load end address str r15, [r0] ldr r4, [r0] sub r2, r2, #1 ; r2 contains (length-1) mov r6, #0 ; r6 sum set 0 stop b stop ltorg area my_data, data, readwrite align sortarray dcd 1,5,20,32,13,66,3,5,23,64,112,66,22 sortarrayend end this doesn't loads data in memory, in debug mode sortarray in r0 register points 0x40000000 , sortarrayend points 0x40000034 , there no data memory map data in separate area but may have noticed there instruction storing data in memory str r15, [r0] , works data stored there. next example works can see placed data inside code area , made readwrite bad idea. in case can see data in memory. area reset, code, readwrite sortarray dcd 1,5,20,32,13,66,3,5,23,64,...

python - Scrapy return empty array -

i want use scrapy crawl. open firefox or chrome xpath or css selector copy address! , got it! return empty! try jquery in online site(inspect element) , in response.body . both of them same doesnt work! fir example, page crawl this , addresses are: in inspect element: { firefox css: html body table tbody tr td div table tbody tr td center table tbody tr td table tbody tr td table.borderact tbody tr td h1 firefox xpath: /html/body/table/tbody/tr/td/div/table[1]/tbody/tr/td[3]/center/table/tbody/tr/td[3]/table[1]/tbody/tr/td[2]/table/tbody/tr[1]/td/h1 chrome css: body > table > tbody > tr > td > div > table:nth-child(3) > tbody > tr > td:nth-child(3) > center > table > tbody > tr > td:nth-child(3) > table:nth-child(1) > tbody > tr > td:nth-child(2) > table > tbody > tr:nth-child(1) > td > h1 in response: firefox css: html body table tbody tr td div table tbody tr td center table tbody tr td table tbody tr td...

machine learning - Counting number of label in MIT-BIH arrhythmia Database (MIT-BIH) -

Image
according paper https://www.researchgate.net/publication/293174514_deep_learning_approach_for_active_classification_of_electrocardiogram_signals number of beats of types n,s,f,v follow for training test mit-bih (ds1), use these records {101, 106, 108, 109, 112, 114, 115, 116, 118, 119, 122, 124, 201, 203, 205, 207, 208, 209, 215, 220, 223, 230}. however, when check using https://physionet.org/cgi-bin/atm/atm , choose describe record in toolbox , number not matching. record number 208 have 2 s label (while it's total 973 in ds1 according paper). total number of n label not matching (40589 instead of 45777). while f , v labels ok. here's meaning label: https://physionet.org/physiobank/annotations.shtml need n,s,f,v beats. can tell me what's problem or went wrong? found in pdf. way 15 labels combined n v s f , q.

linux - Text manipulation with bash -

i have bash variables defined in file: var1=.... var2="some value" var3=.... .... how can change value of variable , add 1 more variable in specific line? need in single shell script. edit: expected output is: var1=.... var2="another value" var3=.... new_var=.... .... i believe following code achieve results want, if understood question correctly: #!/bin/bash #change value of variable sed -i -e 's/^var2=.*$/var2="another-value"/gi' /folder/file #add new variable variable declaration area, using 1 existing variable reference point sed -i -e '/^var2=/i \new_var="another-value"' /folder/file exit 0 that substitute value of variable , add new variable list using 1 existing variable reference point insert new variable. code work in many bash versions.

ruby on rails - Rails4 Action Controller - undefined method 'length' for nil:NilClass -

i'm building messaging system scratch 1 of projects. working had following error: nomethoderror in messagescontroller#index followed undefined method 'length' nil:nilclass . couldn't find answer correspond case, unfortunately. i give conversations_controller.rb , messages_controller.rb , models , routes (and logs): conversations_controller.rb class conversationscontroller < applicationcontroller before_action :authenticate_user! def index @users = user.all @conversations = conversation.all end def create if conversation.between(params[:sender_id], params[:recipient_id]).present? @conversation = conversation.between(params[:sender_id], params[:recipient_id]).first else @conversation = conversation.create!(conversation_params) end redirect_to conversation_messages_path(@conversation) end private def conversation_params params.permit(:sender_id, :recipient_id) end end messages_controller.rb : cl...

parsing - How to parse date/time of the following format? -

i have time strings of following format november 05, 2016, 01:02:31 pm does 1 know how can parse them golang time ? https://golang.org/pkg/time/#parse time.parse(`january 02, 2006, 15:04:05 pm`, `november 05, 2016, 01:02:31 pm`) https://play.golang.org/p/lod5d-8i_u

node.js - Node js Cannot POST /usuarios -

i have these files , when try send data through form have cannot post /usuarios app.js var express = require("express"); var router=express.router(); var bodyparser = require("body-parser"); var aplicacion = express(); var path = require('path'); var index=require("./routes/index"); var usuarios=require("./routes/users"); aplicacion.set('views', path.join(__dirname, 'views')); aplicacion.set('view engine', 'ejs'); aplicacion.use(bodyparser.json()); aplicacion.use(router); aplicacion.use(index); aplicacion.use(usuarios); aplicacion.listen(5000, function() { console.log("servidor iniciado"); }); routes/users.js var express = require('express'); var router = express.router(); var usuariosmodel = require('../models/usuarios'); router.post('/usuarios', function(request, response) { usuariosmodel.getusuarios(function(error, data) { response.sta...

smartcard - Using javacard Shareable class to share an interface between two applet as client and server with different package? -

i want share interface between 2 applets client , server different package aid. saw link: [ 0x6f00 error casting javacard shareable interface in above link said: both client , server have in same package. have question now. possible client uses server functions if have different package aid? thank much. client , server don't have in same package! both need depend on same package, contains shared interface. in linked question, there problem interfaces: op declared 2 interfaces same name in 2 separate packages. why casting failed , 6f00 status thrown. how use shareable interface: 1.declare shared interface public in server-side package: package com.test.mypackage.a; public interface sharedobject extends shareable { public void foo(); } 2.use interface in client code: package com.test.mypackage.b; import com.test.mypackage.a.sharedobject; ... sharedobject obj = (sharedobject) jcsystem.getappletshareableinterfaceobject(svraid, (byte)0); use s...

node.js - not able to debug express app in node-inspector -

Image
i'm trying debug ejs app by: npm run debug folowing scripts package.json "scripts": { "start": "node ./bin/www", "debug": "node --debug ./bin/www" }, in node-inspector, getting following error:

How to merge two files in php while replacing the contents? -

i wanna know how merge 2 files in php such 1 final file generated , have both changes, example : style.css #mydiv{ background:white; color:black; } and style2.css #mydiv{ border:1px solid black; } and final.css #mydiv{ background:white; color:black; border:1px solid black; } so want final.css in output after merging style.css , style2.css ,, note : css file not point, example,, want kind of file merging files both versions. another example : file1.js var x=90; var y=50; var z=x+y; file2.js var z=x+y; var yx=500; and output.js var x=90; var y=50; var z=x+y; var yx=500; thanks!

c# - Replacing volatile with personal lock or Interlocked? -

curiosity killed cat, cannot resist... asking :-). there lot of advices floating around avoid volatile . wonder correct/sane replacement -- personal lock, i.e. have variable x wrap in setter/getter lock created it: private volatile bool x; // // replacement private readonly object x_lock = new object(); private bool __x; private bool x { { lock (x_lock) return __x; } ... or better use interlocked methods (for reading using no-op compareexchange ): private bool x { { return interlocked.compareexchange(ref __x,false,false); } ... i use bool type avoid discussion problems of compound operations, classic increment of int when have read , write value in 1 atomic step. volatile not such cases in first place, off-topic here. update : quote eric lippert blog "volatile fields sign doing downright crazy: you’re attempting read , write same value on 2 different threads without putting lock in place". started thinking (up don't see crazy flags). absen...

c# - How to join two lists and fill a datagridview -

Image
i have 2 list (1st values website, 2nd values .csv file) , i'd join them in list, starting 2 equals values, , display in datagridview. before post code, i'd tried fill datagridview these 2 lists separately , work. i didn't error, can't see datagridview values. i'm going post code , explain it. first list code: var url = textbox5.text; //var url = "http://www.betexplorer.com/soccer/norway/tippeligaen/results/"; var web = new htmlweb(); var doc = web.load(url); bets = new list<bet>(); // lettura delle righe var rows = doc.documentnode.selectnodes("//tr"); foreach (var row in rows) { if (!row.getattributevalue("class", "").contains("rtitle")) { if (string.isnullorempty(row.innertext)) continue; var rowbet = new bet(); foreach (var node in r...

JavaScript img.src onerror event - get reason of error -

Image
there can different reasons <img> load errors, such network error response, bad image data... error object received onerror doesn't seems specify exact reason. is there way know if error because of network error, http 500 or network timeout? edit: i'm not looking alternative way load resource, such ajax request. need answer <img> tag onerror event. reason i'm using method pixel-tracking , need way retry on upon network errors. i'm not looking alternative tracking methods such jsonp. edit 16nov16 2020gmt maybe pixel-tracking in emails or other clients limited in javascript capabilities. one idea comes mind use url query paramters in <img> 's src url. with regards network timeouts, pose idea user opens email, loads email entirely, disconnects internet , somehow not give tracker enough time load. https://developer.mozilla.org/en-us/docs/web/api/windowtimers/settimeout i suggest use settimeout() inside onerror f...

Finding the smallest integer in an array using a recursive function (Python) -

this question has answer here: python: recursive function find largest number in list 7 answers i have write function uses recursion in order determine smallest number in array. have no idea how approach this, since recursion not part of introductory course taking, want give exposure it. so far i've had following idea (but not rely on recursion, , have not made go through entire array): if numbers[0] <= numbers[1]: del numbers[1] else: del numbers[0] where numbers array, instance numbers=[2,1,3,4]. instance want function return 1 smallest integer in array. how go using recursive function solve this? ps: use python 3. you can use builtin function (min), if want iterate, can use cicle. variable "i" goes through array , gets each value in iteration. can use while cicles iterate not...

Javascript Repeating Append Textarea Values issue -

i have created form 4 textareas , submit button. reason of form, when press submit button append value (text) have insert in textareas inside div. when press submit button can see text have insert in 4 textareas when press submit button again append 4 textareas , on. what happen whenever press submit button show 4 textareas(with updated text) without appending 4 textareas. var firstcontent = document.getelementbyid("first-content"); var secondcontent = document.getelementbyid("second-content"); var thirdcontent = document.getelementbyid("third-content"); var fourthcontent = document.getelementbyid("fourth-content"); var customcontainer = document.getelementbyid("c-content"); var submitbtn = document.getelementbyid("c-btn"); function submitcustomform() { var celementone = document.createelement("p"); celementone.innerhtml = firstcontent.value; customcontainer.append(celementone); ...

javascript - how to add more than 1 picture into canvas -

hi i'n new programming , tried out html5 , wondering, how add more 1 picture canvas. tried making 2 canvas on top of each other, not work. after tried not use canvas put images right beside each other. thought putting code putting image canvas 2 times not seem work <!doctype html> <html> <body> <img src="mancala-game_bg_combined3.png" id=base usemap="canvas" img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble1 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble2 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble3 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble4 img style="display:none"> <img src="mancala-game_marble.png" id=pit1marble5 img style="display:none"> <img src="mancala-game_marble....

php - Enable server cache for a specific folder -

i codded php script consiste collect informations using (simple dom html) websites(from html). problem every time when launche script browses website selected , takes on 20 sec per launche. want set server cache specific foler contains script (htdocs/folder/sript.php). want set server cache execute script 1 per 5 minites example otherwise give last resaults. tried add lines .htaccess doesn't work. since php 5.4 should use php opcache : http://php.net/manual/fr/opcache.installation.php you can set blacklist caching : http://php.net/manual/fr/opcache.configuration.php#ini.opcache.blacklist-filename for php < 5.4 : you should use php apc cache : sudo apt-get install php-apc sudo /etc/init.d/apache2 restart after can use like apc.filters "[regex]" on php.ini file

security - Facebook Graph Api secure calls with Javascript -

i have web app fetching latest post public facebook page, , displaying post's background image. works localhosted, access_token displaying it's full glory in chrome developer tools. of course bad practice, , i'm looking ways securely request access_token server/external service. the point of app able fetch information facebook page without requesting user login client. of now, understand requires admin access_token in order fetch info, maybe i'm wrong here? there easier way fetch latest post info public facebook page? don't understand why facebook requires admin token fetch publicly available info? i don't understand why facebook requires admin token fetch publicly available info? facebook doesn't want anonymous requests api. that's why access token required. the point of app able fetch information facebook page without requesting user login client. you still need access token. said, it's not idea request on client since ...

for loop - How to iterate x times using Java 8 stream? -

this question has answer here: is possible use streams.intrange function? 3 answers i have old style for loop load tests: for (int = 0 ; < 1000 ; ++i) { if (i+1 % 100 == 0) { system.out.println("test number "+i+" started."); } // test itself... } how can use new java 8 stream api able without for ? also, use of stream make easy switch parallel stream. how switch parallel stream? * i'd keep reference i . intstream.range(0, 1000) /* .parallel() */ .filter(i -> i+1 % 100 == 0) .peek(i -> system.out.println("test number " + + " started.")) /* other operations on stream including terminal 1 */; if test running on each iteration regardless of condition (take filter out): intstream.range(0, 1000) .peek(i -> { if (i + 1 % 100 == 0...