Posts

Showing posts from February, 2014

c++ - Is it good habit to always initialize objects with {}? -

initializing objects new {} syntax this: int { 123 }; has benefit - not declare function instead of creating variable mistake. heard should habit that. see happen: // want create vector 5 ones in it: std::vector<int> vi{ 5, 1 }; // ups have vector 5 , 1. is habit then? there way avoid such problems? frankly, subtleties of various initialization techniques make difficult 1 practice "good habit." as mentioned in comment, scott meyers discusses brace-initialization @ length in modern effective c++ . has made further comments on matter on blog, instance here , here . in second post, says explicitly thinks morass of c++ initialization vagaries bad language design. as mentioned in 101010's answer, there benefits brace-initialization. prevention of implicit narrowing main benefit, in opinion. "most vexing parse" issue of course genuine benefit, it's paltry--it seems me in cases incorrect int a(); instead of int a; caught @ compile

sql - Fill Variable with Case Statement Results -

i have questionnaire users have filled out (several thousand day) the result each questionnaire record contains 70 fields (that correspond each question) i've been asked identify affirmatives each of 70 questions , concatentate them 1 field (a summary of issues identified record). in other languages (vba in particular) accomlish initializing variable '', looping through recordset , setting variable + field name of issue. i'm not sure how accomplish in sql. i've tried... declare @strfyi nvarchar set @strfyi = '' select a.record_num ,case when a.date_missing = 'yes' @strfyi = @strfyi + 'date_missing, ' when a.unclear_images = 'yes' @strfyi = @strfyi + 'unclear_images, ' when a.damage = 'yes' @strfyi = @strfyi + 'damage, ' else @strfyi end fyi_reasons questionaretable but doesn't work. i'll need trim last comma , space off list once it&

Numpy index array of unknown dimensions? -

i need compare bunch of numpy arrays different dimensions, say: a = np.array([1,2,3]) b = np.array([1,2,3],[4,5,6]) assert(a == b[0]) how can if not know either shape of , b, besides len(shape(a)) == len(shape(b)) - 1 and neither know dimension skip b. i'd use np.index_exp, not seem me ... def compare_arrays(a,b,skip_row): u = np.index_exp[ ... ] assert(a[:] == b[u]) edit or put otherwise, wan't construct slicing if know shape of array , dimension want miss. how dynamically create np.index_exp, if know number of dimensions , positions, put ":" , put "0". i looking @ code apply_along_axis , apply_over_axis , studying how construct indexing objects. lets make 4d array: in [355]: b=np.ones((2,3,4,3),int) make list of slices (using list * replicate) in [356]: ind=[slice(none)]*b.ndim in [357]: b[ind].shape # same b[:,:,:,:] out[357]: (2, 3, 4, 3) in [358]: ind[2]=2 # replace 1 slice index in [359]: b[ind].sha

webdriver io - Webdriverio -- Elements doesn't work -

i trying use elements array of elements, doesn't work here. any 1 can me that? lots. here code: <select name="test" id="select"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> now trying option elements: client.url('www.somesite.com') .elements('#select>option').then(function(res){ console.log(res.length); }) but got 'undefined' result 'res.length' . if use gettext can correct result: client.url('www.somesite.com') .gettext('#select>option').then(function(res){ console.log(res.length); }) you need access value property. console.log(res.value.length);

javascript - Previous Rows/Markers disappear once new rows/markers are created in Google Scatter Chart -

