Posts

Showing posts from September, 2010

qt put multiple executables into one bundle on mac OSX -

we have 4 mac applications form part of 'suite', each use different scientific instrument connected via usb. my colleagues on windows have developed splash screen app lets choose 1 of 4 separate programs run, depending on instrument using. on windows splash screen app in same folder other executables , dependencies , libraries included in same folder well. easy clicking required radio button , program launch. what hoping on mac os x bundle 4 separate programs 1 app bundle , splash screen, when application launched user presented splash screen, when choose appropriate app gets launched automatically. the dependencies , libraries common apps. i'm comfortable building app bundle dependencies using mac deployment tool i'm unsure if possible build multiple binaries 1 app bundle, , how set default app launched (the splash screen). thanks in advance :) mitch yes, multiple app bundles inside app bundle possible. how set default app launched as ...

coreos - Can kube-apiserver allow the unsecure connection outside of localhost? -

i'm trying setup kubernetes cluster development environment (local vms). because it's development i'm not using working certs api-server. seem have use secure connection in order connect minion daemons such kube-proxy , kubelet master's kube-apiserver . has found way around that? haven't seen in docs being able force unsecure connection or ignoring certs bad, assume there's flag when running either minion or master daemons, i've had no luck. etcd working, shows entry both master , minions , logs show attempts @ handshakes failing due bad certs. you can set flag --insecure-bind-address=0.0.0.0 when starting kube-apiserver allow access unauthenticated api endpoint running on port 8080 network (by default accessible on localhost).

javascript - ajax responseText is returning header bar with echo content -

