Posts

Showing posts from September, 2013

SAS where condition exact matching -

thanks feedback guys, have rewrite question make more clear. say, have table: table what trying table list of numbers have matching fp_ndt dates condition, example, want list of numbers, have fp_ndt not null 2014 , 2015 , missing values 2011, 2012 , 2013 (irrelevant of months). condition should number 4. possible table ? ps: if write simple sql select statement , put condition where year(fp_ndt) in (2014,2015) it give me numbers 2 , 3... why not first summarize data? proc sql; create table xx select number , max(year(fp_ndt)=2011) yr2011 , max(year(fp_ndt)=2012) yr2012 , max(year(fp_ndt)=2013) yr2013 , max(year(fp_ndt)=2014) yr2014 , max(year(fp_ndt)=2015) yr2015 table1 group number ; now easy make tests. select * xx yr2014+yr2015=2 , yr2011+yr2012+yr2013=0 ; you use first query sub-query instead of creating physical table.

javascript - Is it possible to detect repaint/reflow in the browser? -

not sure if there solution problem. want know if there way detect when browser actually updates ui. lets want add class element before run long-running, synchronous block of code, after synchronous function runs, class removed. el.classlist.add('waiting'); longrunningsynchronoustask(); el.classlist.remove('waiting'); if run code, long running task started, , block ui before class added. tried using mutationobserver 's, , checking element getcomputedstyle , doesn't work because don't reflect when realtime updates ui. using worker might best solution (drop long running code in worker , post message when it's complete remove class). isn't option me, due needing support older browsers. the solution works outside of implementing worker using settimeout . i'd love know if has run problem , if there way detect repaint/reflow of ui in browser. see example better illustration of problem. const el = document.queryselector('.targe

git - Have two different copies of same file in two different branches -

Image
do know how have 2 different copies of same file in 2 different branches in git? let assume have file called config . i'm trying achieve have copy of file in dev branch different in master branch. the important thing file can't ignored in gitignored. you can checkout 2 branches. modify file , commit them each branch. if want merge branches , have 2 separate files (different content) in each branch, commit changed branches , set desired file tin .gitattributed grab ours file - result in file never overwritten read , set here: https://git-scm.com/book/en/v2/customizing-git-git-attributes#merge-strategies you can use git attributes tell git use different merge strategies specific files in project . one useful option tell git not try merge specific files when have conflicts , rather use side of merge on else’s. this helpful if branch in project has diverged or specialized, want able merge changes in it, and want ignore files . config_fi

regex - Regular Expression user input Java -

this question has answer here: learning regular expressions [closed] 1 answer i new regular expressions , clueless @ moment. i trying create regular expression in java allow alphabetical characters. integers , special characters not allowed. minimum length possible 2 , maximum length 10. (^[a-za-z]{2,10}$) or (\a[a-za-z]{2,10}\z) you downcase first , make smaller regex if doesn't matter these should work.

perl - Use Archive::Zip to determine if a member is a text file or not -

i'm working on script grep contents of members of zip archives when member name matches pattern, using given search string. i have following sub processes single archive (the script can take more 1 archive on command line): sub processarchive($$$$) { ($zip, $searchstr, $match, $zipname) = @_; print "zip[$zip] searchstr[$searchstr] match[$match] zipname[$zipname]\n"; @matchinglist = $zip->membersmatching($match); $len = @matchinglist; if ($len > 0) { print $zipname . ":\n"; $member (@matchinglist) { print "member[$member]\n"; print "textfile[" . $member->istextfile() . "] contents[" . $member->contents() . "]\n"; if ($member->istextfile()) { print "is text file.\n"; } else { print "is not text file.\n"; } @matchinglines = grep /$searchstr/, $member->c

hadoop - complex Hive Query -

hi have following table: id------ |--- time ====================== 5------- | ----200101 3--------| --- 200102 2--------|---- 200103 12 ------|---- 200101 16-------|---- 200103 18-------|---- 200106 now want know how month in year appears. cant use group because counts number of times appears in table. want 0 when month in year not appear. output should this: time-------|----count ===================== 200101--|-- 2 200102--|-- 1 200103--|-- 1 200104--|-- 0 200105--|-- 0 200106--|-- 1 sorry bad table format, hope still clear mean. apreciate help you can provide year-month table containing year , month information. wrote script generate such csv file: #!/bin/bash # year_month.sh start_year=1970 end_year=2015 year in $( seq ${start_year} ${end_year} ); month in $( seq 1 12 ); echo ${year}$( echo ${month} | awk '{printf("%02d\n", $1)}'); done; done > year_month.csv save in yea

Can I create a Visual Studio WinGDB project for python running on Linux? -

i need develop python code run remotely on linux machine. installed extension visual studio called wingdb, supposed allow me use visual studio features such breakpoints , smart editing, while code exists , runs on linux machine. in visual studio created new project, , in templates area, chose template: windgb standard projects -> multiplatform executable. created project c++. how tell instead make python project works remotely linux? possible? none of wingdb templates mention particular language. extent of python support unclear wingdb documentation ( http://www.wingdb.com/docs/pages/wg_intro.htm ) , have not answered email. i'm using visual studio 2015 update 2, , wingdb version 4.4. this answer received wingdb support: unfortunately not possible, wingdb meant native c/c++ development, not python. i think these different plugins python development under vs, or if not have use vs necessarily, can try this: http://www.jetbrains.com/pycharm this python ide

TypeScript transpiling in WebStorm 2016.1 -

after upgrading webstorm 2016.1, typescript transpiling changed import statements different. keep getting js error 'require not defined'. ts file: import {bootstrap} 'angular2/platform/browser'; import {router_providers} 'angular2/router'; import {appcomponent} './application/app.component' import {http_providers} "angular2/http"; import {observable} 'rxjs/rx'; bootstrap(appcomponent, [router_providers, http_providers, observable]); webstorm 11 transpiled version: system.register(['angular2/platform/browser', 'angular2/router', './application/app.component', "angular2/http", 'rxjs/rx'], function(exports_1) { var browser_1, router_1, app_component_1, http_1; return { setters:[ function (browser_1_1) { browser_1 = browser_1_1; }, function (router_1_1) { router_1 = router_1_1;

javascript - Breaking down Callback Hell how do I pass a value? -

using monoskin in express route i'm doing following: router.get(/getbuyerinfo, function(req, res) { var data = "data"; db.collection('buyerrec').find().toarray(function(err, result) { if (err) throw err; console.log(result); db.collection('buyerhistory').find().toarray(function(err, result) { if (err) throw err; console.log(result); console.log(data); }); }); }); it's deeper. in attempt clean deep callbacks, in straight forward , quickest manner, if not modern way, created: router.get(/getbuyerinfo, getbuyerrec); function getbuyerrec(req, res) { var data = "data"; db.collection('buyerrec').find().toarray(getbuyerhistory); } function getbuyerhistory(err, result) { if (err) throw err; console.log(result); db.collection('buyerhistory').find().toarray(function(err, result) { if (err) throw err; co

Frequently dropping a table in SQL Server -

in our current business requirement. have pull complete data every time. have truncate out table , load 20 million rows of data. i want know instead of truncating. if drop , load table select * into . frequent dropping of table have adverse affect on database performance in long term? high fragmentation or related pages? we cannot use merge per our current data. just wanted know adverse affect of frequent drooping , creation of tables.

google chrome - Python Requests Not Returning Same Header as Browser Request/cURL -

i'm looking write script can automatically download .zip files bureau of transportation statistics carrier website , i'm having trouble getting same response headers can see in chrome when download zip file. i'm looking response header looks this: http/1.1 302 object moved cache-control: private content-length: 183 content-type: text/html location: http://tsdata.bts.gov/103627300_t_t100_segment_all_carrier.zip server: microsoft-iis/8.5 x-powered-by: asp.net date: thu, 21 apr 2016 15:56:31 gmt however, when calling requests.post(url, data=params, headers=headers) same information can see in chrome network inspector getting following response: >>> res.headers {'cache-control': 'private', 'content-length': '262', 'content-type': 'text/html', 'x-powered-by': 'asp.net', 'date': 'thu, 21 apr 2016 20:16:26 gmt', 'server': 'microsoft-iis/8.5'} it's got pretty e

android - How to know when one moving view (overlaps) is on the top of the over -

Image
(not sure title. please make right) hi. i'm trying create small game, player can move objects inside ralativelayout . want check whether moving object inside framelayout or outside of it. example want change text of object when inside framelayout . so create objects inside for loop way: random random = new random(); (int = 0; < 3; i++) { //any number, not 3 textview textview = new textview(getactivity()); textview.setx(random.nextint(size.x - 200)); textview.sety(random.nextint(size.y - 200)); //scattered on screen textview.settext(i + ""); textview.setbackgroundcolor(getresources().getcolor(r.color.colorprimary)); textview.settextsize(50); relativelayout.layoutparams lp = new relativelayout.layoutparams( relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); textview.setlayoutparams(lp);

php - Cumulative sum of unique elements sorted by other element in a nested array -

i have following mysql query ( timestamp in unix time, obviously): select usr_id, concat(year(from_unixtime(timestamp)), "/", month(from_unixtime(timestamp)), "/", day(from_unixtime(timestamp))) date_stamp table order year(from_unixtime(timestamp)), month(from_unixtime(timestamp)), day(from_unixtime(timestamp)); this produces this: $arr = array( array('usr_id'=>3, 'date_stamp'=>'2011/6/6'), array('usr_id'=>2, 'date_stamp'=>'2011/6/20'), array('usr_id'=>2, 'date_stamp'=>'2011/6/20'), // same id , date above array('usr_id'=>5, 'date_stamp'=>'2011/6/20'), // same date above array('usr_id'=>1, 'date_stamp'=>'2011/6/21'), array('usr_id'=>4, 'date_stamp'=>'2011/6/21'), // same date above array('usr_id'=>2, 'date_stamp'=>'2011/6/21&

jsf - How to enable/disable inputText on rowSelectCheckbox and rowUnselectCheckbox -

i need in enabling , disabling inputtext based on rowselectcheckbox , rowunselectcheckbox if checkbox ticked or unticked. if ticked, need enable inputtext otherwise should disabled on page load , on untick. default inputtext disabled on page load. here code jsf: <h:form id="request"> <p:datatable value="#{datatableview.employeelist}" id="employee" var="emp" selection="#{datatableview.selectedemployees}" rowkey="#{emp.id}"> <p:ajax event="rowselectcheckbox" listener="#{datatableview.enableinputtext}" /> <p:ajax event="rowunselectcheckbox" listener="#{datatableview.enableinputtext}" /> <p:columngroup type="header"> <p:row> <p:column/> <p:column headertext="id"/> <p:column headertext="name"/>

adal - Azure AD: How to get group information in token? -

we have application developed in mean stack. using adal-agular library azure ad authentication. per documentation , sample adal.js uses oauth implicit flow communicate azure ad. must enable implicit flow application. however when enable implicit flow, azure ad does not include group information in token. issue has been discussed here in detail , confirmed @vibronet question azure ad functionalities have been changing everyday, above answers still valid? still have enable implicit flow of our application? want group information in token (i dont want use graph api solution.) another reason asking question because disabled implicit flow , user still able access application. still don't see group information in token. impossible without calling graph be: here discussion: https://github.com/azuread/azure-activedirectory-library-for-js/issues/239 if hasgroups claim doesn't exist in id_token - groups id_token. if exists - call graph example azur

php - Different button colors based on database query -

i have web form allows people sign class. @ bottom of form submit button says "sign up". in php code, checking number of people have registered class. if count equal specific number, 60 registrants, want change button red , text changed "class full". how do css if can define 1 button color? this css: button { padding: 19px 39px 18px 39px; color: #fff; background-color: #4bc970; font-size: 18px; text-align: center; font-style: normal; border-radius: 5px; width: 100%; border: 1px solid #3ac162; border-width: 1px 1px 3px; box-shadow: 0 -1px 0 rgba(255,255,255,0.1) inset; margin-bottom: 10px; } button1 { padding: 19px 39px 18px 39px; color: #fff; background-color: #ff0000; font-size: 18px; text-align: center; font-style: normal; border-radius: 5px; width: 100%; border: 1px solid #3ac162; border-width: 1px 1px 3px; box-shadow: 0 -1px 0 rgba(255,255,255,0.1) inset; margin-bottom: 10px;

angularjs - basic else if and return javascript -

i learning angular 1.5 , js @ same time. assigning defaults notify.js. have code has no errors, have feeling else if done in better way. also, try , put returns in, errors. please show me best way if else , returns go (bottom or inline?). still have hard time ending functions , semicolons. know these odd but, no errors. thank you. function notificationservice ($scope, $) { var vm = this; /** * @see notifyjs.com */ vm.publish = function (type) { if (type === 'info') { $.notify.defaults({ scope: $scope, classname: 'info', autohide: true, position: 'bottom' }); } else if (type === 'success') { $.notify.defaults({ scope: $scope, classname: 'success', autohide: true, position: 'bottom' }); } vm.publ

Update 3d matrix with coordinates in javascript -

Image
i'm trying create 3d matrix in javascript, , want update values using coordinates: var xaxis = []; var yaxis = []; var zaxis = []; var dimensions = 4; //initalize matrix (var i=0;i<dimensions;i++){ xaxis.push(0); } (var j=0;j<dimensions;j++){ yaxis.push(xaxis); } (var k=0;k<dimensions;k++){ matrix.push(yaxis); } //check value of 1 point in matrix matrix[1][2][3]; //returns 0 expected //update value of matrix using same coordinates matrix[1][2][3] = 2; when run last step, not update expected 1 [2][3] coordinates, updates every third value of every array 2 see in image: how can manage update value want?? mean, number 2 should in 1 coordinate point, in case 1 [2][3]. note: think it's got might assigning original arrays matrix instead of new copies of themselves, when update 1 coordinate, i'm updating original array, , other arrays pointing @ original, that's why it's been reflected there well? you push arrays reference. c

html5 - How can I show synchronized Video and waveform Audio in javascript? -

i want show video , audio waveform @ same time in javascript video player. position should synchronized, ie if play video, position in waveform view should adapt. tried following using wavesurfer.js cannot figure out how synchronize it: <video id="video" class="video-js vjs-default-skin" controls> // replace these own video files. <source src="video.m4v" type="video/mp4" /> html5 video required example. </video> <audio id="myaudio" class="video-js vjs-default-skin"></audio> <script> var player = videojs("myaudio", { controls: true, autoplay: true, loop: false, width: 600, height: 300, plugins: { wavesurfer: { src: "media/heres_johnny.wav", msdisplaymax: 10, wavecolor: "grey", progresscolor: "black", cursorcolor: "black",

How to read in the last word in a text file and into another text file in C? -

so i'm supposed write block of code opens file called "words" , writes last word in file file called "lastword". have far: file *f; file *fp; char string1[100]; f = fopen("words","w"); fp=fopen("lastword", "w"); fscanf(f, fclose(fp) fclose(f); the problem here don't know how read in last word of text file. how know word last word? this similar tail tool does, seek offset end of file , read block there, search backwards, once meet whitespace or new line, can print word there, last word. basic code looks this: char string[1024]; char *last; f = fopen("words","r"); fseek(f, seek_end, 1024); size_t nread = fread(string, 1, sizeof string, f); (int = 0; < nread; i++) { if (isspace(string[nread - 1 - i])) { last = string[nread - i]; } } fprintf(fp, "%s", last); if word boundary not find first block, continue read second last block , search in it,

Converting C++ code from VS 2005 to VS 2008? What does that even mean? -

ok, kinda got assignment, , not sure means. the guy told me "converting" code older version of vs newer one, not sure versions said, lets take these said correct. language c++, , supposed here? mean, differences in vs's? maybe misunderstood said, anyway i'm lost, anyone? the following typical sequence of tasks: load old vs2005 project file in vs2008 vs2008 prompt convert project file vs2008 format, that build project fix flagged error newer compiler test resulting compiled code of course c++ language did not change between years. other things vs might have.

python - How to mock calls to function that receives mutable object as parameter? -

consider example: def func_b(a): print def func_a(): = [-1] in xrange(0, 2): a[0] = func_b(a) and test function tries test func_a , mocks func_b: import mock mock import call def test_a(): datatransform.test import func_a mock.patch('datatransform.test.func_b', autospec=true) func_b_mock: func_a() func_b_mock.assert_has_calls([call(0), call(1)]) after func_a has executed try test if func_a made correct calls func_b, since in loop mutating list in end get: assertionerror: calls not found. expected: [call(0), call(1)] actual: [call([1]), call([1])] the following works (the importing mock unittest python 3 thing, , module func_a , func_b are): import mock mock import call import copy class modifiedmagicmock(mock.magicmock): def _mock_call(_mock_self, *args, **kwargs): return super(modifiedmagicmock, _mock_self)._mock_call(*copy.deepcopy(args), **copy.deepcopy(kwargs)) this inherits m

asp.net mvc - MVC 5 Custom ActionFilter not working -

i'm trying implement basic authentication service using question template. for reason action filter never applied controllers , have no idea why. my controller: [basicauthenticationmanager("username", "password")] public class datacontroller : apicontroller { private dataentities db = new dataentities(); // get: api/data //[basicauthenticationmanager] public ihttpactionresult getvwdata() { return json(db.vwdata); } } my filter: public class basicauthenticationmanager : actionfilterattribute { protected string username { get; set; } protected string password { get; set; } public basicauthenticationmanager(string username, string password) { this.username = username; this.password = password; } public override void onactionexecuting(actionexecutingcontext filtercontext) { var req = filtercontext.httpcontext.request; var auth = req.headers["authorizat

python - Send a file to a specific path in a server -

i trying send file pc many servers specific folder in server directory using 1 script, keeping things simple, trying in beginning send 1 file 1 server instead of many. i connected server using key authentication, not need use login info in code. have used following: import pysftp sftp def filetransfer(): try: s = sftp.connection(host='ip address')# server ip address inserted remotepath='/xx/yy/file.txt'# file transferred localpath='c:/users/david/desktop/file.txt'# file location in pc s.put(localpath,remotepath) s.close() except exception, e: print str(e) filetransfer() i following exception: attributeerror: "'connection' object has no attribute '_transport_live'" in <bound method connection.__del__ of <pysftp.connection object @ 0x0000000002e1f3c8>> i have tried insert server port beside ip address, did not same error. use this sftp.connec

php - Symfony 2.3 Adding Google API -

i used before symfony2 , google api integration i had question this, when use classmap in compser.json able google_client class, unable use other classes. for example want use goole_youtubeservice . have... $client = new \google_client(); $youtube = new \google_youtubeservice($client); when code recognizes google_client() , cannot find google_youtubeservice() . am missing work? this composer.json { "name": "symfony/framework-standard-edition", "description": "the \"symfony standard edition\" distribution", "autoload": { "psr-0": { "": "src/" }, "classmap": ["vendor/google/google-api-php-client/src","vendor/google/google-api-php-clien‌​t/src/contrib"] }, "require": { "php": ">=5.3.3", "symfony/symfony": "2.3.*", "doctrine/orm": "~2.2,>=2.2.3

angularfire - Update part of record firebase -

i have firebase node called comment{textcmnt, datecmnt} try code update textcmnt node updated. var obj = $firebaseobject(ref.child('/comment/'+$scope.c.$id)); obj.textcmnt="new text"; obj.$save(); any please. there no method built angularfire that. luckily angularfire built on top of firebase javascript sdk, has method purpose: ref.update({ textcmnt: "new text" }); and since angularfire built on top of that, interoperate perfectly.

go - golang gofmt package rewrite wildcard -

i'm trying gofmt rewrite of packages start prefix. like: gofmt -r 'github.com/some/path/<wildcard> -> someotherrepo.com/some/path/<wildcard>' obviously wildcard isn't valid syntax, showing concept. i've tried single lowercase character, doesn't work here. is possible i'm trying gofmt ? this gofmt command page says given file, operates on file; given directory, operates on .go files in directory, recursively https://golang.org/cmd/gofmt/

python - I am using a numpy array of randomly generated ordered pairs, I need to determin if the ordered pairs are different types of triangles -

i jst started using numpy week, , confused it. seems different normal python functions. with array, shape of 1000x6, there way go row row in array , check example equilateral triangle.i have 6 columns there triples in each row, 2 integers each point. import numpy np pnts = np.random.randint(0,50,(1000, 6)) i thought may better create 3 arrays this: import numpy np = np.random.random((10,2)) b = np.random.random((10,2)) c = np.random.random((10,2)) to create ordered pairs , use algorithm find triangle. is there better way create array represent 1000 triples of ordered pairs , how can find triangles in array, equilateral triangle example. i have made changes now. made 2 arrays x coordinates , y coordinates. x = np.random.randint(0,10,(3,1000)) y = np.random.randint(0,10,(3,1000)) ############# adding question ############# i have algorithms take each matching x , y coordinates find there side length , angles each triangle. post code. , have functions use angles ,

r - Changing the Appearance of Facet Labels size -

Image
i know question asked here: is there way increase height of strip.text bar in facet? i want decrease height of strip.text bar without changing text size. in current case there space left between text , strip bar walls. here tried far, library(gcookbook) # data set library(ggplot2) ggplot(cabbage_exp, aes(x=cultivar, y=weight)) + geom_bar(stat="identity") + facet_grid(.~ date) + theme(strip.text = element_text(face="bold", size=9,lineheight=5.0), strip.background = element_rect(fill="lightblue", colour="black", size=1)) in case seems lineheight not affect if changed 5 . why? how can make strip bar size little smaller keeping text size same? edit after @sandy muspratt answer we able reduce strip size if there 1 row of facets . g = ggplotgrob(p) g$heights[c(3)] = unit(.4, "cm") # set height grid.newpage() grid.draw(g) however, in real data have many rows of plot below , when changed elements of g$heights nothi

With jquery how do you keep an element in focus after resize? -

i'm trying copy mashable.com's second menu in 640px & 320px. i'm having trouble when resize called menu item element becomes no longer in focus anymore when rotating 640px 320px. can me please? here current code, i've taken out resize function moment until can sorted. <script> jquery(document).ready(function(){ var sliderwidth = jquery('.mosts').css('width'); swidthnum = sliderwidth.replace("px", ""); if (swidthnum >= 640) { jquery('#slider').css('width', '150%'); jquery(".buttongroup1>.date-nav-1").click(function(){ jquery("#slider").animate({left: "0px"}); }); jquery(".buttongroup1>.date-nav-3").click(function(){ jquery("#slider").animate({left: "-50%"}); });

java - How to merge documents correctly? -

Image
i have following problem when printing pdf file after merge, pdf documents cut off. happens because documents aren't 8.5 x 11 might 11 x 17. can make detect page size , use same page size documents? or, if not, possible have fit page? following code: package com.sumit.program; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import java.util.arraylist; import java.util.iterator; import java.util.list; import com.itextpdf.text.document; import com.itextpdf.text.pagesize; import com.itextpdf.text.rectangle; import com.itextpdf.text.pdf.basefont; import com.itextpdf.text.pdf.pdfcontentbyte; import com.itextpdf.text.pdf.pdfimportedpage; import com.itextpdf.text.pdf.pdfreader; import com.itextpdf.text.pdf.pdfwriter; public class mergepdf { public static void main(string[] args) { try { list<inputstream> pdfs = new arraylist<inputstream>()

groovy - Use value returned by a unix shell script then assign it to downstreamParameterized in Jenkins -

i have entry in our dsl.groovy downstreamparameterized { trigger('apache_server') { parameters { predefinedprop('app_package_version', "\${app_package_version}") } } } if notice, value coming app_package_version in stringparam. i'd happen use value being returned unix script(this script exists). how should write code in groovy? job dsl uses groovy , groovy includes the  execute  method to  string  to make executing shells possible: println "script.sh".execute().text you can learn more following article . call execute() resolved during job dsl engine. therefore generated project have output value. if call script each time job build, suggest using groovy plug-in .

javascript - Use of ionic modal gives blank black screen -

i making app in ionic framework. when click on button supposedly open ionicmodal, shows blank black screen. html code: <div class="well"> <h4>add proof</h4> <button style="width:100px;height:10px" class="button button-dark" ng-click="modal.show()">add</button> </div> <script id="templates/newitem.html" type="text/ng-template"> <ion-modal-view> <ion-header-bar class="bar bar-header bar-positive"> <h1 class="title">add proof</h1> <button class="button button-clear button-primary" ng-click="modal.hide()">cancel</button> </ion-header-bar> <ion-content class="padding"> <div class="list"> <label> <h4>select pictures</h4> <button class="button button-small button-dark">bro

java - Recusively Flipping a Binary Tree -

i have homework assignment in need flip binary tree. i'm not looking code or anything, hints why method not working. below code. when step through it, seems work fine, flipping each left , right node, , moving through tree recursively. however, seems on return, it's returning node null left , right values, except original node (root). public class treemanipulator<e> { public treemanipulator() { } public binarynode<e> fliptree(binarynode<e> _root) { binarynode<e> root = new binarynode<>(_root.getitem()); if (_root.getleft() != null) { root.setright(new binarynode<>(_root.getleft().getitem())); this.fliptree(_root.getleft()); } if (_root.getright() != null) { root.setleft(new binarynode<>(_root.getright().getitem())); this.fliptree(_root.getright()); } return root; } } here main method: public static void mai

Google API + proxy + httplib2 -

i'm running script pull data google analytics googleapiclient phyton package (that based on httplib2 client object) --> script works without proxy. but have put behind corporate proxy, need adapt httplib2.http() object embed proxy information. following httplib2 doc 1 tried: pi = httplib2.proxy_info_from_url('http://user:pwd@someproxy:80') httplib2.http(proxy_info=pi).request("http://www.google.com") but did not work. time out error, or without proxy info (so proxy_info in parameter not taken account) i downloaded socks in pysocks package (v1.5.6) , tried "wrapmodule" httplib2 described in here: https://github.com/jcgregorio/httplib2/issues/205 socks.setdefaultproxy(socks.proxy_type_http, "proxyna", port=80, username='p.tisserand', password='telematics12') socks.wrapmodule(httplib2) h = httplib2.http() h.request("http://google.com") but indexerror: (tuple index out of range) in meantime,

ios - Swift NSUserDefaults unexpectedly found nil while unwrapping an Optional value -

//help please code won't work, getting feedback xcode. fatal error: unexpectedly found nil while unwrapping optional value var savedscore = nsuserdefaults.standarduserdefaults().objectforkey("highestscore") as! int import spritekit class gamescene: skscene { var highestscore:int = 2 var score = int() override func didmovetoview(view: skview) { /* setup scene here */ //to save highest score //to saved score var savedscore = nsuserdefaults.standarduserdefaults().objectforkey("highestscore") as! int print(savedscore) } override func touchesbegan(touches: set<uitouch>, withevent event: uievent?) { /* called when touch begins */ score += 1 print("score - \(score)") if score > highestscore { highestscore = score nsuserdefaults.standarduserdefaults().setobject(highestscore, forkey:"highestscore&quo

c++ - Doubly linked list Core dump -

thanks in advance. i making doubly linked list. everything working fine, realized when added new class node somewhere in middle, left pointer still pointing @ node before (now 2 spaces away). so added new node pointer on line 46. then on line 51 told node point new node. so : first had new node temp off in space then make pointer temp2 loop through list lastly tell temp3 point node after temp2 's node after function runs, order should temp2->temp->temp3 my main point : after added line 51, program core dumps(segmentation fault) , closes out. how can fix this? happens when add isn't taking place of head pointer. void add(node *&head, node *&tail, node *&current) { node *temp = new node; //creates pointer pointing new class node cin >> temp->letter; // user input current = head; // creates pointer point @ first node while (current != null) // while list isn't empty { if (current->lett

How to create a string using placeholder (%s) in c -

normally can use placeholder %s in printf(), fprintf() function. i want use placeholder create string using %s. that char fname[200] = "c:\\users\\%s\\desktop\\result", getenv("username"); // getenv() function return current user name // fname "c:\\users\\zobayer\\desktop\\result" i know in c++ can create stringstream std::stringstream ss; ss << "c:\\users\\" << getenv("username") << "\\desktop\\result"; but in c how can create type of string ? please me. and advance me. try sprintf . print string. char fname[200]; sprintf(fname, "c:\\users\\%s\\desktop\\result", getenv("username"));

javafx - Drag and drop item into TableView, between existing rows -

table contains following rows (one column example): a b c i'm trying figure out how drag item it, , have placed between existing rows b , c. i able drag-and-drop results in item added @ end of table can't figure out how place in between rows, based on release mouse button. create rowfactory producing tablerow s accept gesture , decide mouse position, whether add item before or after row: @override public void start(stage primarystage) { tableview<item> table = new tableview<>(); button button = new button("a"); // d&d source providing next char button.setondragdetected(evt -> { dragboard db = button.startdraganddrop(transfermode.move); clipboardcontent content = new clipboardcontent(); content.putstring(button.gettext()); db.setcontent(content); }); button.setondragdone(evt -> { if (evt.isaccepted()) { // next char button.settext(chara