Posts

Featured post

python - Creating a new virtualenv gives a permissions error -

i'm getting following output when running virtualenv newvenv . traceback (most recent call last): file "/usr/local/bin/virtualenv", line 5, in <module> pkg_resources import load_entry_point file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2727, in <module> add_activation_listener(lambda dist: dist.activate()) file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 700, in subscribe callback(dist) file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2727, in <lambda> add_activation_listener(lambda dist: dist.activate()) file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2227, in activate self.insert_on(path) file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2334, in insert_on self.check_version_conflict() file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2373, in check_version_conflict

go - Idiomatic way to handle template errors in golang -

say have html/template following: <html> <body> <p>{{somefunc .somedata}}</p> </body> and somefunc returns error. there idiomatic way deal this? if write directly responsewriter , status code 200 has been written before encounter error. var tmpl *template.template func handler(w http.responsewriter, r *http.request) { err := tmpl.execute(w, data) // "<html><body><p>" has been written... // err? } preferably return status code 400 or such, can't see way if use template.execute directly on responsewriter . there i'm missing? since template engine generates output on-the-fly, parts of template preceding somefunc call sent output. , if output not buffered, (along http 200 status) may sent. you can't that. what can perform check before call template.execute() . in trivial case should enough call somefunc() , check return value. if choose path , return value of somefunc() c

facebook - android ACTION_SEND to share with specific application only -

in android application have 4 buttons facebook , viber , telegram , whatsapp , want share different content based on each button. for example if user clicks on viber button want user action_send share content viber only. i found this explains how facebook , twitter seems it's calling specific class name of application don't know applications wanna use except facebook. all android apps have unique id, first have check if these apps installed in user's device , can pass unique id via intent sharing. according below: unique ids different apps : viber : com.viber.voip telegram : org.telegram.messenger whatsapp : com.whatsapp check if these apps installed , if installed send messages through intent. private void sendmessage(context context,string message, string appids) { final boolean isappinstalled =isappavailable(context, appids); if (isappinstalled) { intent myintent = new intent(intent.action_send); myintent.settype("text/p

c# - What is a NullReferenceException, and how do I fix it? -

i have code , when executes, throws nullreferenceexception , saying: object reference not set instance of object. what mean, , can fix error? what cause? bottom line you trying use null (or nothing in vb.net). means either set null , or never set @ all. like else, null gets passed around. if null in method "a", method "b" passed null to method "a". the rest of article goes more detail , shows mistakes many programmers make can lead nullreferenceexception . more specifically the runtime throwing nullreferenceexception always means same thing: trying use reference, , reference not initialized (or once initialized, no longer initialized). this means reference null , , cannot access members (such methods) through null reference. simplest case: string foo = null; foo.toupper(); this throw nullreferenceexception @ second line because can't call instance method toupper() on string reference pointing null .

javascript - cocos2d-js draw circle not instantly -

i wondering how draw circles (or other shapes also) not instantly. so far tried drawcircle(args...) in ccdrawnode.js , drawcircle(args...) in cc.drawingprimitivecanvas class, , draw circles popping out instantly on screen. what if want achieve effect circular progressive bar, completes circle based on percentage of initialization? or more generally, if want draw circle respect prolonged period? thinking there drawcircle function elapsed time argument fail find any. or have implement own? thanks suggestions, far out of ideas. i think have implement own. think can achieve update circle drawing on each time update() function called.

print tables with dynamic columns angularjs and ngtable -

i'm using angularjs , ngtable , wish print table dynamically generated. this code: var app = angular.module('dl', ['ngtable']); app.controller('dactrl', function($scope, ngtableparams, $http) { $scope.headers=[]; $scope.data = []; //----------------------example-------------------------- //---$scope.header[{label: "value1"},{label: "value2"},{label: "value3"}]----- //---$scope.data[{value1: 1, value2: 2, value3: 3},{value1: 18, value2: 30, value3: 6}, {value1: 15, value2: 21, value3: 56},......]-------------- //------- header y data are dynamically generated $scope.tableparams = new ngtableparams({ page: 1, count: 10, filter: { message: '' }, sorting: { asset: 'asc'

r - Heatmap.2 color gradient with an additional solid color -

Image
the heatmap using creates gradient 0.7 1.3 using heatmap.2 : heatmap.2(lifespan.matrix, col=bluered, breaks=c(seq(0.7,1.3,0.01)), rowv = false, colv = false, trace="none", main="lifespan") in heatmap can see gradient emerge ending oftenly in solid blue line. happens because of 0 values in matrix @ these points. i'd change color, in matrix noted 0, different color i.e. yellow. me problem? breaks <- seq(0.7,1.3,0.01) lifespan.matrix <- matrix(sample(c(breaks,rep(0,100)),100,replace=true),nrow=10) heatmap.2(lifespan.matrix, col=c("#ffff00",bluered(length(breaks)-2)), breaks=breaks, rowv = false, colv = false, trace="none", main="lifespan") you specify exact colors associated breaks.