Posts

Showing posts from May, 2013

javascript - Two animations to be performed in a single page one over the other in canvas -

actually have set of points when connected forms pipes connected horizontally , vertically. want animation pipes this var canvas1 = $("#maincanvas1")[0]; var ctx1 = canvas1.getcontext("2d"); var points = [[250,300],[250,150],[450,150],[450,50],[150,50],[150,300]]; var gradcolor = ["#1fb0ff","#0aa9ff", "#009ff5",'#0092e0', "#0085cc"]; drawconnectionpipe(ctx1,points,15,gradcolor[0],gradcolor[1], gradcolor[2],gradcolor[3], gradcolor[4]); function drawconnectionpipe(ctx,coorinatearray,thickness,gradcolorlight1, gradcolorlight2,gradmidcolor,gradcolordark1, gradcolordark2){ ctx.save(); gradcolornew = [gradcolordark2,gradcolorlight1, gradcolorlight2,gradmidcolor,gradcolordark1]; var gradientobject = null; for(var i=0; i<coorinatearray.length-1; i++){ var startpt = coorinatearray[i]; var endpt = coorinatearray[i+1]; gradientobject = ctx.createlineargradient(startpt[0],startpt[1

Can you code in the cloud? -

i developing 1 hour science fiction tv drama networks cloud-based programming. the idea hundreds of thousands of programmers working on creating virtual utopian world @ same time. in world try , solve of worlds biggest problems. it idea of group of minded individuals trying solve same problems drive heart of show , start give main character insights in real world. that until group of hackers start turn collective conscience , more sinister. idea @ least "somewhat" possible? meaning can large group of people coding @ same time in cloud on same program? think of creating code new sections of world of warcraft while playing @ same time. if code language use? hope makes sense everyone... use source code repository git or subversion , continuous integration tool jenkins, allows build right after every push repo. jenkins build , test code, , deploy virtual utopian app world if successful you can provide context cloud talking cloud technologies. use id

asp.net - (are you missing a using directive or an assembly reference?) -

i writing common business logic class in app_code folder connecting database using efw.but showing following error " error 1 type or namespace name 'job' not found" using system; using system.collections.generic; using system.linq; using system.web; using system.data; namespace webapplication6.app_code { public class blcommon { public list<job> getjobs() { pubs2012entities pubsobject = new pubs2012entities(); var x = pubsobject.jobs.tolist<job>(); return x; } } } , class generated efw jobs table namespace webapplication6.app_code { using system; using system.collections.generic; public partial class job { public short job_id { get; set; } public string job_desc { get; set; } public byte min_lvl { get; set; } public byte max_lvl { get;

html - Javascript img tag src switch function not working -

i have small app uses 3 images buttons, images different colors, above image buttons there big pair of glasses, depending on color button press color of glasses change match color of button pressed. problem getting "cannot set src null" error. here jsfiddle: http://jsfiddle.net/vaf8s/ here function //functions change glasses image function changecolor(a){ var img = document.getelementbyid("imgg"); img.src=a; } you have 2 id's tag. should have 1 id. change html. <section id="banner" > <img id="imgg" src="images/orangeg.png"><br> <img id="wcolorbutton" src="images/whitet.png" /> <img id="bcolorbutton" src="images/bluet.png" /> <img id="ocolorbutton" src="images/oranget.png" onclick="changecolor('images/whiteg.png')" /> </section> fiddle

sms - kannel to send WAP push. WARNING: PPG: pap control entity erroneous, the request unacceptable -

i trying send wap using wap=box kannel. example referring http://www.kannel.org/pipermail/users/2011-september/016716.html receiving error while substitution. not able find-out error. error on kannel is . 2014-03-06 12:00:06 [25702] [14] warning: ppg: pap control entity erroneous, request unacceptable <?xml version="1.0"?><!doctype pap public "-//wapforum//dtd pap 1.0//en" "http://www.wapforum.org/dtd/pap_1.0.dtd"><pap><badmessage-response code="2000" desc="not understood due malformed syntax" bad-message-fragment="&lt;?xml version=&quot;1.0&quot;?&gt; &lt;!doctype pap public &quot;-//wapforum//dtd pap1.0//en&quot; &quot;http://www.wapforum.org/dtd/pap_1.0.dtd&quot;&gt; &lt;pap&gt; &lt;push-message push-id=&quot;71417&quot;&gt; &lt;address address-value=&quot;wappush=+919971132145/type=plmn @ ppg.n

mysql - Search in a table based on multiple column value -

i have table, want filter data of table based on multiple column value whether type value of 1 column or more one. i using code. alter proc usp_getdata @name varchar(50)= null , @sector int =null,` `@pocket varchar(50) =null , @plot int =null , @locality varchar(50) =null select * m_details v_regname =@name , n_sector =@sector , v_pocket=@pocket , n_plotno=@plot , v_locality=@locality i want replace column value @name not null therefore result. in procedure, replace bits v_regname =@name with (@name null or v_regname = @name)

.Net user can not connect to php Webservice -

i have php webservice code : require_once('nusoap.php'); require_once('gw.interface.php'); $namespace = 'www.mydomain.com'; $server = new soap_server(); $server->soap_defencoding = 'utf-8'; $server->decode_utf8 = false; $server->encode_utf8 = true; $server->configurewsdl('smsserver', 'urn:smsserver'); $server->wsdl->addcomplextype( 'listarray', 'complextype', 'array', '', 'soap-enc:array', array(), array( array('ref'=>'soap-enc:arraytype','wsdl:arraytype'=>'xsd:string[]') ), 'xsd:string' ); /** * sendsms **/ $server->register('sendsms', array( 'fromnum' => 'xsd:string', 'tonum' => 'xsd:string', 'messagecontent' => 'xsd:string', 'messagetype' => 'xsd:string', 'user' =>

c# - How to retrieve dual batteries status? -

dim power powerstatus = systeminformation.powerstatus dim percent single = power.batterylifepercent or powerstatus power = systeminformation.powerstatus; float percent = power.batterylifepercent; (i prefer vb answer application written in can convert c# fine if dont know vb) i understand above give me battery percentage remaining - have tablet 'hot swappable' (it has main battery small 5 minute battery runs tablet while swap batteries on it) - how find status of second battery? i looking systeminformation.powerstatus(0) have no idea trying find , must having google block cannot find anything. you can use wmi , win32 battery levels. try this: objectquery query = new objectquery("select * win32_battery"); foreach (managementobject o in new managementobjectsearcher(query).get()) { uint level = (uint)o.properties["estimatedchargeremaining"].value; }

asp.net mvc - Unity does not resolve the dependency -

i use unity unity.mvc5. class registers types , dependency resolver below: public static class unityconfig { public static void registercomponents() { var container = new unitycontainer(); container .registertype<ilogger, nlogger>() .registertype<idataaccesslayer, sqldataaccesslayer>() .registertype<ieventbusiness, eventbusiness>(); dependencyresolver.setresolver(new unitydependencyresolver(container)); } } and here global.asax code: void application_start(object sender, eventargs e) { unityconfig.registercomponents(); globalconfiguration.configure(webapiconfig.register); routeconfig.registerroutes(routetable.routes); } in 1 of controllers have property this: [dependency] public ieventbusiness eventbusiness { get; set; } i expect property set automatically unity it's null. can me figure out doing wrong? thanks guys. removed unity.mvc5 , installed unity

python - Returning two values from pandas.rolling_apply -

i using pandas.rolling_apply fit data distribution , value it, need report rolling goodness of fit (specifically, p-value). i'm doing this: def func(sample): fit = genextreme.fit(sample) return genextreme.isf(0.9, *fit) def p_value(sample): fit = genextreme.fit(sample) return kstest(sample, 'genextreme', fit)[1] values = pd.rolling_apply(data, 30, func) p_values = pd.rolling_apply(data, 30, p_value) results = pd.dataframe({'values': values, 'p_value': p_values}) the problem have lot of data, , fit function expensive, don't want call twice every sample. i'd rather this: def func(sample): fit = genextreme.fit(sample) value = genextreme.isf(0.9, *fit) p_value = kstest(sample, 'genextreme', fit)[1] return {'value': value, 'p_value': p_value} results = pd.rolling_apply(data, 30, func) where results dataframe 2 columns. if try run this, exception: typeerror: float required . possi

Android: Transfer files/apps from android device to pc -

i developing android application enables user transfer files android device pc. how can transfer selected files/apps connected pc? you can use socket connection. pc server , android app client. way can send data mobile device pc. for example can refer below link http://www.javaworld.com/article/2077322/core-java/sockets-programming-in-java-a-tutorial.html this written in java can write in android.

How to enable double click event to fotorama slider to make full screen -

how enable double click event fotorama slider make full screen, seeing on right top corner you can use jquery events http://api.jquery.com/dblclick/ execute function fotorama.requestfullscreen() remember should initialize fotorama manually in header of api can see how it. here example ! http://jsfiddle.net/meickol/8dv7k/ how see easy! luck! html <base href="http://fotorama.s3.amazonaws.com/i/okonechnikov/"> <!-- fotorama --> <div class="fotorama_custom" data-width="700" data-ratio="700/467" data-max-width="100%"> <img src="1-lo.jpg"> <img src="2-lo.jpg"> <img src="9-lo.jpg"> <img src="6-lo.jpg"> <img src="5-lo.jpg"> </div> script <script> // 1. initialize fotorama manually. var $fotoramadiv = jquery('.fotorama_custom').fotorama({ click:false, allowfullscreen:true,

java - string.format throws exception in http post request and response -

i have method placing format specifiers (like %s) instead of placing hard code values, can find code bellow; string username = "nicole"; string password = "nicole"; httpclient client = new defaulthttpclient(); httppost post = new httppost("url"); string input=string.format("<soap:envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:inn=\"http:innovation/\"> <soap:header/><soap:body><inn:getcategoriesbyvendorid><!--optional:--> <username>%s</username><!--optional:--><password>%s</password></inn:getcategoriesbyvendorid> </soap:body></soap:envelope>",username,password); //stringentity input = new stringentity("<soap:envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:inn=\"http:innovation/\"> <soap:header/><soap:bo

java - How can I check if an object exists in a List by specialized comparing way? -

for example have list list<myclass> . list.contains() use object.equals() comparing, have implement method myclass.equals() correct semantic, can't modify it. is there api can use specialized comparing method/class checking except loop & check myself? the list not sorted list can't use collections.binarysearch() . you can specify custom contains() method single instance of list , during instantiation such this: list<string> list = new arraylist<string>() { @override public boolean contains(object o) { // own implementation } };

c# - Call same method both in client-side and server-side -

i have complex calculation in page , want perform in both client-side , server-side. easier maintenance, prefer write 1 function , call in client , server. so searching method call javascript function in c# code behind or else satisfy demand. thought service based function call in client ajax , in server simple function; however, obvious work in client because should go server , come back. any idea? as stated in comment, can think of 3 options have here. use ajax call result controller (server-side calculation only). use postback, pretty same option above. use javascript interpreter jint, execute same piece of javascript on server side. i think first 2 prefered, third option might solution if don't call or postback. cause client-side code calculate it's own result, while server-side able same. same code, same result, no call client-side server-side. a populair javascript interpreter .net might jint example, has proven it's stability , performan

.htaccess - Questions about a simple Python web server -

import string,cgi,time os import curdir, sep basehttpserver import basehttprequesthandler, httpserver class myhandler(basehttprequesthandler): def do_get(self): try: if self.path.endswith(".html"): f = open(curdir + sep + self.path) self.send_response(200) self.send_header('content-type','text/html') self.end_headers() self.wfile.write(f.read()) f.close() return except ioerror: self.send_error(404,'file not found: %s' % self.path) def do_post(self): global rootnode try: ctype, pdict = cgi.parse_header(self.headers.getheader('content-type')) if ctype == 'multipart/form-data': query=cgi.parse_multipart(self.rfile, pdict) self.send_response(301) self.end_headers() upfilecont

ios - MPMoviePlayerController stops playing the video after 5s -

i tried play video in ios played 5s video. code: nsbundle *bundle = [nsbundle mainbundle]; nsstring *moviepath = [bundle pathforresource:@"videoviewdemo" oftype:@"mp4"]; nsurl *movieurl = [[nsurl alloc]initfileurlwithpath:moviepath]; mpmovieplayercontroller *themoviplayer = [[mpmovieplayercontroller alloc] initwithcontenturl:movieurl]; themoviplayer.controlstyle = mpmoviecontrolstylefullscreen; themoviplayer.controlstyle = mpmoviecontrolstyledefault; [themoviplayer setmoviesourcetype:mpmoviesourcetypefile]; themoviplayer.shouldautoplay = yes; themoviplayer.view.transform = cgaffinetransformconcat(themoviplayer.view.transform, cgaffinetransformmakerotation(m_pi_2)); [themoviplayer.view setframe:self.view.frame]; [themoviplayer preparetoplay]; [self.view addsubview:themoviplayer.view]; declare ivar @property (nonatomic,strong) mpmovieplayercontroller *mymoviecontroller; assign themoviplayer follows, self.mymoviecontroller = themoviplayer; [self.v

php - How to send some images in a same folder to android and how android client can decode these datastream? -

i have implemented cbir program using android. basic framework is: take picture using android camera , upload wamp server call retrieval engine , store retrieved images (for example 10 images) in folder, named './output/' php sends result images android displaying. my question how send these images (10 more or less) android , how android receives , decodes these images. on server sider, php script looks like: <?php # ..... #function streaming file client function streamfile($location, $filename, $mimetype='application/octet-stream') { if(!file_exists($location)) { header ("http/1.0 404 not found"); return; } $size=filesize($location); $time=date('r',filemtime($location)); #html response header header('content-description: file transfer'); header("content-type: $mimetype"); header('cache-control: public, must-revalidate, max-age=0'); header('prag

javascript - How to add setCenter on Map that is controlled by Radio button inside the List that is populated by .Each Loop -

i have problem because have list populated .each loop, , in every item on list there address radio button, question how can focus or setcenter when radio button selected because tried getelementbyid focuses on last queried address. . in advance 1 me :) this set of codes function initialize() { var minzoomlevel = 4; var zooms = 7; geocoder = new google.maps.geocoder(); geocode = new google.maps.geocoder(); // used set center of maps on logged user $.getjson('/dashboard/loadaddress', function geocoding(address) { $.each(address, function () { customerlocationid = this["id"]; var currvaladdress = this["addressline1"]; var latitude = this["latitude"]; var longitude = this["longitude"]; latlang = new google.maps.latlng(latitude, longitude); var addresse = { zoom: 16, center: latlang, maptypeid: google.maps.maptypei

php - mysql order by field with NULL values last -

i have been having issue when using field function in order clause. my situation product can have 3 categories , user can choose category show first. there 3 possible queries can formed. these are: query 1 select * my_table main_categories_id = 2 order field(product_condition, 'graded', 'new', 'used'); query 2 select * my_table main_categories_id = 2 order field(product_condition, 'new', 'graded', 'used'); query 3 select * my_table main_categories_id = 2 order field(product_condition, 'used', 'new', 'graded'); this not work when product condition null because shows rows null value first. need these appear last. i have tried adding null field function doesnt seem work. does know way can achieve this? thanks help. you can either: explicitly sort first whether column nu

sql - INT field - String or binary data would be truncated -

first-time poster, long-time fan. i've looked @ other answers on topic , can't find solves problem. i have sql returns matrix of qualifications region using dynamic pivot. have code working correctly, bringing rows, want use filter. the errant code in clause: t3.trainingtypeid = ' + @trainingid + ' if hard code value t3.trainingtypeid (this alias tlkptrainingtype.id ), (200, say), 1 row returned, want if assign same value variable @trainingid int , above error message. have checked datatype of tlkptrainingtype.id , int (and select max(len(tlkptrainingtype.id)) tlkptrainingtype returns 3). i'm not sure understand triggers well, given i'm reading db, right in thinking it's not relevant here? am missing obvious? insights appreciated, i'm relative newbie! here code, relevant clause near bottom: declare @trainingid int, @cols nvarchar(max), @cols2 nvarchar(max), @cols3 nvarchar(max), @query nvarchar(max) set @cols = stuff((select distin

jquery on click event that call a named function -

i have jquery onclick handler, writed anonymous function that: $("#selector").on("click" function(){ // }) i generalize anonymous function extracting logic in named function, drive me like: $("#selector").on("click" namedfunction()) function namedfunction(){ // } to me seemed solution. there's drawback since namedfunction executed script loaded. here can test bad behaviour. just pass reference of function itself. try, $("#selector").on("click", namedfunction);

date - startdate openssl set timezone -

good morning, today have question concerning openssl. when sign certificat in openssl ca, realized needed wait amount of time before being able use certificat. at first did not understant wrong had same hour on ca , on server (used openvpn). realized when sign certificat default timezone of certificate gmt while server using cet. so thought going use startdate when generate certificate , problème solwed. when use start date '20140404000000z' , time zone still gmt while server in cet. is possible tell him use timezone of server , not gmt. server centos. any appricated. thanks according rfc 5280 defines x.509 certificate profile time fields in certificate must expressed in gmt time. see sections 4.1.2.5, 4.1.2.5.1 , 4.1.2.5.2. anyway when server verifies validity of client certificate should transform gmt time acquired certificate own timezone or vice versa. maybe clock on system issuing certificates not in sync clock on vpn server? few seconds or minu

How to handle multiple jQuery popup with selenium webdriver -

i working on java selenium webdriver 2.39, have application multiple 'processing' popup display 2-5 sec , closed automatically, depend on data. now, question how handle popup, popup jquery popup. script can work further once 3 popup gets open , process data , closed automatically. however, can not use wait time script used load testing using jmeter, hence process time may take more or less 5 sec., there way can know if popup exist or not on screen? have used below given sample code returns parent window , not identify jquery popup, using below given code can if popup exist or not, if not jquery popup. can me? public void focusonwindow() throws exception{ int i=0; { handles=driver.getwindowhandles();//get windows iterator = handles.iterator(); if(iterator.hasnext()){ subwindowhandler = iterator.next(); if(subwindowhandler==null){ i=0; }else if(subwindowhandler!=null){ if(s

haskell - Getting a <<loop>> when implementing block-visibility in a type-checker -

i'm writing simple type-checker simple imperative language, , i'm stuck kind of output: testchecker: <<loop>> i have alread read this question, know must doing wrong circular reference. i'm pretty sure problem in following function, responsible checking block of statements: checkgroup :: environ -> [prog] -> (state, environ, [string]) checkgroup env progs = (finalstate, finalenv, messages) (finalstate, finalenv, messages) = foldl checksingleprog (ok, empty, []) progs checksingleprog (s, e, msg) prog = (ress, mergeenv e e', mess) (s', e', msg') = checkprog (mergeenv' env finalenv) prog mess = msg ++ msg' ress = if s == err || s' == err err else ok note the: checkprog (mergeenv' env finalenv) prog where checkprog uses environment merging of environment of father of group plus environment generated whole group . (edit: yes know finalenv p

sql - Suggestions modelling nested data sets that change over time -

i looking suggestions on creating temporal nested data set model. trying improve performance reading sections. have node tree of ~1million nodes, frequent depths of 20+ nodes. tree stores categories can change on time, ability enter future changes. the current data structure temporal adjacent node model, modelling changes node tree on time trivial simple data structure: nodes nodeid [data] edges parentnodeid childnodeid validfromdate validtodate a nested data set makes fast read operations, current understanding of nested sets not support changes on time tree nodes nodeid left right [data] one thought had create series of "nesting maps" reflect left/right values @ given points in time, mean recreating entire node tree whenever single change-over-time modelled, make size of "nests" dataset large changes frequent. nests nodeid left right validfromdate validtodate has created temporal ne

jquery - creating an javascript object at global level -

i trying create object below var x = function x() {}; does create object @ window level/global level.is way of using ? if written in global name space.. meaning in loaded script directly or in script tag global. but if made inside, example, dom ready event or onlad event handlers wont global. using window.variable makes global if you're inside block.

mysql - Check uniqueness for multiple attributes in SQL -

i having table of form id, mid,pid . now, table id primary key. , might come across inserting same combination of mid,pid , shouldn't add them. here id needs generated , can't obtained or crawled. there mechanism in sql check uniqueness of combination . i thinking of generating id auto increment, being primary key can't here,another option thinking is, concatenate mid , pid , set them primary key. else check if data exists select command , same. these kind of defeats purpose, or least not elegant. there other methods? will creating constraint serve it? yes, adding (composite) uniqueness constraint want: alter table my_table add unique (mid, pid)

Create database postgresql using JAVA -

hello want create database postgresql using java got error message here code : try { connection c=null; statement stmt=null; class.forname("org.postgresql.driver"); c = drivermanager .getconnection("jdbc:postgresql://localhost:5432/", "postgres", "admin@2014"); c.setautocommit(false); system.out.println("opened database successfully"); stmt = c.createstatement(); string sql = "create database db owner postgres tablespace numerique; "; stmt.executeupdate(sql); stmt.close(); c.commit(); c.close(); } catch (exception ee) { system.err.println( ee.getclass().getname()+": "+ ee.getmessage() ); system.exit(0); } and here error messag

cassandra and windows phone or wpf -

im thinking of doing project uses wpf or windows phone , cassandra database hosted on azure ubuntu vm, have used cassandra jsp sites before , wpf cassandra on local database never through remote location. possible query cassandra cluster externally hosted local wpf application? im under impression need cloud service handle requests , node.js unsure how works wpf application. on local cassandra cluster use standard datastax csharp driver works well, doesn't query apart local database, changing ip address vm's address doesn't work. i got working, hadn't set cassandra.yaml file , created endpoint 9042, works perfect now.

php - How can I retry an ajax request on empty response -

i retry ajax request when response data empty json object. my ajax code following. $.ajax({ type: "post", url: "index.php?r=funding/getpaymentbutton", data: {email:benfemail,data:json.stringify(data),paymenttype:method}, async: true,//false success: function (data) { if(data.length === 0) { $(this).ajax();//retry ajax request here, if data empty console.log('err'); } else { obj = jquery.parsejson(data); // prcessing ajax request } } }); php echo json_encode(array( 'type'=>$paymenttype, 'btn'=>$this->paymentbtn, 'usd' => round($this->finalusdamount,2),) ); you can put ajax request in function , call function if respons empty. like this: function yourcall(){ $.ajax({ type: "p

c# - Force my code to use my extension method -

i'm using bitfactory logging, exposes bunch of methods this: public void logwarning(object acategory, object anobject) i've got extension method makes bit nicer our logging needs: public static void logwarning(this compositelogger logger, string message = "", params object[] parameters) which wraps common logging operations, , means can log like: logging.logwarning("something bad happened {0}. id {1}",foo,bar); but when have 1 string in params object[] , extension method won't called, instead original method chosen. apart naming method else, there way can stop happening? the rules how overloaded methods resolved 1 (or error) complex (the c# specification included visual studio gory details). but there 1 simple rule: extension methods considered if there no possible member can called. because signature of 2 objects accept 2 parameters, call 2 parameters match member. no extension methods considered possibilities. yo

Python - Getting prime numbers -

this question has answer here: fastest way list primes below n 29 answers i'm trying make program print prime numbers within argument pass it, far i've made python respond true or false if prime or not. prime = [] prime_list = [] def check_prime(user_input): x in range(2, user_input): if float(user_input) % x > 0: prime = true else: prime = false break print prime check_prime(int(raw_input("get prime numbers to: "))) here program returns if number prime or not(i think) what trying prime numbers , store them list, print them out when it's finished. i've been picking away @ program @ least week , can't figure out. please pointers only, no finished version. you have made function prints out true or false depending on whether number prime. the next step make r

java - Android WebView, how to code for device back button? -

i developing 1 app, has 2 activities. second activity has button using web view. when clicking on button going on web view when pressing on button of device app going first activity, want go again on second activity. how can implement tried many techniques. here code. public void onbackpressed (){ if (webview.isfocused() && webview.cangoback()) { webview.goback(); } else { super.onbackpressed(); } }

java - Design pattern for prioritization of graph nodes -

problem solve: give priority (int value) nodes of graph. there dag class attribute graph (of type directedgraph jgrapht library). moreover, there must different algorithms assign priorities, , must possible add new algorithms in future without modifying existing code. dag created first, , user have possibility select algorithm use (using combobox in gui). user must have possibility change algorithm @ moment. approach 1: develop interface (algorithm) algorithms, , make algorithms implement interface. in dag class, add new attribute: algorithm myalgo; each time user selects different algorithm on gui, instantiate algorithm: myalgo = new algorithmnumberx; approach 2: write prioritization task independently (not attribute of dag), use static method prioritize nodes of dag, sending dag argument , returning modified dag. which advantages has each approach? i go option 1 (as have). describing strategy pattern (a combination of both options actually). problematic thing

json - Download venues not work - Foursquare API php (search/venues) -

when try download venues foursquare venues search api (e.g. api.foursquare.com/v2/venues/search?near=newyork) return empty json. here code (php): <?php require_once("foursquareapi.class.php"); // set client key , secret $client_key = "ghxxxxxxxxxxxxxxxxxxxxxxxxx"; $client_secret = "rexxxxxxxxxxxxxxxxxxxxxx"; // load foursquare api library $foursquare = new foursquareapi($client_key,$client_secret); // prepare parameters $params = array("near"=>str_replace(' ', '', $_get['place'])); // perform request authenticated-only resource $response = $foursquare->getpublic("venues/search",$params); $venues = json_decode($response); echo $venues; ?> $venues empty don't understand why.. suggestion? ps. $_get['place'] = "newyork" , here work (developer.foursquare.com/docs/explore#req=venues/search%3fnear

python: Selenium webdriver and hanging proxy issue -

i trying understand how handle cases when calls perfomed through proxies hanging. example have code: def call_with_proxy(ip, port): profile = firefoxprofile() profile.set_preference('network.proxy.type', 1) profile.set_preference('network.proxy.socks', ip) profile.set_preference('network.proxy.socks_port', port) profile.update_preferences() driver= webdriver.firefox(profile) driver.get("http://somewebsite.com") the proxy taken free proxies list here https://hidemyass.com/proxy-list/ some times everythig works , getting page requesting. getting blank firefox page (where can see elements of website being loaded, e.g. css), , process lasts long time. e.g. session not being closed after 10 minutes of such waiting time. want ask if there way, automatically close browser if example page not loading time, or example test performing stopped execution (due reason related proxies) in java have: webdriver.manag

authentication - Authorization and fetching data from api in ruby -

i trying hit api fetch values, api prompts me authentication shoud provide username , password. if try other apis, able data. wondering how authentication. pretty new ruby , how doing: require 'open-uri' require 'json' result = json.parse(open("http://api.geonames.org/searchjson?q=london&maxrows=10&username=demo").read) puts "#{result}" i'm not familiar service, can try basic authentication result = json.parse(open("http://username:password@api.geonames.org/searchjson?q=london&maxrows=10&username=demo").read) as @slicedpan suggested, can use open s options arguments : result = json.parse(open("http://api.geonames.org/searchjson?q=london&maxrows=10&username=demo", :http_basic_authentication=>['user', 'password']).read) if ssl errors, @ blog post : errors --- have seen 1 of these error messages? openssl::ssl::sslerror: ssl_connect returned=1 errno=0 sta

Hide Join if string.IsNullOrEmpty using Linq -

i got linq query searches selected values in database using dropdowns. is there way hide "join" in linq query if ddlcategory null? want because result of search shows duplicated-rows because documents can have many categories.?? hope understand mean.. can help?? var documents = d in data.tbldocuments join sc in data.tblsubcategories on d.docid equals sc.docid orderby d.docyear descending (string.isnullorempty(person) || d.docperson.equals(person)) && (string.isnullorempty(year) || d.docyear.equals(year)) && (string.isnullorempty(law) || d.doclaw.equals(law)) && (string.isnullorempty(court) || d.doccourt.equals(court)) && (string.isnullorempty(category) || sc.categoryid.equals(category)) && (string.isnullorempty(casenr) || d.docnr.equals(casenr)) select d; use lambda syntax:

scope - Global error message in php -

i have problem understanding of variable scopes. i've got huge .php file many $_post validations (i know isn't not practise). anyways want little html-part above code outputs error message. message want change in every $_post validation function. example: if($err) { echo '<div class="error-message">'.$err.'</div>'; } now functions following in same file. if(isset($_post['test']) { $err = 'error!'; } if(isset($_post['test2'] { $err = 'error 2!'; } but doesn't work. think there's huge missunderstanding , i'm ashamed. can me? i didnt catch question maybe answer: <body> <p id="error_message"> <?php if(isset($err)){echo $err;} ?> </p> </body> and suggest learn how work sessions . , should know $_post empty on each refresh or f5

c# - Linq to entities hard code list -

this view model public class procurementdisplaydata { public string key { get; set;} public string value { get; set;} } how can hard code list. syntax inside query var query = (from u in context.jobs join q in context.quotations on u.quotationid equals q.quotationid join v in context.vessels on q.vesselid equals v.vesselid join c in context.customers on q.customerid equals c.customerid u.jobno == jobno select new list<procurementdisplaydata> { new { key = "a" ,value=u.jobno}, new { key = "b" ,value=u.vessel} }).tolist(); return query; get jobno , vessel database. create lists in memory: var query = u in context.jobs join q in context.quotations on u.quotationid equals q.q

javascript - Trigger function from object using dynamic key -

i'm struggling on triggering function defined in object, pointing using dynamic key. code looks this: $(function(){ var events = { test : function(){ console.log ('init'); } } $('#trigger').click(function(){ var e = $(this).data('event'); events[e]; }); }); so basically, there element #trigger attribute data-event="test" (or else), once gets clicked check events object if there function defined trigger , fire it. however, doesn't work way. can console log events object function isn't executed. doing wrong? thanks! invoke function () $('#trigger').click(function(){ var e = $(this).data('event'); events[e](); // ^^this }); demo

javascript - There is something wrong with my if statement as when I press play, subtitles play with the video but when i press pause, subtitles don't stop -

here main javascript code have: var hour = parseint(js_arr[j].substring(0,1)); var min = parseint(js_arr[j].substring(3,4)); var seconds = parseint(js_arr[j].substring(6,7)); var mil_sec = parseint(js_arr[j].substring(9,11)); var time = (hour*3600000)+(min*60000)+(seconds*1000)+mil_sec; var bool = false; var =0; function timeout(status){ settimeout(function() { if(status) { document.getelementbyid('subs').innerhtml = js_arr[i]; i=i+4; j=j+4; hour = parseint(js_arr[j].substring(0,1)); min = parseint(js_arr[j].substring(3,4)); seconds = parseint(js_arr[j].substring(6,7)); mil_sec = parseint(js_arr[j].substring(9,11)); time = (hour*3600000)+(min*60000)+(seconds*1000)+mil_sec; timeout(status); } else{ timeout(status);