i creating google scatter chart. want dynamically update markers/rows. problem while being updated dynamically, each time new row created previous 1 disappears. want see new rows old ones. rows being dynamically updated combobox item selection. however, previous row disappears when new combobox item selected. want see row on chart. code is:: <script type="text/javascript"> var i=0; google.load("visualization", "1", {packages:["corechart"]}); google.setonloadcallback(drawchart); function drawchart() { var data = new google.visualization.datatable(); var struser=[0]; var struser2=[0]; if(i==0) { var struser=[0]; var struser2=[0]; } else { var a= document.getelementbyid("combo1"); struser[i] = parseint(a.options[a.selectedindex].value); var b= docume

Unexpected output in c++ code , Not getting expected result -

i made program show possible time in clock if angle given between hour , minute hand .. #include <iostream> #include <fstream> #include <string> #include <vector> #include <math.h> using namespace std; int main(){ //ifstream cin("input.txt"); vector <float> hour , min , angle; string str; int h , m ; float diff, cal1 ,cal2 , , j;; h = 11 ; m = 59; ( = 0 ; <= h ; i++ ){ ( j = 0 ; j <= m ; j = j + 1){ cal1 = (i*60/2) + (j/2); // hour angle cal2 = (j*6); // min angle; diff = fabs(cal1 - cal2) ; if ( diff > 180 ){ diff = 360.0000 - diff ; } //cout << cal1 << " " << cal2 << " " << diff << endl; hour.push_back(i); min.push_back(int(j)); angle.push_back(diff); } } int t , value , size; cin &

sql server - SQL Pivot with unbalanced data -

i'm deeling pivot function if possible "fill up" data not included in main table. table includes these data: create table tmpdata (objid int, colid varchar(5), value varchar(50)); insert tmpdata (objid, colid, value) values(21, 'col1', 'a value'); insert tmpdata (objid, colid, value) values(21, 'col2', 'col2_1'); insert tmpdata (objid, colid, value) values(21, 'col2', 'col2_2_x'); -- second 'value' col_2 insert tmpdata (objid, colid, value) values(21, 'col3', 'col3_1'); insert tmpdata (objid, colid, value) values(22, 'col1', 'another value'); insert tmpdata (objid, colid, value) values(22, 'col2', 'col2_2'); insert tmpdata (objid, colid, value) values(22, 'col3', 'col3_2'); with pivot function select * ( select objid , colid , value tmpdata) t pivot (max(value) colid in ([col1], [col2], [col3])) pivottable; i 1 (max) value objid=21 in col2

c# - Cannot deserialize the current JSON object to generic List type -

Image
question background: i'm using newtonsofts json.net desearlize xml response aws service c# object strcuture. the issue: i'm receiving following error message when trying deserialize on imageset class category property : cannot deserialize current json object (e.g. {"name":"value"}) type 'system.collections.generic.list`1[shoppingcomparisonengine.aws.awsrootlistpriceobject.imageset]' because type requires json array (e.g. [1,2,3]) deserialize correctly. fix error either change json json array (e.g. [1,2,3]) or change deserialized type normal .net type (e.g. not primitive type integer, not collection type array or list<t>) can deserialized json object. jsonobjectattribute can added type force deserialize json object. path 'items.item[1].imagesets.imageset.category', line 1, position 12122. i should add have no control on returned xml , in turn have no control on large object structure need deserialize response into. th

java - Drawable resource file - Changing Image -

long description: so want resting image different depending on circumstances. user gains (in case) currency, want check see whether has enough purchase. if has enough want button change colors visually tell user has enough buy upgrade. every time currency value changes call upon function. though life not perfect can't combine java code in xml , have no clue how call upon it. summary: my question is how change @drawable/button through mainactivity example of want happen: afunction(){ if(whatever){ <item android:drawable="@drawable/buttonclick" android:state_pressed="true"></item> <item android:drawable="@drawable/button"></item> } else <item android:drawable="@drawable/buttongray"></item> } in xml: <item android:drawable="@drawable/button"></item> <item android:drawable="@drawable/button

javascript - Call ajax function from <a> tag inside php file -

i'm trying call ajax call list of elements in php. well, php code: http://pastebin.com/apf6gtq6 when generate list, want click on links , send link ajax call perform request. ajax call: http://pastebin.com/mr8nmay2 but when click on link have got error of type: syntaxerror: unexpected token ':'. expected ')' end argument list. i have searched error can't find it. can me? thank replace onclick else part :- <a onclick='javascript: thecall(" . $flight[$i] . ");'>$i</a>

java - Check if a string is a Palindrome (using methods) -

i have no idea why following method not working. shows: palindrome.java:97: error: <identifier> expected the method takes parameter string , should return true or false if provided string palindrome. public static boolean checkpalindrome(checkstring) { boolean test = true; int left = 0; int right = checkstring.length() - 1; while (left < right && test) { if (checkstring.charat(left) != checkstring.charat(right)) { test = false; } right--; left++; } return test; } mistake in first line , should : public static boolean checkpalindrome(string checkstring) you have provide data type before parameter ^

python - How to render JSON on client-side from Google App Engine Entity -

i appreciate on rendering json object on client-side google app engine entity. here of relevant code: def render_str(template, **params): t = jinja_env.get_template(template) return t.render(params) class bloghandler(webapp2.requesthandler): def write(self, *a, **kw): self.response.out.write(*a, **kw) def render_str(self, template, **params): params['user'] = self.user return render_str(template, **params) def render(self, template, **kw): self.write(self.render_str(template, **kw)) class post(ndb.model): subject = ndb.textproperty(required = true) created = ndb.datetimeproperty(auto_now_add = true) startdate = ndb.datetimeproperty() enddate = ndb.datetimeproperty() class postpage(bloghandler): def get(self, post_id): key = ndb.key('post', int(post_id), parent=blog_key()) post = key.get() postdict = post.to_dict() postdict['startdate'] = postdict['startdate'].isoformat()

html - disable a menu item in Angular uib-dropdown -

in angular template i'm creating dropdown menu using angular-ui , need disable of list items based on property of "company" object defined in ng-repeat. i tried disabled tag or ng-disabled directive without success. how can achieve that? my current code: <div class="btn-group" uib-dropdown is-open="dropdown-open"> <button id="companydropdown" type="button" class="btn btn-default" uib-dropdown-toggle> {{companydescr}}<span class="caret"></span> </button> <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="companydropdown"> <li role="menuitem" ng-repeat="company in companycontracts"> <a ng-click="selectcontract(company)">{{company.address}}</a> </li> </ul> </div> any appreciated!

ios - dismissViewControllerAnimated called from a UIAlertController sends me to the RootViewController -

i've been trying dismiss alert view calling dismissviewcontrolleranimated unfortunately i'm not getting want since sends me rooviewcontroller ("usersswippingviewcontrollerusers"/"users") instead of staying in view controller presented (chatviewcontroller).. could please me out here. have attached screenshots of code i'm using call dismissviewcontrolleranimated , storyboard give rough idea of app looks like. view controller app taking me "usersswippingviewcontrollerusers"/"users" when should staying in/taking me chatviewcontroller. screenshots: this preview of app's storyboard here code i'm using dismissviewcontrolleranimated in handler of uialertaction don't use dismissviewcontrolleranimated method in uialertcontroller action. doing telling parent view controller instance dismissed (note why use self in closure!). , uialertcontroller have default approach dismissed automatically after button presse

c# - How can I allow a client to specify the fields they want returned from my api? -

i'd mimic popular apis , 1 of things see lot client query web api , specify fields return. instance, looking user's details have ton of info, or basic info. rather creating separate endpoints different levels of detail, i'd able allow client request information need. private api. so on server, i'd use users complete data (eagerly loaded or lazy loaded; hasn't been determined yet), once have object, i'd use fields specified in client's request build response object. is there library this? or popular techniques or articles helpful. tia this kind of involved process want loop objects returned if properties passed in , return dictionary of properties. created extension method doing it. using system; using system.collections; using system.collections.generic; using system.globalization; using system.linq; using system.reflection; using system.text; using system.threading.tasks; using newtonsoft.json.linq; namespace yournamespace.extensions {

asp.net - Attempting to create an Entity Framework model from a MySQL database fails with an unexpected exception -

Image
so, i'm trying set mysql , asp.net. currently, have both visual studio 2013 , visual studio 2015 installed on pc. used installer mysql (basically 1 comes need started, including mysql visual studio): mysql installer anyways, quick test made new asp.net mvc project, connected database in server browser (which works fine!). however, tried create ado.net model it. when come step of generating model database, error/exception: this happens in both visual studio 2013 and visual studio 2015. i have tried search way out of (i've tried different databases, used of sample databases included mysql server installed, still got same error), don't seem able find information on it. additionally, might worth noting when select version of entity framework use, this: which seems odd i'd think newest mysql installer did include mysql visual studio supports ef 6.x? anyways, assistance or hints on problem appreciated :) edit - narrowed down problem bit so, found out

