Posts

Showing posts from May, 2014

android - Flickr API Signing Requests getting "oauth_problem=signature_invalid" -

i trying improve on api connections , figure give flickr go. getting error "oauth_problem=signature_invalid" , not entirely sure error is. think error be; flickr requires utf-8 encoded , using base64 , not entirely sure how utf-8 encoded if issue. possibility "oauth_callback" adding example because not have website. if have , give me feedback on causing "signature_invalid". https://www.flickr.com/services/api/ the flickr api expects data utf-8 encoded. results flickr example: have base string looks following: get&https%3a%2f%2fwww.flickr.com%2fservices%2foauth%2frequest_token&oauth_callback%3dhttp%253a%252f%252fwww.example.com%26oauth_consumer_key%3d653e7a6ecc1d528c516cc8f92cf98611%26oauth_nonce%3d95613465%26oauth_signature_method%3dhmac-sha1%26oauth_timestamp%3d1305586162%26oauth_version%3d1.0 what getting: get&https%3a%2f%2fwww.flickr.com%2fservices%2foauth%2frequest_token&oauth_callback%3dhttp%253a%252f%252...

scala - Does this code take full advantage of Spark's distributed computing and functional programming paradigms -

i have array of n tuples: (key, data). both custom defined objects. in each data object, have string field query. if there query, string not equal default value "". what want proportion of array has valid queries. this code have right now: val proportion = (inputarr map {case (key, data) => data map (d => if (d.query != "") 1 else 0) sum } sum) / inputarr.length is optimal code is there better way of accomplishing want do? also, know spark automatically parallelizes reduce, ide suggested replace reduce (_ + _) sum, still automatically distributed , computed, right? also, i'm new functional approach, please let me know if i'm doing inefficiently. updated: val betterproportion = (inputarr count { case (key, listdatas) => (listdatas count (data => data.query != "")) > 0 }) / inputarr.length is better code? updated: val betterproportion = (inputs filter { case (key, listdatas) => (listdatas count (data =...

python - Move Flask-Restplus Swagger API Docs -

i'm trying use flask-restplus build restful api in python. i'd have swagger docs located in different place normal "/". i'm following documentation here , have followed instructions. i'm using python2.7.3 , have following code ~/dev/test/app.py : from flask import flask flask.ext.restplus import api, apidoc app = flask(__name__) api = api(app, ui=false) @api.route('/doc/', endpoint='doc') def swagger_ui(): return apidoc.ui_for(api) app.register_blueprint(apidoc.apidoc) when try run python app.py get: traceback (most recent call last): file "app.py", line 7 in <module> @api.route('/doc/', endpoint='doc') file "/home/logan/.virtualenvs/test/lib/python2.7/site-packages/flask_restplus/api.py", line 191, in wrapper self.add_resources(cls, *urls, **kwargs) file "/home/logan/.virtualenvs/test/lib/python2.7/site-packages/flask_restplus/api.py", line 175, in add_resou...

java - Failed to create WebSocket connection when Spring Security is on -

im using java websocket client subscribe spring-boot based server application. worked fine, after adding support spring security in order authenticate , authorize users, websocket java client stopped working. im getting following errors (post request failed 405 not allowed error) 19:56:49.813 [main] info o.s.s.c.threadpooltaskscheduler - initializing executorservice 19:56:49.819 [main] debug stompwebsockettestclient - connecting , subscribing 1 users 19:56:49.886 [main] debug o.s.w.s.s.c.resttemplatexhrtransport - executing sockjs info request, url=http:<//>localhost:9090/hello/info 19:56:49.923 [main] debug o.s.web.client.resttemplate - created request "http:<//>localhost:9090/hello/info" 19:56:49.941 [main] debug o.s.web.client.resttemplate - request "http:<//>localhost:9090/hello/info" resulted in 200 (ok) 19:56:49.974 [main] debug o.s.w.s.s.client.websockettransport - starting websocket session url=ws:<//>localhost:9090/hello/91...

ios - How do I properly add a button to my scene using only code? -

working off of other stack overflow answers have managed come code below. (in homescreen.m file) uibutton *gcbutton; -(id)initwithsize:(cgsize)size { if (self = [super initwithsize:size]) { //add button [self addgamecenterbutton]; } return self; } -(void)addgamecenterbutton { gcbutton = [[uibutton alloc]initwithframe:cgrectmake(50, 20, 30, 30)]; [gcbutton setbackgroundcolor:[uicolor orangecolor]]; [gcbutton settitle: @"my button" forstate:uicontrolstatenormal]; [gcbutton settitlecolor: [uicolor bluecolor] forstate:uicontrolstatenormal]; [gcbutton.layer setborderwidth:1.0f]; [gcbutton.layer setbordercolor:[uicolor bluecolor].cgcolor]; //adding action programatically [gcbutton addtarget:self action:@selector(buttonclicked:) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview:gcbutton]; } -(void)buttonclicked:(uibutton*)sender { nslog(@"you clicked...

angularjs - how to fit button to jquery-ui slider -

Image
i want add function jquery-ui slider. when click space of slider, want trigger function. when click space of slider, set nearest handler. added button slider. when add new handler, add new button on top of slider. problem how set width , left of button make clickable. jsfiddle here: http://jsfiddle.net/5ycu91hj/ the picture here: what want implement click different space between handlers can trigger different functions. <button style="left:10% width: 20%;height:inherit;position:absolute"></button> i'm not sure whether there're better solution this. checked jquery-ui api didn't see click function can use. not sure you're asking, here's attempted answer: to call function on click, can use onclick() event. <button style="left:10% width:20%; height:inherit; position:absolute" onclick="myfunction()"></button> then can pass arguments function position of mouse , value(s) of sliders ...

html - Requesting multiple partials with link tag in Rails -

i have list of users has conversation , progress of own. when click user on list, want request , render both conversation , progress partials of user. <% @patients.each |patient| %> <tr> <td> <%= image_tag("doctor/avatar.png", :alt => "user", :style => 'width: 40px', class: "img-responsive") %> </td> <td> <%= link_to patient.name, conversation_path(patient.conversation.id), :remote => true, class: 'grp', :style => "font-weight:bold; color:#000" %> </td> </tr> by link_to tag, able render conversation partial. // show.js.erb conversation $("#chats").html("<%= escape_javascript render(@conversation) %>"); however, don't know how request conversation , progress @ same time. can make multiple request link_to tag?

javascript - Multiple CSS Animation alignment Issue -

i have been trying trigger 2 animations placed @ 2 different places simultaneously move them away each other via javascript - {{id}}.classname . animation begins, second element id - p2 displaces automatically original position before animation starts. here codepen link. , yeah, i'm using bootstrap this. can me out? updated you remove class values 2 divs when click on button. so replace : e2.classname = "pop2"; e1.classname = "pop1"; by : e2.classlist.add('pop2'); e1.classlist.add('pop1'); that add new class (pop1 , pop2) others existing default (col-sm-7 , col-sm-5) , work perfectly.

oop - Javascript Class properties and methods work differently -

i have been working javascript while , used notation create objects var classname = (function() { var property = 1; //example of property var method = function () { //example of method }; }); but have project use angularjs , javascript don't recognize it. can use 1 var classname = (function() { this.property = 1; //example of property this.method = function() { //example of method }; }); is there reason first 1 not working? in experience prefer first 1 better [edit] var classname = (function() { var property = 1; //example of property var method = function () { //example of method }; })(); var classname = (function() { var property = 1; //example of property var method = function () { //example of method }; }); in example you're not creating surmounts property and/or method. you're assigning function variable classname , , within function you're creating 2 more variables. variables f...

facebook - How can I get fan page likes count using graph api? -

how can fan page likes count using graph api? earlier here: https://graph.facebook.com/fanpage_id/?access_token=access_token but it's return only: { "name": "fanpagename", "id": "0000000000" } you need add fields want now: https://graph.facebook.com/fanpage_id?access_token=access_token&fields=name,likes serach "declarative fields" in changelog: https://developers.facebook.com/docs/apps/changelog#v2_4 edit: since v2.7 of graph api, "likes" has been renamed "fan_count". more information: https://developers.facebook.com/docs/apps/changelog the new api call: https://graph.facebook.com/fanpage_id?access_token=access_token&fields=name,likes

android - Start a ListFragment from Activity -

i developing app present map (using fragment) , list (using listfragment). so, have activity starts application mapfragment or list fragment, according the user's preferences. can replace current activity mapfragment fragmentmanager , fragmenttransaction. problem have how can call or start listfragment activity. listfragment uses listviewadapter class inflate customized layout (repetedly different information) if want use transaction, necessary use listview container in layout. problem using layout items , not container. any ideas solve problem or other way deal starting presenting listfragment in activity? if trying display 2 different fragments @ same time, have @ documentation , basic idea include multiple framelayout s in activity layout. don't forget view.setvisibility() listfragments started same other fragment. for example: getsupportfragmentmanager().begintransaction() .replace(r.id.content_frame, new mylistfragment() ...

c# - Creating a custom UI element in WPF -

i have several textboxes labels in code implemented following xaml: <dockpanel horizontalalignment="right"> <textblock foreground="black" padding="0,0,10,0">serial number:</textblock> <textbox width="150" isreadonly="true" borderbrush="gainsboro" height="20"></textbox> </dockpanel> i can reduce of copied code doing like: <dockpanel horizontalalignment="right"> <textblock style="{staticresource cstmtextboxlbl}">serial number:</textblock> <textbox style="{staticresource cstmtextbox}"></textbox> </dockpanel> but still lengthy. possible like: <controls:cstmtextbox style="{staticresource cstmtextbox}" labeltext="serial number:" text=""/> where cstmtextbox implement whatever xaml needed same visual effect once, , access both textblock text , textbox t...

responsive design - Extjs 6 responsiveConfig cannot find setters for layout config items -

Image
i've got a fiddle of base layout i'm trying add responsive configurations to . my goal use border layout navigation can change between western region , northern region depending on window size , layout config can switch between vertical , horizontal when region west buttons grouped vertically , when region north buttons grouped horizontally. i know default, layout type cannot changed @ runtime, found this forum thread user points out if use box layout type (the parent of vbox , hbox) can update vertical config change grouping @ runtime. the fiddle linked above attempt @ prototyping concept out. the problem i'm running responsiveconfig cannot find setters particular properties i'm trying change, , it's not vertical config. config items know have setters , have seen work before in responsiveconfig not working well: ext.layout.container.box has setpack method. am mis-configured somehow? i posted thread in sencha's forums technique tryi...

Why does the python Cassandra driver fail when declared as a class field? -

i'm working server process meant connect cassandra database , forward information it. process written class, , goal create single cassandra session class can use send information. however, i'm running problem; when create cassandra session in classes init method, , later try use session in method, following error: errors={}, last_host=<server ip address> . can around problem creating new cassandra session each time method called, not way go this. so, how can make cassandra session can use consistently throughout class? this code not work: from cassandra.cluster import cluster multiprocessing import process class dataprocess(process): def __init__(self): super(dataprocess,self).__init__() # few other irrelevant things ... # set cassandra connection self.cluster = cluster(contact_points=[cassandra_ip]) self.session = self.cluster.connect('some keyspace') print "connected cassandra." def ...

jQuery transform select into picker option -

i'm trying solve bug (it works fine on chrome). that's script transform select picker option: jquery.fn.select2optionpicker = function(options) { return this.each(function() { var $ = jquery; var select = $(this); var multiselect = select.attr('multiple'); select.hide(); var buttonshtml = $('<div class="d2s"></div>'); var selectindex = 0; var addoptgroup = function(optgroup) { if (optgroup.attr('label')) { buttonshtml.append('<strong>' + optgroup.attr('label') + '</strong>'); } var ulhtml = $('<ul>'); optgroup.children('option').each(function() { var img_src = $(this).data('img-src'); var color = $(this).data(...

coffeescript - Meteor - data fetched multiple times? -

i'm using meteor admin project stub ( https://github.com/yogiben/meteor-admin ). i amended data - posts collection in main.coffee include custom filtering defined in buildpostsearch function: router.map -> //cut @route "dashboard", path: "/dashboard" waiton: -> [ subs.subscribe 'posts' ] data: -> posts: posts.find( buildpostsearch() ).fetch() buildpostsearch = () -> console.log "executed." { //filter object constructed depending on session parameters } this works correctly, being invoked multiple times on page refresh. can see in browser console: executed. executed. executed. executed. executed. executed. (...around 50 times) i worried performance. query db many times? there better way it? the data hook reactive, it's normal fire multiple times . it's important remember when runs it's fetching documents y...

javascript - jquery css right on iOS -

i tried position of element right. defined following in css .container { position: absolute; right: 8%; bottom: 7%; } i tried position of element right using following jquery code $('.container').css('right'); which gives 142px on chrome , mozilla but gives 8 (percentage) on ios(both safari , chrome) browsers. any other options in jquery value in px on ios browsers , other browsers alike? take percentage , value... var px_right = ('.container').css('right'); /* --- --- */ if ( /*ios*/ navigator.useragent.match(/(ipod|iphone|ipad)/)) { px_right = (('.container').css('right'))/100.0 * window.width(); } ` edit sorry have forgotten thing: /100.0 . edited: px_right = (('.container').css('right'))/100.0 * window.width(); example : 'px_right = 8% of 980px = 0.08*980 = 78px

Determining the Size of a Rectangle based on Co-ordinates in Java -

i've been struggling problem awhile , i'm looking assistance. information know/am given: a series of co-ordinates similar following x=5, y=5 x=5, y=6 x=9, y=10 x=1, y=1 x=2, y=1 x=1, y=2 x=2, y=2 every point in list part of rectangle, @ least 1x1 these lists int[] s, x-coords in 1 array, , y-coords in another the array co-ordinates matched (e.g. xcoords[5] makes ordered pair ycoords[5] ) the size of arrays not consistent (it might 50 x-coords , 50 y-coords) the co-ordinates can negative what need find the number of rectangles in list (e.g. example 3) the size of each rectangle (e.g. example r1=2x1, r2=1x1, r3=2x2) the format of results don't matter example: public class rectangle_test { public static void main(string[] args) { int[] xcoords = {5,5,9,1,2,1,2}; int[] ycoords = {5,6,10,1,1,2,2}; } } i have idea of how approach problem... get first element of each array , assign variable int initialx = xco...

Time series loadflow powerfactory via python -

can me running time-series load flow in powerfactory using python? sharing script. thanks in advance, the script built software - right click object of interest , select execute script , choose time-series list , execute full fill requirement

angularjs - get the location of the stationary marker when map changes -

Image
i'm developing mobile app in ionic.my requirement had stationary image on map, need location under image.. below code found dragging marker , getting location. var mylocation = new google.maps.marker({ position: new google.maps.latlng(pos.coords.latitude, pos.coords.longitude), map: map, title: "my location", draggable:true }); google.maps.event.addlistener(loc, 'dragend', function(evt){ console.log('current latitude:',evt.latlng.lat(),'current longitude:',evt.latlng.lng()); }); but need stationary image , location when map dragged thing in below image. there rounded circle, when drag map , can see location under image.. anyone please guide me achieve that. thankyou

javascript - How do I return the response from an asynchronous call? -

i have function foo makes ajax request. how can return response foo ? i tried return value success callback assigning response local variable inside function , return one, none of ways return response. function foo() { var result; $.ajax({ url: '...', success: function(response) { result = response; // return response; // <- tried 1 } }); return result; } var result = foo(); // ends being `undefined`. -> more general explanation of async behavior different examples, please see why variable unaltered after modify inside of function? - asynchronous code reference -> if understand problem, skip possible solutions below. the problem the a in ajax stands asynchronous . means sending request (or rather receiving response) taken out of normal execution flow. in example, $.ajax returns , next statement, return result; , executed before function passed success callback ca...

scripting - Alfresco: Run Javascript on Workflow Cancellation -

i have advanced workflow creates , modifies custom data list entries different tasks completed. however, if user cancels workflow, data list entry still persists. is there execution or task listener event on workflow cancellation can run javascript from? following webscript called internally "delete/cancel workflow" action. /alfresco/service/api/workflow-instances/{workflow_instance_id}?forced={forced?} you can find related files here. <alf_home>\tomcat\webapps\alfresco\web-inf\classes\alfresco\templates\webscripts\org\alfresco\repository\workflow

node.js - Creating public URL for Skipper upload on AWS -

i'm uploading image amazon web service s3 using skipper.js , creating public url file uploaded hasn't been possible using skipper.js . don't want use skipper-disk want upload s3 , able create publicly accessible url download file. code below , that's i've done imageupload: function(req, res) { //console.log(req); req.file('avatar').upload({ adapter: skipper, key: 'key', secret: 'secret', bucket: 'bucketname' }, function(err, fileuploaded){ if (err) { console.log(err); return res.negotiate(err); } if (fileuploaded.length === 0) { return res.badrequest('no files uploaded'); } var imageurl = fileuploaded[0].extra.location; var imageky = fileuploaded[0].extra.key; imageupload.create({urllink: imageurl, imagekey: imageky}).then(function(urladded){ if (urladded) { ...

html - jquery toggleClass changing only once -

i making slideshow jquery. i'm using jquery ui icons play/pause button , on. have code: $(function(){ $(".controls").hide(); //hide controls $(".slider").hover(function(){ $(".controls").fadein(500); }, function(){ $(".controls").fadeout(500); }); // show controls on hover $(".play").click(function(){ $(".slider").attr({'data-running' : 'true', 'data-paused' : 'false'}); $(this).toggleclass("ui-icon-play ui-icon-pause play pause"); }); $(".pause").click(function(){ $(".slider").attr({'data-running' : 'false', 'data-paused' : 'true'}); $(this).toggleclass("ui-icon-play ui-icon-pause play pause"); }); //add play/pause functionality }); html: <div class="slider-wrap"> <div class="slider" data-running=...

javascript - Angular recursive directive and ngRepeat scope -

i'm having problems recursive tree directive in angular, ngrepeat not model in scope reason, below directive's code. app.controller("pagecontroller", function($scope) { this data object: $scope.mytree = [{ "name": "apparel", "checked": false, "children": [{ "name": "mens shirts", "children": [{ "name": "mens special shirts", "children": [] }] }, { "name": "womens shirts", "children": [] }, { "name": "pants", "children": [] }] }, { "name": "boats", "children": [] }]; }); main directive: app.directive("treeui", function($compile, $timeout) { return { priority: 1001, replace: false, transclude: "element", restrict: "aec", sco...

python - How to sort a list based on the output of numpy's argsort function -

i have list this: mylist = [10,30,40,20,50] now use numpy's argsort function indices sorted list: import numpy np = np.argsort(mylist) which gives me output: array([0, 3, 1, 2, 4]) when want sort array using so works fine: myarray = np.array([1,2,3,4,5]) myarray[so] array([1, 4, 2, 3, 5]) but when apply list, not work throws error mylist2 = [1,2,3,4,5] mylist2[so] typeerror: integer arrays 1 element can converted index how can use so sort list without using for-loop , without converting list array first? you can't. have convert array back. mylistsorted = list(np.array(mylist)[so]) edit: ran benchmarks comparing numpy way list comprehension. numpy ~27x faster >>> timeit import timeit >>> import numpy np >>> mylist = list(np.random.rand(100)) >>> = np.argsort(mylist) #converts list numpy internally >>> timeit(lambda: [mylist2[i] in so]) 12.29590070003178 >>> myarray = np.ran...

lua - nginx string.match non posix -

i got string (str1) , want extract after pattern "mycode=", local str1 = "servername/codebase/?mycode=abc123"; local tmp1 = string.match(str1, "mycode=%w+"); local tmp2 = string.gsub(tmp1,"mycode=", ""); from logs, tmp1 => mycode=abc123 tmp2 => abc123 is there better/more efficient way this? belive lua strings not follow posix standard (due size of code base). yes, use capture in pattern control string.match . from lua reference manual (emphasis mine): looks first match of pattern in string s. if finds one, match returns captures pattern ; otherwise returns nil. if pattern specifies no captures, whole match returned. third, optional numerical argument init specifies start search; default value 1 , can negative. it works this: > local str1 = "servername/codebase/?mycode=abc123" > local tmp1 = string.match(str1, "mycode=%w+") > print(tmp1) mycode=abc123 > local tmp2 =...

Get value of TextBox if 1s elapsed after last change c# -

how can value of textbox 1seconde after last change . i tried stopwatch , timerstamp time between 2 change don't know how value of textbox 1 seconde after. thanks help! edit: stopwatch timerbetweenwrite = new stopwatch(); private void textbox_textchanged(object sender, textchangedeventargs e) { timerbetweenwrite.stop(); // elapsed time timespan value. timespan ts = timerbetweenwrite.elapsed; if (search.text != null && ts.seconds >= 1) { //doing stuff } timerbetweenwrite.restart(); } but don't work want because need change textbox 1 seconde after last change. want run function 1 seconde after last change of textbox user can continue change textbox. final edit: that code work thank's help! public partial class viewerpage : page { system.timers.timer mytimer = new system.timers.timer(1000); public viewerpage() { initializecomponent(); ...

java - Add URL to classpath via command line -

i'm trying achieve equivalent this: java.exe -cp "c:\my_test\my_jar.jar;c:\my_test\lib\*;" com.test.main but using url this: java.exe -cp "http:\\192.168.1.12\my_test\my_jar.jar;http:\\192.168.1.12\my_test\lib\*;" com.test.main the error is: could not find or load main class , if http:\\192.168.1.12\my_test\my_jar.jar can see main class there. there way can via command line ? p.s: can reach http:\\192.168.1.12\my_test\my_jar.jar via browser the classpath composed of jar files , directories. not of http urls. you'll have programmatically create urlclassloader load classes server way.

sql server 2008 - Get only rows where 2 conditions are fulfilled in Microsoft SQL -

i have table mapping table t1. looks following: +-------+---------+-------------+ | reqid | fieldid | listitemid | +-------+---------+-------------+ | 219 | 76 | 3548 | | 219 | 86 | 2382 | | 220 | 76 | 3548 | | 220 | 86 | 3491 | | 221 | 77 | 3550 | | 221 | 87 | 2387 | +-----------------+-------------+ now want todo select distinct reqids has both of following select * t1 (fieldid='76' , listitemid='3548') or (fieldid='77' , listitemid='3550') or ((fieldid='86' , (listitemid='3491' or listitemid='2380')) or (fieldid='87' , (listitemid='3494' or listitemid='2386'))) order requirementid this gives me rows has 1 of above requirements. want todo get select * t1 ((fieldid='76' , listitemid='3548') or (fieldid='77' , listitemid='3550')) , (((fieldid='86' , (...