Posts

Showing posts from August, 2014

python - Creating dataframe from json not always working -

i'm trying run code create data frame json link. sometimes, code run. other times, error message (below). i'm not sure why occurs, though code same. import requests import json url = "http://stats.nba.com/stats/leaguedashplayerstats?college=&conference=&country=&datefrom=&dateto=&division=&draftpick=&draftyear=&gamescope=&gamesegment=&height=&lastngames=0&leagueid=00&location=&measuretype=advanced&month=0&opponentteamid=0&outcome=&poround=0&paceadjust=n&permode=totals&period=0&playerexperience=&playerposition=&plusminus=n&rank=n&season=2016-17&seasonsegment=&seasontype=regular+season&shotclockrange=&starterbench=&teamid=0&vsconference=&vsdivision=&weight=" jd = requests.get(url).json() df = [] item in requests.get(url).json()['resultsets']: print("got here") row_df = [] row in item['rowset...

android - Libgdx for loop lag -

i have problems game. game runs ok until time have reposition objects, happens every frame. example here have reposition parked cars (around 6 cars on each side of road), cars moving down in screen, reset , reposition @ top again. have used poolable save resources. however, game still jumpy when comes running these lines of code. there way improve code prevent lag? maybe new thread? if how right way of creating new thread , updating every frame. private void updateparkedvehicles(float delta){ (int = 0; < parkedcarleft1array.size; i++){ parkedcarleft1array.get(i).update(delta); (int c = 0; c < parkedcarleft1array.size; c++){ if (c != i){ if (intersector.overlaps(parkedcarleft1array.get(i).bounds, parkedcarleft1array.get(c).bounds)){ parkedcarleft1array.get(i).reset(); } } } } (int = 0; < parkedcarright1array.size; i++){ parkedcarright1array.get(i).up...

animation - React Native: Creating an Animated View that slides directly with finger drag -

desired effect: i want create basic animation of smooth sliding view (left or right) in sync drag pace of finger.(e.g. sliding off- canvas menu , out of view) currently i'm using animated.spring in parent component handles gestures. i'm using transform , translatex in child component slide view left or right. for example: root.js(parent component handles gestures) _handlepanrespondermove(e: object, gesturestate: object) { let dx = gesturestate.movex - this.state.swipestart; animated.spring( this.state.slidevalue, { tovalue: newvalue, velocity: gesturestate.vx, tension: 2, friction: 8, }).start(); } navigation.js(child component slides) render(){ <animated.view style={[styles.navigation,{transform: [{translatex: this.props.slidevalue}]}]}> <view > </view> </animated.view> } the problem: there sticky/lagging behavior animation instead of smooth movement p...

java - Find No of divisor -

Image
i have 1 programming question asking find count of numbers between (1 , x) divisible 2 , factor of 2 + 3 , factor of 3 + 5 , factor of 5. i solved , algo below- total count of nos between 1 , x= sum of ( no of factor of x '2 , factor of 2'=x/2 no of factor of x '3 , factor of 3'=x/3 no of factor of x '5 , factor of 5'=x/5) -common number now problem here how common numbers included in above calculation. example have find count of no between 1 , 30 divisible above 3 , factor of them then for 2 numbers ->2,4,6,....30 3 numbers ->3,6,9...30 5 numbers ->5,10,15...30 see here have counted 30 in each case have remove count how big x value please help let's consider numbers 1 x set. set can divided subsets: divisible 2, 3, 5 , none of them. sets intersect. approach good, needs changed. should count how many numbers count 2 , 3 @ same time, 2 , 5 etc. when you'll assure can fill diagram numbers, you're ready code. f...

.net - Token Based Authentication using ASP.NET Web API 2 and Owin throws 401 unautorized -

i have create oauth authentication using guide taiseer joudeh . have created endpoint /token make authentication. works , revice result this. { "access_token": "dhbvpjshuois6k8ndsxfroptq63qlww_7bifl0lozixhznngld0qcu-x4q4qa7xwhhiqeqbbk6gyu_hliyfubsfmsdxwqloqayabjhnnsnjpmmhnadb-kcqznpqy7-waaqkmcvh1hpqx4l30sxlx0l8mbjtrtkx9-jxhawdpapqya9lu4ai2-z5-zxxorifdl-svxrunbtdqmnrxoh_oeyclungzw-is543ttj0bysq", "token_type": "bearer", "expires_in": 86399 } but if use access token in header of next call of enpoint has authorizeattribute alwayse recive unauthorized error. if take in in currentprincipal of current thread it's genericprincipal. my startup class looks (looks similar in guide) public class startup { public void configuration(iappbuilder app) { httpconfiguration config = new httpconfiguration(); icontainer container = autofacconfig.register(config, app); configur...

javascript - jQuery: Detect iFrame not loaded after X sections -

i'm loading iframe in modal window domain, frame not load, or takes 20+ seconds load. here code: html: <div id="mask"> <div id="iframe_lightbox"> <div id="iframe_container"><iframe id="patterncooleriframe" style="width: 100%; height: 100%;" src="" frameborder="0" ></iframe></div> <div id="iframe_lightbox_close">x</div> </div> </div> js: function launch_iframe(iframesrc, iframeid){ $("#mask").fadeto('500', 1, function () { $('<iframe>', { src: iframesrc, id: 'iframeid', frameborder: 0, scrolling: 'no', width: '100%', height: iframeh+'px' }).appendto('#iframe_container'); }); } how can detect if content has not loaded in iframe after x seconds?...

php - Check that an input date is set without a submit button? -

Image
is possible check input type date set without submit button. i.e if done through mobile browser there set button when first click on date input field there way check "set" button clicked , desktop view calendar when user clicks on date same button, there way check has been clicked without submit button? image example: normally check using submit button, this: if (isset($_get['date'])){ $date = $_post['datevalue']; if (empty($date)) { //if date not set... } else{ //if date set... } } thanks guys, been struggling while now. why not let html handle it? <input type ="date" required> forms wont submit unless input type required attribute not empty

IIS URL Rewrite to a controller? -

i trying url rewriting in iis work way , new having bit of trouble. i have simple mvc framework , want requests handled controller (obviously) if request comes in mydomain.net/users/profile/id/22/groupid/2 want hit /controller/users/profile/id/22/groupid/2 controller know handling user , profile action. is possible? do need separate rule each route (users, customers, orders etc)? i had more complex solution using 404 page , including controller passing info ran problems since 404 stripped post variables. plus think url rewrite better solution, don't know how it.

php - WordPress image editor broken when using S3 Offload Lite plugin -

Image
i'm using wp offload s3 lite plugin on wordpress site. uploading , creating thumbnails seems work fine, when try edit image using wp's built-in image editor, displays broken image: how can fix error? my nginx error log shows: 2016/11/05 16:10:44 [error] 6767#0: *164466 fastcgi sent in stderr: "php message: wpos3: there error attempting download file store/2016/11/forests-why-matter_63516847.jpg s3: local directory /home/avishai/apps/myapp/releases/20161105032906/public/wp-content/uploads/2016/11 not exist , not created. php message: wpos3: file /home/avishai/apps/myapp/releases/20161105032906/public/wp-content/uploads/2016/11/forests-why-matter_63516847.jpg not exist" while reading response header upstream, client: 108.162.219.242, server: example.com, request: "post /wp-admin/admin-ajax.php http/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "example.com", referrer: "http://example.com/wp-admin/tools.p...

add string to given command line argument in C -

hello started programm in c , trying read file , give file name argument without ending .txt . want add .txt in code : ./myexample.exe file if use file.txt there no problem dont know how change argv[1] tried char *n = argv[1] + ".txt"; doesnt works , dont know else.. int main(int argc, char* argv[]) { char *n = argv[1] +".txt"; file *fp1; fp1 = fopen(n , "r"); thats if use char *n = argv[1]+".txt" error: invalid operands binary + (have 'char *' , 'char *') you can't concatenate strings +. use strcpy , strcat: char n[256]; strcpy(n, argv[1]); strcat(n, ".txt"); make sure n large enough hold filename + extension.

java - GWT better a single service with all methods inside or more services -

this project stackoverflow. must write project in gwt , know if it's better use single service (like greetingservice) , put methods inside it, user registration, user login, user post question, user answare. or it's better use service group...one service manage user, 1 service manage question , answere , 1 service manage categories of questions. and if divide more services can communicate wichothers or need "superservice" manage everything? this not answer you're looking for, wanted notice command pattern . original presentation https://www.youtube.com/watch?v=pduhr18-edm&t=9m45s . pattern had great impact on model of client-server interaction in projects , away 1 service per module.

r - Moving average over 5 years with irregular dates -

i have large number of files (~1200) each contains large timeserie data height of groundwater. starting date , length of serie different each file. there can large data gaps between dates, example (small part of such file): date height (cm) 14-1-1980 7659 28-1-1980 7632 14-2-1980 7661 14-3-1980 7638 28-3-1980 7642 14-4-1980 7652 25-4-1980 7646 14-5-1980 7635 29-5-1980 7622 13-6-1980 7606 27-6-1980 7598 14-7-1980 7654 28-7-1980 7654 14-8-1980 7627 28-8-1980 7600 12-9-1980 7617 14-10-1980 7596 28-10-1980 7601 14-11-1980 7592 28-11-1980 7614 11-12-1980 7650 29-12-1980 7670 14-1-1981 7698 28-1-1981 7700 13-2-1981 7694 17-3-1981 7740 30-3-1981 7683 14-4-1981 7692 14-5-1981 7682 15-6-1981 7696 17-7-1981 7706 28-7-1981 7699 28-8-1981 7686 30-9-1981 7678 17-11-1981 7723 11-12-1981 7803 18-2-1982 7757 16-3-1982 7773 13-5-1982 7753 11-6-1982 7740 14-7-1982 7731 15-8-1982 7739 14-9-1982 7722 14-10-1982 779...

html - Form submission on different network -

i've created webpage form has action pointing url accessible machine form resides. is there way can submit form client machine separate server, cannot access action url? i cannot install php or other software on backend. i not have access source code of file called upon action, .py file.

javascript - Bend SVG `<g>` around Curve -

Image
i'm using d3.js draw svg <path> s in straight line. of these elements contained in <g> same vertical transformation. i'd "wrap" these elements around circular arc. @ end, each rectangle should become small segment of arc, , vertical lines point center of circle. i realize in arc beginning: drawing thick circle segments end-to-end instead of rectangles, example. this, however, sounds lot of math , calculation, new svg. is there way transform these elements onto curve post hoc , meaning use code have draws these rectangles—maybe changing transform attribute? if there's external svg library (though i've looked no success), i'd consider using that. easier using path arc command a —though not quite hoping in can't morph elements arranged in line around circle—i found d3.arc() (formerly d3.svg.arc() ). canvas.selectall(".xcontainer") .selectall("path") .data(...) .enter() .append(...

redirect - Apache directory trailing slash issue behind https -

i run apache server behind https portal , have issue directory redirection. apache server docker container receives requests forwarded https portal container (steveltn/https-portal). works fine, except default http redirections made http instead of https. instance, let have directory named test in apache website. calling https://example.com/test returns 301 code redirection http://example.com/test/ . right behaviour have redirection https. i first thought misconfiguration of https portal, , asked steveltn/https-portal team. replied it's problem in apache configuration ( https://github.com/steveltn/https-portal/issues/67#issuecomment-257934618 ). summary of answer portal tell apache existence request header x-forwarded-proto: https. web apps recognize header automatically, such wordpress. guess configure web app recognize header i tried lot of configuration found on internet instance one, none fixes problem: <virtualhost *:80> serveradmin webmaster@l...

batch file - Correct syntax of the variable "Set" for program execution and error log -

i creating unattended batch file programs have problems correct detection of variable run properly. set installjava=java\jre-8u111-windows-i586.exe /s auto_update=0 web_analytics=0 reboot=0 sponsors=0 removeoutofdatejres=1 || echo "%time% java install did not complete." >> "%temp%\error.txt" what syntax should used run installation file , error log program? you use: set "installjava=java\jre-8u111-windows-i586.exe /s auto_update=0 web_analytics=0 reboot=0 sponsors=0 removeoutofdatejres=1 || echo %time% java install did not complete.>> "%temp%\error.txt"" the environment variable installjava must referenced immediate expansion, i.e. %installjava% work command line execution. see answer on why no string output 'echo %var%' after using 'set var = text' on command line? why using syntax set "variable=value" necessary here because of operators || , >> interpreted literal characte...

(JAVA) Checking whether input string contains a certain word (definite) and removing it -

this question has answer here: remove last chars of java string variable 6 answers let's have input string of 6 characters followed word "hello" abcdefhello or set of data quernwegngweghello i mean, word "hello" @ end. how can remove word if possible? the string dynamic in number, meaning change accordingly check whether word contains "hello" in last 5 characters , remove them if possible. private static string striphellofromend(string input) { if (input.endswith("hello")) { return input.substring(0, input.length() - "hello".length()); } return input; }

asp.net - Removed all .NET Users rules in IIS by Accident -

i accidentally removed .net users in iis , can't access site or add user access rules. need able add user access again. error when accessing .net users in iis

json - Unable to update table in Advanced Data Persistence mode -

i have issue related database. working gupshup bot programming. there 2 different data persistence modes can read here , here . in advanced data persistence, following code documeneted put data data base function messagehandler(context, event) { if(event.message=='update bug - 1452') { jiraupdate(context); } } function jiraupdate(context){ //connect jira , check latest update , values if(true){ context.simpledb.doput("1452" ,"{\"status\":\"qa pending\",\"lastupdated\":\"06\/05\/2016\",\"username\":\"john\",\"comment\":\"dependent on builds team provide right build\"}"); } else{ context.sendresponse('no new updates'); } } function dbputhandler(context, event) { context.sendresponse("new update in bug, type in bug id see update"); } if want change 1 of column (say status or last up...

jquery - AJAX POST with CORS to API Gateway does not work, although can POST with CURL -

so trying submit data api endpoint using $.ajax() call. have verified can post using curl command, in format of following: curl -x post -h "content-type: application/json" -d "{\"uname\":\"myusername2\",\"emailaddr\":\"user2@ex.com\"}" <url api endpoint> that curl command returns empty json response (looks {} ), , data gets put db (which configured api gateway endpoint do). however, when try using $.ajax() command, programmed fire on button being clicked after form data filled out, can't work. var obj = new object(); obj.uname = $uname; obj.emailaddr = $email; var stringedobj = json.stringify(obj); alert("stringified: " + stringedobj); $.ajax({ url: '<same url in curl>', type: 'post', contenttype: 'application/json', datatype: 'json', data: json.stringify(obj), success: function(data)...

SQL Server: How to join this two tables? -

could me? trying join these 2 tables table producto : +-------------+-------------+-------------------------------------------+----------------------+----------+-------+------------+-------+------------------------+----------+-------+-------+-------------------------------------------+----------------------+------------+-------+----------+----------+--------+--------+---------------+----------+------------+------------+---------------+---------------+--------+--------+------------------+---------+---------------+--------+------------+----------+------------+----------+-------------+------------+-------------------+-------------------+ | id_sucursal | id_producto | clave_eq_sisco | num_serie | no_parte | oem | cod_barras | marca | modelo | original | linea | nuevo | descr_larga | descr_corta | existencia | costo | impuesto | utilidad | precio | oferta | precio_oferta | cantidad | f_in...

Migrating from Joomla to Wordpress advice -

this first time migrating website joomla wordpress. website: www.sfspas.com 1- worried website not transfer or loose functionalities. can duplicate code , transfer version wordpress? (keeping website live via joomla , creating in parallel new website www.sfpsas222.com in wordpress test things out?) the website has live 24h/7 , can't break. how can make sure inventory uploaded correctly , website looks now? 2- once transferred. if want change appearance of index.php can upload newly designed index page on wordpress? how can go it? suggestions highly appreciated! thanks! i transferred 1 of sites joomla wordpress , can say, it's not one-click action. both frameworks have own structure, can't transfer content , users directly. in short, transfer need create simple plugin take require info joomla (articles, users, etc.) , inject wordpress database, converting prior that, if necessary. and no, can not on 24/7 running site. don't think it. duplicate s...

c# - Group by variable integer range using Linq -

i'm trying group set of data based on range of integer, range not increase @ fixed interval. e.g. have item id price 1          10 2          30 3          50 4          120 i group items price 0 - 10, 11- 100, , 100-500. item 1 in group a, item 2,3, in group b, item 4 in group c. the closest can come items group items (items.price / 10 ) then join groups different ranges. any ideas? thanks! jenny parameterizing list of range ceilings... var ceilings = new[] { 10, 100, 500 }; var groupings = items.groupby(item => ceilings.first(ceiling => ceiling >= item));

javascript - What does this JS snippet do? `"development" !== 'production'` -

it's on react.js file : if ("development" !== 'production') { var typeofspec = typeof spec; var ismixinvalid = typeofspec === 'object' && spec !== null; "development" !== 'production' ? warning(ismixinvalid, '%s: you\'re attempting include mixin either null ' + 'or not object. check mixins included component, ' + 'as mixins include themselves. ' + 'expected object got %s.', constructor.displayname || 'reactclass', spec === null ? null : typeofspec) : void 0; } when ever false? in way useful? autogenerated?

html - Put an image on the right side of the page -

so have webpage in html , css, , have contact page. have image want put on right side of page, if do: float: right; doesn't seem work. tried align apparently thing close text-align . if needed, here code (html): cherryplaysroblox </head> <body> <div class="outer"> <ul> <li><a href="home.html">home</a></li> <li><a href="about.html">about</a></li> <li><a href="gallery.html">gallery</a></li> <li><a href="contact.html">contact</a></li> <p id="cherry">cherryplaysroblox1</p> </ul> <div class="jumbotron"> <h1>contact</h1> <h4>here few ways can contact me. update page when change anything.</h4> </div> </div> <!-- email --> <img src="_gmail.png" alt=...

go - How to write log into .log files in golang? -

i'am new use go language, still learn , need help. how can write application logs in go language ".log" files similiar php phalcon framework ? i have searching google , go language tutorials, there no simple understanding example. have try example logs text doesn't write continously. here's example used learn logging log, , think it's completly wrong. package main import ( "bufio" "fmt" "io/ioutil" "os" "time" ) func check(e error) { if e != nil { panic(e) } } func main() { := time.now() dt := now.format("2006-01-02") dt2 := now.format("2006-01-02 15:04:05") // start, here's how dump string (or // bytes) file. d1 := []byte("hello\ngo11\n" + dt2) err := ioutil.writefile("/users/my/documents/work/src/logs/log-"+dt+".log", d1, 0644) check(err) // more granular writes, open ...

c - Threads are created, then all exit before critical region -

i need write program class creates 8 threads. 4 producer, , 4 consumer. producers need loop, , randomly send sigusr1 or sigusr2 consumer threads. 2 should register if have received sigusr1 , other 2 register sigusr2. when try run threads created, "prod ready" printed 4 producer threads,"waiting 1" printed both threads, "waiting 2" printed 3 times threads exit. @ end of debugging says process exits normally. i need use semaphores control critical regions. great. #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <semaphore.h> #include <signal.h> #define np 4 #define nc1 2 #define nc2 2 #define cnt 10 void handler1(int signum); void handler2(int signum); typedef struct { int sent; int received; int buf[1]; int sig1; int sig2; sem_t con; sem_t prod; } sbuf_t; sbuf_t buff; void *producer() ...

php - Storing database value into variable -

my table category has these columns: idcategory categorysubject users_idusers i have form simple radio buttons , textbox. have select statement category , need idcategory stored variable ($getcatid) can use statement: $sql="insert topic(subject, topicdate, users_idusers, category_idcategory, category_users_idusers) values('($_post[topic])', '$date', '$_session[userid]', '$getcatid', '$_session[userid]');"; what best way , store categoryid? if($_server['request_method'] != 'post') //show form if not posted { $sql = "select * category;"; $result = mysqli_query($conn,$sql); ?> <form method="post" action="createtopic.php"> choose category: </br> </br> <?php while ($row = mysqli_fetch_assoc($result)) { echo "<div class= 'choice'><input type=...

osx - Metal normal doesn't interpolate -

i've been learning how metal works using swift , targeting macos. thing's have been going okay, now, close getting stuff done, i've hit problem cannot possibly understand ... hope guys me :) i'm loading , displaying obj teapot, i'm lighting using ambiant+diffuse+specular light. lighting in works well, problem : normal vector not interpolated when going fragment shader, results in having flat lighting on supposedly curved surface ... not ... i don't understand why normal not interpolated while other values (position + eye) ... here shader , image show result : thanks in advance :) struct vertex { float4 position; float4 normal; }; struct projectedvertex { float4 position [[position]]; float3 eye; float3 normal; }; vertex projectedvertex vertex_project(device vertex *vertices [[buffer(0)]], constant uniforms &uniforms [[buffer(1)]], uint vid [[vertex_i...

ios - Using Autolayout Constraints programmatically to center a UIImageView inside a UIView Swift 2.3 iOS10 -

Image
i have added uiview table cell through storyboard following constraints: then have following code programmatically add uiimageview uiview above , size according orientation of screen. //use half screen size width when on iphone , on landscape let image: uiimage = uiimage(named: header_image_bath)! imageview = uiimageview(image: image) imageview!.frame = cgrectmake(0 , 0, self.view.frame.width / 2, 185) imageview!.contentmode = .scaleaspectfit //center image let centerxconst = nslayoutconstraint(item: imageview!, attribute: .centerx, relatedby: .equal, toitem: imagewrapperview, attribute: .centerx, multiplier: 1, constant: 1) let centeryconst = nslayoutconstraint(item: imageview!, attribute: .centery, relatedby: .equal, toitem: imagewrapperview, attribute: .centery, multiplier: 1, constant: 1) nslayoutconstraint.activateconstraints([centerxconst, centeryconst]) ...

python 2.7 - Get URL file property from a Windows internet shortcut (.url) file -

i want retrieve url property of windows internet shortcut (.url) file. example, there youtube trailer "rogue one: star wars story trailer (2016)" @ https://www.youtube.com/watch?v=ze2kpozx_ku . if url dragged chrome browser windows desktop file "rogue one- star wars story trailer (2016) - youtube.url" created. in windows 10 can @ file's property (e.g. right click , select 'property'), select 'web document' tab, , in url field there " https://www.youtube.com/watch?v=ze2kpozx_ku ". how url programmtically in python 2.7? i chasing problem wrong way! thought needed extract file information. using philip's suggestion printed contents , saw url inside. example, dragging movie's url c:\temp , running following got url: filename = 'c:\temp\rogue one- star wars story trailer (2016) - youtube.url' open(filename, "r") infile: line in infile: if (line.startswith('url')): ...

How does a computer store, sort and process the events during a simulation implemented with with Simpy? -

i'm facing synchronization problem in simpy. that, mean events not processed computer in order to. have been looking lot more information in simpy documentation how events queued, sorted , processed computer. found everywhere sorted respect time have triggered at. before reading remaining, have links or document advise me? more specifically, trying model , simulate real world systems (an instance of poolsystem class), pool of subsystems can either further broken down sub-subsystems or capable of failing (this last category of system called atomicsystem). sum up, poolsystem made of subsystems can either poolsystem or atomicsystem. for instance, car instance of poolsystem class, engine subsystem. engine can broken down several other subsystems such piston or sparking plug, can fail. in case, engine defined poolsystem instance , piston , sparking plug atomicsystem instances. the atomicsystem , poolsystem classes based on same standard model. both have: a "critical...