java - How can I draw directional path and detect if traced - Android -

i working on application draws letters on canvas , detect if user traces letter in correct form. tried different techniques , can't seem find best approach cover letters. letters in comic sans font , due formations in f , s pretty difficult. it's lowercase letters there number of attempts answer needed answer posted here: path measure example this did accomplish task: get starting point of path then created separate path started @ point when user touch close start point (lets call trail path) finally went on calculate point of path ahead of user trail path , see if difference in touch , expected point close. here bit of code path measure pm = new pathmeasure(mypath, false); pm.getpostan(0, floatpoints, null); //this functions says whether offset path great accept private boolean ismajoroffset(float point1, float point2, int tolerance){ float difference = math.abs(point1 - point2); return tolerance < ma

ibm bluemix - Spark set_hadoop_config error -

does know causing error? looks basic. in: def set_hadoop_config(credentials): prefix = "fs.swift.service." + credentials['name'] hconf = sc._jsc.hadoopconfiguration() hconf.set(prefix + ".auth.url", credentials['auth_url']+'/v2.0/tokens') hconf.set(prefix + ".auth.endpoint.prefix", "endpoints") hconf.set(prefix + ".tenant", credentials['project_id']) hconf.set(prefix + ".username", credentials['user_id']) hconf.set(prefix + ".password", credentials['password']) hconf.setint(prefix + ".http.port", 8080) hconf.set(prefix + ".region", credentials['region']) out: name: compile error message: :1: error: ':' expected ')' found. def set_hadoop_config(credentials): ^ stacktrace: thanks! there 2 issues code. it python code snippet, executed within scala