Image
i using ajax communicate php .when fetched data shows typed email present on database,i used echo message 'email taken,try email'.but ajax responsetext returning header file , echoed content .here image how can echoed message ajax responsetext? here codes javascript function signup(){ var f=document.getelementbyid("firstname").value; var l=document.getelementbyid("lastname").value; var p=document.getelementbyid("password1").value; var p2=document.getelementbyid("password2").value; var e=document.getelementbyid("email").value; var status=document.getelementbyid("status"); if(f=="" || l=="" || p=="" || p2=="" || e==""){ status.innerhtml="all fields required"; } else if(p!=p2){ status.innerhtml="passwords didn't match"; } else{ document.getelementbyid("submitx").style.display = "no...

java - How to Correctly Close Resources -

as cleaning code, findbugs pointed me bit of jdbc code uses connection, callablestatement, , resultset objects. here's snippet code: callablestatement cstmt = getconnection().preparecall("..."); ... resultset rs = cstmt.executequery(); while ( rs.next() ) { ... } cstmt.close(); rs.close(); con.close(); findbugs pointed out these should within block. started refactoring code , started wonder how handle code within block. it's possible creation of callablestatement of connection objects throw exception, leaving resultset object null. when try close resultset, i'd nullpointerexception , connection would, in turn, never closed. indeed, this thread brings same concept , shows wrapping close() invocations in null check idea. but other possible exceptions? according java api spec, statement.close() can throw sqlexception "if database error occurs". so, if callablestatement not null , can call close() on it, might still exception , not have ch...

qt - PyQt setGeometry sets client size; how to set size of entire window? -

class appwindow(qtgui.qmainwindow): def __init__(self, parent=none): super(appwindow, self).__init__(parent) self.setgeometry(x, y, w, h) when window opens, client area of window cover (x, y, w, h). but overall window, borders, title, , menubar, covers larger area. i want initial overall window cover (x, y, w, h), without regard client area size. how do it?

java - Can someone tell me what this means? -

this question has answer here: calling invokeandwait edt 4 answers while working threads , runnables, popped up...can please tell me means? thank much. exception in thread "awt-eventqueue-0" java.lang.error: cannot call invokeandwait event dispatcher thread there thread edt (event dispatcher thread). whatever reason, edt needed call invokeandwait() , either security, visibility, or other cause did not let edt call method. exception thrown awt event queue thread (0), thread manages java.awt.* classes.

ActiveX controls implementation differences in VB6 & python using win32com. -

i have third party activex controls designed used in vb6. want migrate controls python. got win32com , ran 'makepy.py -i' on type library file. understand how dispatch executable container using win32com.client.dispatch() method , call subclasses. container called sterling , running when calls object made, don't exclusively mention container in vb code, figure it's not needed here either. have comm objects type library, however, seems work in vb6. vb6 code works , accesses com object after add reference sterling.tlb type library: ' declare activex type library class public withevents m_stiquote stiquote private sub form_load() ...................................... ' create instance of type library class set m_stiquote = new stiquote ...................................... end sub private sub form_unload(cancel integer) ...................................... ' destroy type library class set m_stiquote = nothing ........................

python - Grequests with exponential backoff -

the following pattern have doing simultaneous requests: rs = (grequests.get(url) url in urls) res_items = grequests.map(rs) num, res in enumerate(res_items): json_data = json.loads(res.text) however, crashes error connectionerror: httpconnectionpool(host='apicache.vudu.com', port=80): max retries exceeded url: every 5,000 requests. more reliable patter doing above -- example, retrying url 5 times if individual request doesn't work? here 1 option, using exponential backoff described here: def grequester(self, url, n=1): ''' google exponential backoff: https://developers.google.com/drive/web/handle-errors?hl=pt-pt ''' max_tries = 8 try: res = grequests.get(url) except: if n > max_tries: return none n += 1 log.warning('try #%s %s...' % (n, url)) time.sleep((2 ** n) + (random.randint(0, 1000) / 1000.0)) # add jitter 0-1000ms return self...

Azure worker role hangs on publish with error in Diagnostics -

after updating azure sdk 2.6 (from 2.5.1) have not been able publish azure worker role instance. had been working 2.5.1 sdk. worker process fails start in azure , hangs status of: busy (waiting role start... application startup tasks running. [2015- 06-02t23:27:56z] last role error: exit code - 0, exit time - [2015/06/02, 23:27:20.218]) the worker process make use of azure diagnostics - configured in service definition file like: <imports> <import modulename="remoteaccess" /> <import modulename="remoteforwarder" /> <import modulename="diagnostics"/> </imports> and see error in event log of worker vm: system.unauthorizedaccessexception: access path 'diagnosticplugin-shutdownevent' denied. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.threading.eventwaithandle..ctor(boolean initialstate, eventresetmode mode, string name) @ microsoft.windowsazure.plug...

jquery - Table with SlideToogle Randomly Jerky -

i have table quite few rows. , jquery expand collapse rows. appears start ok , after short while find animation jerky, jumpy. http://jsfiddle.net/felix00111/6jesxoxk/8/ below jquery $('tr.main-parent') .css("cursor", "pointer") .click(function () { var $children = $(this).nextuntil($('tr').not('.sub')); if ($children.find(':visible').length) { $children.find('td > div, td').slideup(1200); } else { $children.filter('.parent').find('td > div, td').slidedown("slow"); } }); $('tr[class^=child-]').find('td > div, td').hide(); $('tr.parent') .css("cursor", "pointer") .click(function () { var $children = $(this).nextuntil($('tr').not('[class^=child-]')); $children.find('td > div, td').slidetoggle(1200); }); $('tr.sub').find('td > div, td').hid...

Unable to connect to Cassandra remotely using DataStax Python driver -

i'm having trouble connecting cassandra (running on ec2 node) remotely (from laptop). when use datastax python driver cassandra: from cassandra.cluster import cluster cluster = cluster(['10.x.x.x'], port=9042) cluster.connect() i get: traceback (most recent call last): file "/users/user/virtualenvs/test/lib/python2.7/site-packages/ipython/core/interactiveshell.py", line 3035, in run_code exec(code_obj, self.user_global_ns, self.user_ns) file "<ipython-input-23-dc85f20fd4f5>", line 1, in <module> session = cluster.connect() file "/users/user/virtualenvs/test/lib/python2.7/site-packages/cassandra/cluster.py", line 755, in connect self.control_connection.connect() file "/users/user/virtualenvs/test/lib/python2.7/site-packages/cassandra/cluster.py", line 1868, in connect self._set_new_connection(self._reconnect_internal()) file "/users/user/virtualenvs/test/lib/python2.7/site-packages/c...

string - Match pattern of a list of words and highlight the found results -

i want excel row in column1 contains strings in column2. when found, highlight rows in column1. can group rows , use them else. have big data set need automated. column1 column2 long text 'uy58iop' uy58iop long text 'uy58iop' ldk09jy long text 'ldk09jy' te89uty long text 'te89uty' long text 'oo48tsi' please try selecting columna, home > styles - conditional formatting - new rule..., use formula determine cells format , format values formula true: : =match(left(right(a1,8),7),b:b,0) format... , fill, select choice of highlighting, ok, ok.

html - Paying for multiple items (at once) via paypal -

i have list of products i'd add "pay now" button can allow customers pay via paypal. i've gone through documentation , can't find how this. can add multiple items, not going handy have list of items process. need checkout process itemize order, "buy now" 1 price no either. any appreciated guys, tried (with no luck): <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="email@domain.com"> <input type="hidden" name="lc" value="gb"> <input type="hidden" name="item_name" value="test 1"> <input type="hidden" name="item_number" value="1"> <input type="hidden" name="item_name2" value="test 2...

python - different nltk results in django and at command line -

i have django 1.8 view looks this: def sourcedoc_parse(request, sourcedoc_id): sourcedoc = sourcedoc.objects.get(pk=sourcedoc_id) nltk.data.path.append('/root/nltk_data') new_words = [] english_vocab = set(w.lower() w in nltk.corpus.gutenberg.words()) #<---the line error occurs results = {} template = 'sourcedoc_parse.html' params = {'sourcedoc': sourcedoc,'results': results, 'new_words': new_words, 'base_url': base_url} return render_to_response(template, params, context_instance=requestcontext(request)) it gives me following error: django version: 1.8 python version: 2.7.6 ... traceback: file "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/home/rosshartshorn/htdocs/worldmaker/sourcedocs/views.py" in sourcedoc_parse 107. engl...

node.js - "nvm" command not recognized in new command line windows/tabs despite presence of "NVM_DIR" variable in both ~/.bashrc and ~/.bash_profile -

my colleague installed node version manager on macbook using homebrew, , ran 2 commands suggested @ end of install script: export nvm_dir=~/.nvm source $(brew --prefix nvm)/nvm.sh everything works fine in terminal window in install took place, if opens new terminal window or new tab, has install nvm on again. my level of command-line experience relatively low (i don't know don't know), i'm not sure start diagnosing problem. suggestions welcome. the instructions brew after installing nvm are: add following $home/.bashrc, $home/.zshrc, or shell's equivalent configuration file: source $(brew --prefix nvm)/nvm.sh on os x default settings, want $home/.profile (or ~/.profile ). add line above end of file. running line once set nvm in shell session. if add .profile file, run @ beginning of every shell session.

java - start AsyncTask from one activity, get result in another -

i'm new android programming, , i'd create central database service class take care of user data exchange external database. this, created service started after successful login. created class extends asynctask data retrieval. now, wanted methods data retrieval stored in service. fire intents service different activities, , .setaction() determine method call, or data retrieve. i created interface class handling asynctask results. now, this question thought possible have multiple listeners 1 , same asynctask result. seems impossible achieve: i'd retrieve asynctask results in mainmenuactivity, can't create instance of asyncuserdata there delegate userdata class. in example below, missing piece valid instance of asyncuserdata userdata class work with. how it? here's example: mainmenuactivity public class mainmenuactivity extends actionbaractivity implements asyncuserdata { textview tvusername; protected void oncreate(bundle savedinstancestate) { sup...

angularjs - Infinite loop in interceptor -

i've made angularjs website working api. api provides few features authentication (oauth). when api returns 401 error, means access_token has expired , needs refreshed refresh_token . i created interceptor in angularjs. goal check if result returned api 401 error , if it's case, must refresh token , then, process previous rejected request. the problem interceptor creates infinite loop. after second failure of initial request, should stop doesn't. angular.module('myapp') .factory('authinterceptor', function ($rootscope, $q, $window, $injector) { return { // if api returns error 'responseerror' : function(rejection) { // if it's 401 if (rejection.status == 401) { var deferred = $q.defer(); $injector.get('$http').post('http://my-api.local/api/oauth/token', { grant_type : 'refresh_token', client_id : 'id', client_secret : '...

performance - Iterating bidimensional array/list with only one for (Python) -

this question has answer here: “for loop” 2 variables? 7 answers instead of doing this: for x in range(500): y in range(300): print x,y how can this? for x,y in range(500),range(300): print x,y i use itertools.product from itertools import product x, y in product(range(500), range(300)): print x, y

Linking an Excel Sheet to another in the same workbook using VBA -

i'm trying keep track of been done in workbook, have copy of sheet comments added date of change , user changed it(don't care change want know cells change dates , username), yes know can use copy , paste link, vba script have right doesn't recognize changes made in original sheet code below: private sub worksheet_change(byval target excel.range) 'if target.column <> 1 exit sub dim ccc range dim comment string application.screenupdating = false application.calculation = xlmanual comment = ("cell last edited: ") & & (" ") & application.username target.clearcomments each ccc in target range(ccc.address).addcomment comment next ccc application.screenupdating = true application.calculation = xlautomatic end sub in works nice, clear want script copies original sheet 1 , if make change copy or modified copy sheet , add comment date , username any suggestion great , in advance :d not sure if keeping ...

react native - Set the bounds of a mapView -

i have app calls api , returns list of locations. once data returned, convert json map points annotations. these added ma no problem. the problem running setting bounds of map. can't seem figure out. the code have is. _handleresponse(response) { var locations = []; // loop through repsone , add items arra annotations (var = 0; < response.length; i++) { // location var location = response[i]; // parse co ords var lat = parsefloat(location.latitude); var lng = parsefloat(location.longitude); // add location array locations.push({ latitude: lat, longitude: lng, title: location.name }); } // calls map set state this.setstate({ annotations: locations }); } and here view code <view style={styles.container}> <mapview style={styles.map} onregionchangecomplete={this._onregionc...

ubuntu - Phantom Mercurial, How to remove? -

i'm trying install tortoisehg on ubuntu 14.04. went fine, trying open complains having unsuported mercurial version (3.4.1). removed via: sudo apt-get remove mercurial sudo apt-get purge mercurial sudo dpkg -r mercurial sudo dpkg --purge mercurial it comes out successful, if try: hg --version i get: mercurial distributed scm (version 3.4.1) (see http://mercurial.selenic.com more information) copyright (c) 2005-2015 matt mackall , others free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. any other ideas? tortoisehg needs 3.1.x or 3.0.x. you can find out in path application exists using type command (when using bash): ry4an@four:~$ type -a hg hg /usr/local/bin/hg it's possible installed python package in case command be: pip uninstall mercurial but might easier/safer install version supported somewhere comes earlier in path tortoise find one.

In ASP.NET 4.5, how should I encode a string to be used as a JavaScript variable, to prevent XSS attacks -

i know of several ways this, have downside. there "accepted" way of doing it, considered best? i used use microsoft.security.application.antixss.javascriptencode() great, antixss has been end-of-lifed because encoder included in .net of 4.5. however, reason, system.web.security.antixss.antixssencoder doesn't include javascriptencode method. there's system.web.httputility.javascriptstringencode() , uses blacklist method encoding, it's unlikely whitelist encoder. and i've seen recommendations use system.web.script.serialization.javascriptserializer.serialize() , calls httputility.javascriptstringencode() . so what's best accepted, whitelist method encoding values written out js variables? if wish include javascript code within <script> block this: <script> var myvariable = '<%=thisiswrong %>'; </script> then in context httputility.javascriptstringencode should used. function correctly encodes sp...

python - Generate pairings within World Cup tournament groups -

Image
i put data 2015 fifa women's world cup: import pandas pd df = pd.dataframe({ 'team':['germany','usa','france','japan','sweden','england','brazil','canada','australia','norway','netherlands','spain', 'china','new zealand','south korea','switzerland','mexico','colombia','thailand','nigeria','ecuador','ivory coast','cameroon','costa rica'], 'group':['b','d','f','c','d','f','e','a','d','b','a','e','a','a','e','c','f','f','b','d','c','b','c','e'], 'fifascore':[2168,2158,2103,2066,2008,2001,1984,1969,1968,1933,1919,1867,1847,1832,1830,1813,1748,1692,1651,1633,14...

amazon web services - Windows EC2 initial config from AMI after autoscale boot up -

i'm looking @ autoscaling off-the-shelf amazon provided windows ami (as opposed custom one). after new instance gets booted (and before!! gets added load balancer), want initialization tasks injected , ran on new instance (say, running powershell script). secondly, loadbalancer needs know start sending requests new ec2 instance after startup script has finished (not sure how either). after new instance gets booted (and before!! gets added load balancer), want initialization tasks injected , ran on new instance (say, running powershell script). take @ userdata . long , short of can configure instances run small script when launched, can used bootstrapping. a common practice include enough code in userdata download variable script central location (e.g. git repository or secure s3 bucket), execute - way can version , change actual script doing work without having update userdata. secondly, loadbalancer needs know start sending requests new ec2 instance ...

Python C-API access String constants -

i wanted implement library have written python in c using c-api of python. in python can declare "constants" in module stating: red = "red" # not constant, know blue = "blue" # suitable, nevertheless def solve(img_h): # awesome computations return (red, blue)[some_flag] those constants later returned functions offered module. have trouble doing same thing in c. here got far: pymodinit_func pyinit_puzzler(void) { pyobject* module = pymodule_create(&module); (void) pymodule_addstringconstant(module, "blue", "blue"); (void) pymodule_addstringconstant(module, "red", "red"); return module; } pyobject* solve(pyobject* module, pyobject* file_handle) { // awesome computations based on file // involves huge amounts of memory management, efficient in c // problem: how return stringconstants here? return some_flag ? blue : red; } i have marked problematic part. af...

about drawing sinus function in gnuplot when it is pressed a keyboard -

is possible draw sinus function on interval: [-2*pi, 2*pi] in following way: when press right arrow on keyboard produce sinus function on interval: [-2*pi, -pi] when press again plot sinus function on interval [-pi, 0] .... is possible? thanks! to plot when hitting key, must use bind command, like clear bind left 'plot sin(x)' the clear opens empty plot windows, must give focus, , hit arrow-left key plot sine. now can put more logic command called in bind: clear = 0 left_lim(n) = (i%2 ? -pi : -2*pi) right_lim(n) = (i%2 ? 0 : -pi) bind left 'plot [-2*pi:2*pi][-1:1] (x < left_lim(i) || x > right_lim(i)) ? 1/0 : sin(x); = i+1' this draw sine on interval [-2*pi:-pi] @ every odd time press key, , on interval [-pi:0] @ every time press it. total xrange [-2*pi:2*pi] , yrange [-1:1]. depending on overall logic (what should happen if hit key third time?) must adapt script bit.

How to programmatically get an Image Button's width and height in Android -

im trying programmatically integer variable of image button's width , height in android. want because size of image vary depending on device. how can this? i've tried. width = image.getwidth(); height = image.getheight(); but returns zero?? bitmap deprecated in api 22+. getting size of actual image not work because distort fit needs. drawable.getintrinsicheight(); off table (yes know must declare drawable befor saying drawable.getintrinsicheight idc). i'm confused. please help! full code: package com.example.e99900004533.candycollector; //imports android, , random import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.graphics.point; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.view.display; import android.widget.edittext; import android.widget.imagebutton; import android.os.countdowntimer; import android.graphics.drawable.drawab...

rest - Laravel - What is exactly a RESTful API? -

i'm working on school project, , project name is: ... using web restful api ... so, decided write android application client-side, , server-side laravel framework (version 5). what understand when hear rest api is: get, put, delete, edit, update, index. this why have created class named apicontroller project contains it's methods communicate "exterior". an example of how think user registration should work: routes.php route::post('/register', array('uses' => 'apicontroller@postregisteruser', 'as' => 'postregisteruser')); and apicontroller : class apicontroller extends controller { public function postregisteruser() { $validator = validator::make(input::all(), array( 'email' => 'required|email|unique:users,email', 'uuid' => 'required|unique:users,uuid', 'name' => 'required|min:6' )); ...

Matlab: Help Solving a 2nd order ODE with the derivative input being a function of time -

i have been going round , round in circles trying matlab solve resonator circuit equation time varying input voltage. works fine long in arguments of derivative functions scalar values. i have gone through others questions , found answers suggesting anonymous functions or using interpolation. when try implement these suggestions, return error tells me not have enough initial conditions match output of ode function or matrices being concatenated not match.. here code: %% define parameters f0=1494.72e6; q=80; r=1; l=(q*r)/(2*pi*f0); c=1/((2*pi*f0)^2*l); tp=71e-9; n=2^16; n=(0:n-1); tt=1e-6; h=tt/n; t=n*h; start_pulse=1; end_pulse=round(tp/h); v=zeros(size(t)); %% create voltage pulse ii=1:length(n); if ii>=start_pulse && ii<=end_pulse v(ii)=sin(2*pi*f0*t(ii)); end end %% tspan=[0 tt]; x0=[0 0]; sol=ode45(@ode,tspan,x0,[],v); int=(0:h:tt); sint=deval(sol,int); plot(int,sint*c); my ode funtion following: function [ dx ] = ode( t,x,v) f0=1494...

.htaccess - Redirect all wordpress posts to a sub-directory -

i'm moving wordpress blog root http://website.com/blog . consequently need redirect links such http://www.website.com/2015/05/post-title http://www.website.com/blog/2015/05/post-title , http://www.website.com/2014/03/post-title http://www.website.com/blog/2014/03/post-title , etc. couldn't find how correctly .htaccess. try adding top of htaccess file in document root : rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^/blog rewriterule ^([0-9]{4}/[0-9]{2}/.*)$ /blog/$1 [l,r]

c# - Access to the return value from the database by linq -

i need send value database code var concerthallid = _concert in db.tbl_content_context join _concerthall in db.tbl_concert_concerthall on _concert.contextid equals _concerthall.contextid _concert.encontextid == concertid select _concerthall.concerthallid; how set concerthallid variable? your query return iqueryable, if return 1 row or need first 1 use after code: var id = concerthallid.firstordefault();

python - create variable for one tuple item at the end of a list -

i have list of tuples called list_cs : ('2015-05-14', 685) ('2015-04-15', 680) ('2015-03-20', 675) ('2015-02-11', 680) ('2015-01-13', 685) ('2014-12-10', 685) ('2014-11-25', 685) ('2014-10-09', 685) ('2014-09-15', 690) ('2014-08-21', 680) ('2014-07-22', 680) for first 5 tuples, want assign scores in second position of tuple unique variables. this: cs0 = [x[1] x in list_cs[0:1]] cs1 = [x[1] x in list_cs[1:2]] cs2 = [x[1] x in list_cs[2:3]] cs3 = [x[1] x in list_cs[3:4]] cs4 = [x[1] x in list_cs[4:5]] i want assign score in second position of last tuple unique variable. never know how long list might be; want last one. but, can't figure out how last one. i've tried of following none of them work. cs1st = [x[1] x in list_cs[-1:-0]] cs1st = [x[1] x in list_cs[-0:-1]] cs1st = [x[1] x in list_cs[:-1]] cs1st = [x[1] x in list_cs[-1]] how can this? you don't need list ...

java - JPQL query - inner join no data type for node -

i have following jpql query used select programmes featuring performer specified id. the channelprogramme entity has programme , episode there entity called progepperfassociation, featuring programmeid, performerid , episodeid. (a performer can feature in many programmes , episodes , programme/episode can feature many performers) @query("select cp channelprogramme cp" + " cp.programme.programmeid in (select programme progepperfassociation prog" + " inner join prog.performer perf" + " prog.performerid in :performerid)" + " , (cp.starttime between :fromdate , :todate)" + " order cp.starttime, cp.starttime") however getting following exception caused by: java.lang.illegalargumentexception: validation failed query method public abstract java.util.list com.tvfreakz.repository.channelprogrammerepository.findscheduledperformerprogrammes(java.lang.long,java.util.date,java.util.date)! @ org.springf...