mysql - create any table name with prepareStatement jdbc java -

this question has answer here: jdbc preparestatement doesn't work 4 answers so i'm trying create unspecified table name unspecified columns, however, i'm new preparestatement , i'm not sure do. how i'm thinking know i'll need loop multiple entries of "line" table name how can deal columns? think i'm specifying number of columns in here (4). how can without specifying? , should put setstring if value differ based on table name? i'm kind of confused , hoping explain me loop start .... line = kb.next(); sql = "create table " + line + "(?,?,?,?)"; pstmt = conn.preparestatement(sql); pstmt.setstring(1,?); pstmt.executeupdate(); loop end it's unlikely you'll able work on database. for oracle-specific reasoning, see why cannot use bind variables in ddl?

winapi - How to use SetConsoleTextAttribute C++ -

i have searched countless forums , websites can't seem find answer. i'm trying use setconsoletextattribute affects text. how can affect whole screen command color 1f would? code is: #include <iostream> #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <wincon.h> using namespace std; int main() { setconsoletitle("c++ calculator"); // title of window int x; // decision int a; // first number int b; // second number int c; // answer handle con; con = getstdhandle(std_output_handle); setconsoletextattribute(con, background_blue | foreground_blue | foreground_green | foreground_red); cout << "calculator" << endl << endl; cout << "1:addition" << endl << "2:subtraction" << endl << "3:multiplication"; cout << endl << "4:division" << endl << "5:exit&q

excel - Comparing, matching and combining columns of data -

i need matching data , combining it. have 4 columns of data in excel sheet, similar following: column: 1 2 3 4 u 3 0 w 6 b 0 r 1 c 0 t 9 d 0 ... ... ... ... column 2 data value corresponds letter in column one. need compare column 3 column 1 , whenever matches copy corresponding value column 2 column 4. you might ask why don't manually ? have spreadsheet around 100,000 rows isn't option! i have access matlab , have information imported, if more completed within environment, please let me know. as mentioned @bla: a formula similar =if(a1=c1,b1,0) should serve (excel).

c++ - Is it bad practice to implement a graph's nodes as a vector of pointers? -

i attempting implement graph in c++ each node instance of class a . first instinct represent collection of nodes in graph object vector of objects of type a . however, wanted implement following functionality well: suppose overload + operator when g_2 = g_0 + g_1 (where g 's instances of graph class), g_2 's nodes consist of combined nodes of g_0 , g_1 . if modify of nodes in g_2 , g_0 , g_1 's nodes remain unchanged , in sense g_2 no longer remain sum of g_0 , g_1 . however, if instead represent nodes in graph vector of pointers objects of type a , modifying g_2 modify g_0 , g_1 , , vice versa, desirable project working on. that being said, can't suspect having vector of pointers data member dangerous, don't know enough say. a vector of pointers fine. need take care of memory management of objects yourself, doable. you need allocate objects new a() , delete them delete pointer_to_a if want rid of them.

hadoop - HDFS compression at the block level -

one of big issues hdfs compression: if compress file, have deal splittable compression. why hdfs require compress entire file, , not instead implement compression @ hdfs block level? that solve problem: 64 mb block read or written in single chunk, it's big enough compress, , doesn't interefere operations or require splittable compression. are there implementations of this? i'm speculating here, can see several problems. hdfs contains feature called local short-circuit reads . allows datanode open block file, validate security, , pass on filedescriptor application running on same node. bypasses file transfer via http or other means hdfs m/r app (or whatever hdfs app reading file). on performant clusters short circuit reads norm, rather exception, processing occurs split located. describe require reader comprehend block compression in order read block. other considerations relate splits span blocks. compressed formats in general lack random access , req

android - Root LinearLayout does not allign center -

Image
the root code below: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/satranc" android:layout_width="fill_parent" android:layout_height="@dimen/boy" android:gravity="center_horizontal" android:orientation="vertical" tools:context=".mainactivity"> the root tag closed. can help? thank in advance well tried william's solution , did not work. following earlier comment used android:gravity="center_horizontal" in nested linearlayouts horizontal orientation , voila! worked. regards , thank contributors...

Method in Java that returns the first odd found in a range -

i need create method receives int n , tests integers between n*n+1 , (n+1)*(n+1)-1 , returns first odd number encounters. if no such number found between these bounds function return 0 . i'm trying figure out how while , don't it. i'm quite new java. can me? i thought in eclipse says me this method must return result of type int , didn't understand why. public static int test(int n){ // receives argument n int = n*n+1; // calculate lower bound int b = (n+1)*(n+1)-1; // calculate upper bound { (int = 1; <=a; i++){ if (a % == 0){ return a; } else if (a % != 0){ return 0; } } ++a; } while (a <= b); } to check whether number odd, use modulo: n % 2 == 0 if above condition evaluates true , number even. evaluate true if number odd: n % 2 != 0 i hope helps.

node.js - Cannot connect heroku to mongolabs database -

i new dev , have no idea doing in regards deploying app. locally, can run perfectly. have setup heroku account , mongolabs account. app.js file starts app, , have set in heroku , when heroku logs shows attemps start crashes when cant find mongodb. have code wrong, lost , don't know find answer. have been looking hours. username , password swapped below use correct credentials when trying send file. my app.js file is: var express = require('express'); var app = express(); var mongodb = require('mongodb'); var reddit = require('./routes/reddit'); var enter = require('./routes/enter'); var user = require('./routes/user'); var update = require('./routes/update'); var message = require('./routes/message'); var register = require('./routes/register'); var login = require('./routes/login'); var rate = require('./routes/rate'); var credentials = require ('./routes/request-credentials'); var uri

javascript - Prevent md-select dropdown opening under certain condition when clicked -

i have , trying stop md-select opening under condition , instead show warning dialog. i able disable md-select following ng-disabled="controller.unsavedchangesmade" but prefer avoid , instead allow user click on dropdown dialog showing up, , without md-select list of items opening up. if remove ng-disabled, dialog , dropdown list of items shows up. <md-input-container> <label>select item</label> <md-select ng-disabled="controller.unsavedchangesmade" ng-model = "selecteditem" ng-click="controller.handleitemchange(selecteditem.name, $event)" aria-label="selected item"> <md-option ng-repeat = "(index,item) in controller.items" ng-value = "item" ng-click = "controller.getitembycategory(item.name)"> {{item.name}} </md-option> </md-select> </md-input-container> i have looked using $event.st

java - Finish All Activities from BroadCast Receiver -

i want finish applications' activities broadcast receiver when screen off: first created static reference in activities below: public class mainactivity extends appcompatactivity implements navigationview.onnavigationitemselectedlistener { public static appcompatactivity ma; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //set instance of ma equals mainactivity ma=this; toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); floatingactionbutton fab = (floatingactionbutton) findviewbyid(r.id.fab); fab.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { snackbar.make(view, "replace own action", snackbar.length_long) .setaction("action", null).show(); } }); drawerlayout drawer = (drawerlayout) f

c# - Email attachment with long non-ascii name -

i try send system.net.mail.mailmessage system.net.mail.attachment . name of attachment "Счёт-договор №4321 от 4 июля.pdf" code attachment creation: var nameencoding = encoding.utf8; return new system.net.mail.attachment(new memorystream(bytes), messagebodieshelpers.encodeattachmentname(filename, nameencoding), attachment.mediatype) { transferencoding = transferencoding.base64, nameencoding = nameencoding }; code inside messagebodieshelpers.encodeattachmentname taken https://social.msdn.microsoft.com/forums/en-us/b6c764f7-4697-4394-b45f-128a24306d55/40-smtpclientsend-attachments-mit-umlauten-im-dateinamen?forum=dotnetframeworkde if send attachment gmail or ms exchange, name of attachment decoded successfully. but! if send attachment icloud "????-??????? №4321 от4 ????.pdf" mail attachment headers: from ms exchange: content-type:

Populate the selectbox dynamically using chosen.js - jquery -

i can change placeholder after page has loaded (shown below), $('#dropdown1').chosen(); $('#dropdown1').attr('data-placeholder', 'pizza , chips'); $('#dropdown1').trigger('chosen:updated'); but cant seem add values taken database. want them bee added straight text box, have been selected. should square , grey , can deselected if wished....??? the answer simple, took me while, thinking had via jquery when was adding 1 word "selected" in option! <select class="html-multi-chosen-select" multiple="multiple"> <option value="foo" selected>foo</option> <option value="bar" selected>bar</option> <option value="dog">dog</option> <option value="cat">cat</option> </select> fiddle here http://jsfiddle.net/mikeys4u/99dkm/235/

android - How to use SharedPreferences to store int that is incremented everytime the user clicks a button & retrieve value next time the app is launched -

im beginner android dev, , ive been working on pretty straightforward voting app school. basically i've created objects in multiple activities act int counters record votes(in form of clicks) various posts. have achieved , able view results counters in different activity. also, activity shifts new activity next position in voting system automatically. i realised lose data/votes objects(counters) if app killed or crashed. therefore, tried implementing shared preferences store , update count of votes when button clicked. however, app crashes when use code reassign shared preference variable counter objects value. i cannot seem understand , fix code counter resumes last value. below code: public class spl extends appcompatactivity { sharedpreferences retrieve = getapplicationcontext().getsharedpreferences("result", mode_private); public int spl1count = retrieve.getint("hb1", 0); public int spl2count = retrieve.getint("hb2", 0); @override

Nginx 301 redirect syntax error -

i found nginx syntax not correct: location /news { rewrite ^(.*)$ /blog redirect;} i want redirect mysite.com/news mysite.com/blog code redirecting more pages blog. anyone can me explaining error , tell me how correctly redirect? thanks the best practice still use location . if don't want below /news redirect /blog (e.g., no need wildcard), following want, , efficient way create single alias: location = /news { return 301 /blog; } otherwise, if do, in fact, want wildcard: location /news { rewrite ^/news(.*) /blog$1 permanent; } p.s. note redirect cause 302 redirects; if want 301 , keyword called permanent .

html - 6-6 pane with 6-3-3 underneath -

i need this: http://qs.lc/tdcw9 but looks this: http://qs.lc/z252x they aligned. know how 3-3 underneath "jouw nieuws" without getting aligned, on first screenshot? that work if choose go 2 column layout, second column having full width 1 column first row, followed 2 column second row. here rough example: <div class="container"> <div class="row"> <div class="col-md-6"> <div class="col-md-12"> lorem ipsum col 1-1 text </div> <div class="col-md-12"> lorem ipsum col 1-2 text </div> </div> <div class="col-md-6"> <div class="col-md-12"> lorem ipsum col 2 text </div> <div class="col-md-6"> sub col 1 </div> <div cl

javascript - window.scrollY not working -

i've been working on javascript website , made little test program. when check console, rather getting value of window.scrolly (y) "0" in console. use firefox, in case matter how. here code: var y = window.scrolly; console.log(y); print("foo"); window.onscroll=function(event){ console.log(y); } // used c#, made function - function print(word){ console.log(word); } i'm not sure i'm doing generate error, appreciate if got answer. you're calling print() before declared it. may source of error. try removing line see if error goes away.

html - parsing/escape in Swift -

currently have html string (here part of it) in swift want escape special part <tr style="color:white;background-color:#32b4fa;border-width:1px;border-style:solid;font-weight:normal;"> <th scope="col" style="border-color:black;font-family:verdana,geneva,arial,helvetica,sans-serif;font-size:x-small;width:25px;">&nbsp;</th><th scope="col" style="border-color:black;font-family:verdana,geneva,arial,helvetica,sans-serif;font-size:x-small;width:20px;">park-<br>stätte</th><th scope="col" style="border-color:black;font-family:verdana,geneva,arial,helvetica,sans-serif;font-size:x-small;width:25px;">parkmöglichkeit</th><th scope="col" style="border-color:black;font-family:verdana,geneva,arial,helvetica,sans-serif;font-size:x-small;width:25px;">anzahl stellplätze</th><th scope="col" style="border-color:black;font-fami

laravel - How to use PHP(5.5) extract EXIF(version 2.3) info from JPEG file -

i using php v5.5.30, in information page: exif exif support enabled exif version 1.4 $id:a0425de51ec3270d01522bf62d41bfe78893f78d $ supported exif version 0220 supported filetypes jpeg,tiff when use exit() function of ``(actually use php native function) retrieve exif info jpeg, give wrong results: "make" => "\x01" "model" => null "orientation" => 1 how can solve problem? there way can let php support exif v2.3 or 3rd party library? many thanks.

android - org.apache.http.httpResponce (Not a repost) -

first of let me tell im complete noob here. don't know programming . wanted compile project . various google searches found out problem caused because of upgradation in android sdk. there 56 errors in project. managed solve 54 of them adding several jars java built path. im sure program clean , not contain errors. got github. pictures of errors provided thread. im using eclipse mars way. errors follows 1.the project not built since build path incomplete. cannot find class file org.apache.http.httpresponse. fix build path try building project 2.the type org.apache.http.httpresponse cannot resolved. indirectly referenced required .class files in advance if using android sdk 23 httpresponse , other org.apache classes missing. because, have been removed. instead, use urlconnection network communication.

python - SQLAlchemy Query to create table in second database -

i using pandas query different databases (usually oracle) , store in single postgres database. cases querying results create table without making use of pandas power. large queries memory intensive since pandas retrieves rows before running inserts. i interested know if can accomplish sqlalchemy expressions alone. sample of pandas code (very simple) import pandas pd sqlalchemy import create_engine engineora = create_engine('oracle://user:passwd@oraclehost:port/sid') engine = create_engine('postgresql://user:passwd@localhost:5432/dbname') data = pd.read_sql_query(sqlselect, engineora) data.to_sql('table_name',engine, if_exists='replace') this works great other large result sets. started investigate way in straight sqlalchemy expression (ideally low memory usage) without luck. engineora = create_engine('oracle://user:passwd@oraclehost:port/sid') engine = create_engine('postgresql://user:passwd@localhost:5432/dbname') results

php - Post to multiple accounts on twitter using API. getting duplicate status error. -

trying post twitter using laravel and twitter api package . im using foreach loop grab each of account tokens , post keep getting error duplicate status because seems not changing tokens before posting twitter. i've tried refresh page , break connection, still getting error. here foreachloop foreach ($post['accountstopost'] $accounttopost) { $uniqueprofile= db::table('profiles')->where('social_media_id', $accountstopost)->first(); $new_token = [ 'oauth_token' => $uniqueprofile_test->oauth_token, 'oauth_token_secret' => $uniqueprofile_test->oauth_secret, 'x_auth_expires' => $uniqueprofile_test->x_auth_expires, ]; session::forget('access_token'); session::put('access_token', $new_token); twitter::posttweet(['status' => $post['post_text'], &#

web config - Can't change decimal spectator default on server? -

i moved site server , new server uses comma instead of period when using decimals. locally set machine use comma work out code fix. i added <globalization culture="af-za" uiculture="af-za" /> web.config , found apply's period separate decimals, looking for. when place <globalization culture="af-za" uiculture="af-za" /> onto site web.config hosted on new server not change decimal separator period, says comma? could server force format standard stopping me changing it? you can use cultureinfo.invariantculture property msdn link . this way, server ignore settings, , use "default" value. in case, use comma.

node.js - DefinitelyTyped for systemjs-builder -

is there definitelytyped systemjs-builder? https://github.com/systemjs/builder because systemjs.d.ts not seem include it, , "cannot find module" error when try import it: import builder = require('systemjs-builder'); and couldn't find systemjs-builder.d.ts file on internet. if there isn't definitelytyped library, how can use typescript? any profoundly appreciated! this 1 https://github.com/definitelytyped/definitelytyped/blob/master/systemjs/systemjs.d.ts should includes type definifions builder. edit: seems there no typings avalible (maybe use js). when dont want create typings can put in systemjs-builder.d.ts : declare module "systemjs-builder" { var builder: any; export = builder; } and write /// <reference path="../yourpath/systemjs-builder.d.ts" /> in main typings.

Python: How to keep a variable in memory such that it can be called from other python scripts? -

there module named tzwhere in python. when load in tz variable in:- from tzwhere import tzwhere tz = tzwhere.tzwhere(shapely=true) the line above takes 45 seconds load , scope until particular python session stopped. after line can many outputs of tz.tznameat(latitude, longitude) want, problem these outputs calculated in python shell. i want make tz variable shareable api, such if tz variable called python session or if java program using exec command, neither should take 45 seconds load again , nor should give me nameerror: name 'tz' not defined . please help. thank much!! you use pickle module can store class instances in files. try this: tzwhere import tzwhere tz = tzwhere.tzwhere(shapely=true) import pickle # dump variable tz file save.p pickle.dump( tz, open( "save.p", "wb" ) ) to load tz script do: import pickle tz = pickle.load( open( "save.p", "rb" ) ) note: python 2 only, use faster ve

websocket - 2D multiplayer game real-time comunication JavaScript -

i programming multi-player game javascript , html. objective need communication between players. how can manage this? my code: enchant(); window.onload = function() { var game = new game(320, 320); here first question: should counted how many player now, entered room last. number should assigned player. i´d solve function. var my_bear = get_player_number(); game.preload('chara1.gif'); game.fps=15; var bears = []; game.onload = function() { var ix; var bear; (ix = 0; ix < 5; ix++) { bear=new sprite(32, 32); bear.image = game.assets['chara1.gif']; bear.frame = 4; bear.x=math.random()*300; bear.y=math.random()*300; game.rootscene.addchild(bear); bears.push(bear); } }; game.start(); var addit=6; document.addeventlistener('keyup',function (evt) { if(evt.keycode == 38){bears[my_bear

c# - ASP.Net Web App: How to pass Session to new thread? -

i have web application that, based on input user, calculates combination of products fit requirements , returns quote user. calculation can take time, displaying progress dialog user. the progress dialog usercontrol updatepanel, contains text labels, button, , timer used asynchpostbacktrigger trigger. declared on aspx page hidden default. before, created separate thread heavy work while updating progress dialog using main thread. there no issues there. here start thread: protected void startquotecalculation(object sender, eventargs e) { totalpanelcount = currentquote.panelcount; progressdialog.showpopup(); calculatequotethread = new thread(new threadstart(calculatequote)); calculatequotethread.start(); } where calculatequote heavy work. however, i've had change unrelated exactly, affecting calculation of combinations. a variable that's used during quote calculation stored in user session. session lost when start work

jquery - Codeigniter View with controller within View (with a Controller) when loading the 2nd view the 1st view data are erased -

second view <script type="text/javascript"> var globalvariables = { 'csrftoken' : <?php echo json_encode($this->security->get_csrf_hash()); ?>, 'baseurl' : <?php echo '"' . $base_url . '"'; ?>, 'dateformat' : <?php echo json_encode($date_format); ?>, 'services' : <?php echo json_encode($services); ?>, 'categories' : <?php echo json_encode($categories); ?>, 'user' : { 'id' : <?php echo $user_id; ?>, 'email' : <?php echo '"' . $user_email . '"'; ?>, 'role_slug' : <?php echo '"' . $role_slug . '"'; ?>, 'privileges': <?php echo json_encode($privileges); ?> } }; $(document).ready(function() { backendservices.initialize(true); }); </script>