Posts

Showing posts from September, 2014

swagger UI passing headers to API try out calls programmatically -

all our services require authentication token passed in header. know correct way go use oauth not yet supported our use case. what want token once making call authentication service , set try out requests swagger ui index page. there enough documentation on how pass custom header swagger api calls (the calls api info) couldn't find set custom header "try out" calls. i appreciate advise. thanks, jas

Kendo Grid: Column Header Checkbox 'Check All' that checks boxes across grid all pages -

is there example out there in javascript and/or jquery has 'check all' checkbox checks checkboxes across pages of grid? i have been trying 3 days , not finding clean answer. what have ugly , not work... function onrequestend(e) { var mastercbchecked = $("#mastercheckbox").is(':checked'); var grid = $("#grid").data("kendogrid"); (var = 0; < grid.datasource.total(); ++) { var datarow = $("#grid").data("kendogrid").datasource.data()[i]; var elementrow = grid.table.find(".cbadvisor")[i]; if (elementrow != null) { var checked = elementrow.checked, row = $(elementrow).closest("tr"), dataitem = grid.dataitem(grid.tbody.find("tr").eq(i)); checkedids[dataitem.dimagentid] = mastercbchecked; ...

Creating a List in prolog -

i have predicate has following format: pilot( id1, id2 ). i'm searching multiple values pilot , im able predicate findall, how can go there , use new predicate create list this: [ pilot( id1, id2 ), pilot( id1, id2 ), pilot( id1, id2 ), pilot( id1, id2 ), ... ]. [clarification] i this: ask id of flight: id and this: findall( flights( pilots ), flight( id, pilots, _, _, _, _), xs). and this: xs = [ flights( 1, 2 ), flights( 4, 7 ), flights( ... ), ... ]. i take information , find resulting pilots associated id of flights. can each pilot , i'm able write() them, problem iss, have multiple same pilots, because of multiple flights, want put of pilots, have structure: pilot(id,a,b,c,d,e), , put of them in list this: xa = [ pilot(id,a,b,c,d,e), pilot(id,a,b,c,d,e), pilot(id,a,b,c,d,e), ... ] can remove duplicate entries. the input format of problem not clear. if have 1 predicate each flight-pilot pair, do: % flight(id, pilot) flight(1, 100). flight(...

node.js - ".use" method to add logic on each request of SuperAgent -

this issue in superagent repository mentions .use method add logic on each request. example, adding authorization header jwt when token available: superagent.use( bearer ); function bearer ( request ) { var token = sessionstorage.get( 'token' ); if ( token ) request.set( 'authorization', 'bearer ' + token ); } although last comment informs feature working again, can't make work. the following test code: var request = require( 'superagent' ); request.use( bearer ); function bearer ( request ) { // "config" global var token , other stuff resides if ( config.token ) request.set( 'authorization', 'bearer ' + config.token ); } returns error: request.use( bearer ); ^ typeerror: undefined not function the issue linked isn't linked commits, can speculate on whether or not feature implemented , removed, or never implemented in first place. if read through src , see use ev...

php popen(exim) from a webpage -

problem: apache accessing programs in /usr/bin platform: win/7 pro sp1 apache 2.4 php 5.6 cygwin emulator gives linux/unix emu , has exim 4.84-1 program: sendit.php hndl popen( exim ... ) fwrite(hndle, email_headers); fwrite(hndle, email_body); fflush(hndle); fclose(hndle); (a)launch user account php sendit.php -> exim/exim_main.log updated reports 368 bytes sent exim -> email arrives demonstrates sendit.php works & exim config , permissions correct (b)launch apache account uid(apache) gid(srvc) php sendit.php -> exim/exim_main.log updated reports 368 bytes sent exim -> email arrives demonstrates sendit.php runs account (c)launch within web page apache run own uid/gid in (b) page.phtml sendit.php -> no update exim log -> no mail recv'd reports same nnn bytes send exim no i/o errors i fwriting_stream 368 bytes ... ...

java - Joda Period not converting all minutes to hours "8h, 132m" -

i storing 2 datetimes (joda) in object , period object new period(datetime1, datetime2) . want add periods different objects together. both adding periods in variable , summing periods in smaller periods stored in hashmap<long, period> . the result , issue this. first period gets "2 hours , 30 minutes" periodformat.getdefault().print(p) (the values same if concatenate gethours , getminutes). second value "5 hours , 52 minutes". far good. when 3rd , 4th, minutes stop converting hours. "5 hours , 103 minutes" "8 hours , 132 minutes" it should 10h , 12m, can see. that's not getting. issue? how can period forget conversion? don't have problems selected sums, yet. code: (with variable names changed) mainsum= new period(); taskssum= new hashmap<long, period>(); for(entry entry: entries){ long main_id= entry.getmain_id(); long task_id = entry.gettask_id(); period entryperiod = entry.getper...

ios - Perform action on selection of UICollectionViewCell? -

i call function when cell pressed , able change function based on cell pressed. here code currently: override func numberofsectionsincollectionview(collectionview: uicollectionview) -> int { //#warning incomplete method implementation -- return number of sections return 4 } override func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { //#warning incomplete method implementation -- return number of items in section return 10 } override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { let cell = collectionview.dequeuereusablecellwithreuseidentifier(reuseidentifier, forindexpath: indexpath) as! uicollectionviewcell // configure cell return cell } func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize { r...

c# - IIS Url Rewrite rule HTTP to HTTPS AND add WWW -

i have website want used www sub-domain , via https. had url rewrite working adding www. want force http https redirect. forcing https works well, when can't figure out how combine 2. can provide me working rule redirects https://www.domain.com in case request without www and/or via http. i have been made question months ago , answers may you. at: how create except rewrite rule @ iis i solved installing rewrite module , creating rule inside it. install, have install: http://www.iis.net/downloads/microsoft/url-rewrite

How to make HTML form submit when Enter key pressed? -

i've got following html code (from larger page) lets me enter username , password, , select server want log in to: <form> <b>multi-server login</b><p> <table> <tr><td colspan=2 align=left> enter username , password:<br> </td></tr><tr><td valign=top> username:&nbsp; </td><td> <input id='userid' size=20 class='fixed'> </td></tr><tr><td valign=top> password:&nbsp; </td><td> <input type='password' id='passwd' size=20 class='fixed'><p> </td></tr><tr><td valign=top> remote host:&nbsp;&nbsp; </td><td valign=top> <select id='server'><br> <option value='server1' selected>server1<br> <option value='server2'>server2<br> <option value='server3'>server3<br> </select> </td>...

Getting two vagrant VMs to communicate -

i've looked around lot solution seems simple problem, , have not come answer. i have vagrantfile defines 2 vms: vagrant.configure("2") |config| config.vm.define :box1 |config| config.vm.box = "hashicorp/precise32" config.vm.hostname = "box1" config.vm.network "private_network", ip: "192.168.0.21" config.vm.provision :hosts end config.vm.define :box2 |config| config.vm.box = "hashicorp/precise32" config.vm.hostname = "box2" config.vm.network "private_network", ip: "192.168.0.22" config.vm.provision :hosts end end so, understanding of i'm giving each box own ip address, , running hosts provisioner (provided vagrant-hosts plugin ). vagrant-hosts docs, should need do. however: $ vagrant ssh box1 -c 'ping 192.128.0.22' ping 192.168.0.22 (192.168.0.22) 56(84) bytes of data. 192.168.0.21 icmp_seq=1 destination host unreachable 192.1...

php - !preg_match for letters not working -

i developing website in use !preg_match("~/^[a-za-z ]*$/~",$name) when user write his/her name in html form field letters allow write if number write message appears "only letter allowed".... takes both numbers , letter. do??? here code: <?php $nerr = $naerr = $cerr = ""; $id = $name = $color = ""; if (isset($_post["submit"])) { $id = $_post["id"]; $name = $_post["name"]; $color = $_post["color"]; if (!preg_match("[0-9]",$id)) { $nerr = "only number allowed"; } else if (!preg_match("~/^[a-za-z ]*$/~",$name)) { $naerr = "only letters allowed"; } else if (!preg_match("~/^[a-za-z ]*$/~",$color)) { $cerr = "only letters allowed"; } } ?>

elasticsearch nest index relational database -

i've indexed 2 separate tables elasticsearch - meetings , meetingattendees. 1 many relationship - meeting can have many attendees. meetings id: 1 id: 2 meeting attendees meetingattendeeid: 1 meetingid: 1 name: "tom" meetingattendeeid: 2 meetingid: 1 name: "david" meetingattendeeid: 3 meetingid: 2 name: "david" i've tried create relationship this, i'm not seeing difference in es client.createindex(ci => ci.index("testmappingindex") .addmapping<meeting>(m => m.mapfromattributes()) .addmapping<meetingattendee>(m => m.mapfromattributes().setparent<meeting>())); i'd able query this: result = client.search<meeting>(s => s .type("meeting") .from(0) .size(10) .query(q => q.meetingattendees(ma => ma.terms(t => t.name == "david"))) ...

php - How to grant limited permissions to PostgreSQL tables? -

i considering switching mysql postgresql because of limitations of mysql's fulltext features in shared hosting environment (the minimum word length cannot changed). have no administrative experience of postgresql , struggling make sense of granting permissions users/roles. my app has 2 users, 1 building , 1 runtime. want runtime user have these perms: select, insert, update, delete i therefore log onto postgresql thus: sudo -u postgres psql postgres having consulted manuals , various internet sources, created demo, intention of having limited permissions on future tables. fresh database: create user job_frontend password 'password'; drop database if exists job_frontend; create database job_frontend encoding 'utf8'; create role job_runtime; alter default privileges in schema public grant select, insert, update, delete on tables job_runtime; grant job_runtime job_frontend; my strategy, going wrong: create user, set grants on role, assign role gra...

c - Recursive call that confuses me -

i have following function int vowels(char *str) { int count = 0; if (! str[0]) return count; if (strchr("aeiouaeiou", str[0])) count ++; return count + vowels(&str[1]); } that performs counting vowels appear in string, confuses me recursive call vowels(&str[1]) not understand why on every call goes next character, without doing str++ . can me understand this? please. within each function call declared like int vowels(char *str); though declare like size_t vowels( const char *str ); expression &str[1] is equivalent to str + 1 or ++str however may not use str++ because value of expression address stored in str before increment. as me define function following way size_t vowels( const char *s ) { return *s ? ( strchr( "aeiouaeiou", *s ) != null ) + vowels( s + 1 ) : 0; }

c# - Duplex WCF: host runs on desktop, interacts with website (client)? -

i want use duplex wcf between host (a desktop app) , web site, web site client , desktop app runs wcf host. the user should click on button on web site, ajax call asmx web service in turn should send command host (which talks bunch of other desktop apps; i've learned how last part tutorials found online) i want 2 interfaces: 1 between host , bunch of other desktop clients (which know how do) , 1 between host , website, @ point needs receive message/command website (this part need on). i've seen examples of duplex wcf between host , client client desktop application (gui), not client website/web service. how go doing this?

jms - IllegalArgumentException converter-bean MessageConverter does not implement InboundMessageConverter -

i need oep application. i'm trying convert jms-inbound message using own converter bean. when deploying i’m getting following exception. exception in thread "springosgiextenderthread-171" org.springframework.beans.fatalbeanexception: error in context lifecycle initialization; nested exception java.lang.illegalargumentexception: converter-bean messageconverter not implement inboundmessageconverter @ com.bea.wlevs.spring.applicationcontextlifecycle.onapplicationevent(applicationcontextlifecycle.java:146) @ org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster.java:97) @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:324) @ org.springframework.context.support.abstractapplicationcontext.finishrefresh(abstractapplicationcontext.java:929) @ org.springframework.osgi.context.support.abstractosgibundleapplicationc...

javascript - Can you set multiple attributes with the DOM's setAttribute function? -

let's wanted create input element using dom. instead of doing this var input = document.createelement("input"); input.setattribute("class", "my-class"); input.setattribute("type", "checkbox"); input.setattribute("checked", "checked"); is there dryer way write these 3 lines of code 1 line. i know this var attributes = ["class", "type", "checked"]; var values = ["my-class", "checkbox", "checked"]; (var = 0; < attributes.length; i++) { input.setattribute(attributes[i], values[i]) end the problem is helpful if have boatload of attributes need add. if have 2 or three, less dry. is there anyway can dry code? yes can using jquery. $(input).attr( { "data-test-1": num1, "data-test-2": num2 });

windows phone 8 - Deep link from toast when tombstoned -

i have strange issue in windows phone 8.0 silverlight app. use toast notifications deep linking. works expected if: the app open the app deactivated still in memory or the app closed. however, if app in tombstoned state, doesn't work. flow expect see: phone receives toast server, user taps toast application_activated event onnavigatedto (old page pre-tombstone) onnavigatedto (deep link page) the 4th step doesn't happen. acts user hit button , re-opened application. know push notification correct because works in other scenarios. idea cause this?

Creating multiple lines inside a nodule of a binary graph in the r package igraph -

package: igraph program: r-gui system: windows 8 problem: how put text, within node, onto multiple lines instead of default 1 line? background: using reingold layout binary tree graph. when print original tree text levels 5+ tends mesh incoherent mess. right putting tree png file with, relatively, insane dimensions can read easily. looking solution can move text onto multiple lines increase font size , decrease overall dimensions. pertinent code: creating tree library(igraph) binarygraph<-graph.tree(n = 1) filling tree, newname variable containing gene locations @ specific node location leftholder = newname[j] binarygraph <- binarygraph + vertices(leftholder) binarygraph <- binarygraph + edge("root" , leftholder) plotting v(binarygraph)$label.cex = 0.65 png(file = "f:/current work/prunedtree.png",width= 60, height=40, units="in", res=300) plot(binarygraph, vertex.size=10, edge.width=2 ,layout = layout.reingold.tilford(binarygraph...

Dynamically Instantiate a Function & Call a Method in JavaScript -

take javascript class: var foo = function() { this.bar = function() { return 'foobar'; }; }; i can instantiate class , call it's bar method this: (new foo).bar(); i achieve instantiation , calling of class , it's method dynamically based of string represents class , method foo@bar . i have tries following achieve receive error uncaught typeerror: string not function : var action = 'foo@bar'; var classmethod = action.split('@'); (new classmethod[0]).call(classmethod[1]); is possible in javascript or going in wrong way? you eval. won't show because eval evil. if willing create object containing types can created: var foo = function() { this.bar = function() { return 'foobar'; }; }; var types = { foo : foo }; var action = 'foo@bar'; var classmethod = action.split('@'); (new types[classmethod[0]])[classmethod[1]](); the problem code classmethod[0] stri...

javascript - ajax post to php not actually writing to the mysql table -

$(document).ready(function() { $('#save').click(function() { var rows = []; (i = 1 ; < document.getelementbyid("schedule").rows.length ; i++) { var name; var tuesday; var wednesday; var thursday; var friday; var saturday; var sunday; name = document.getelementbyid("schedule").rows[i].cells[0].firstchild.value; tuesday = document.getelementbyid("schedule").rows[i].cells[1].firstchild.value; wednesday = document.getelementbyid("schedule").rows[i].cells[2].firstchild.value; thursday = document.getelementbyid("schedule").rows[i].cells[3].firstchild.value; friday = document.getelementbyid("schedule").rows[i].cells[4].firstchild.value; saturday = document.getelementbyid("schedule").rows[i].cells[5].firstchild.value; sund...

ms access - Select rows based on 5% of total ticket count per combo of User/Team/Category -

i new world of programming , self-taught. i've read think need code includes use of sub-queries. however, i've never created sub-queries i'm little lost on how accomplish that. i have table include multiple tickets entered different users specific teams , categories. need count # of tickets per combinations , pull random no of tickets (5 %) based on each combination. for example combo of smith,saml&cinquiry has 176 tickets, need pull 9 of tickets the combo of brown,toml&clicensing has 22 tickets, need pull 1 of those. i attempting in access database. here's i've tried: public function test() set dbs = currentdb dim newqry querydef set newqry = dbs.createquerydef(rst2) = 1 i2 = 1 set rst = dbs.openrecordset("query1", dbopendynaset) until i2 > rst.move int(rnd(rst.recordcount) * 100) if i2 = 1 query_filter_store = " combo ='" & rst.combo.value & "'" else query_filter_...

c++ - Older version Commands of opencv are not working in newer versions -

i using opencv 3.0.0 beta, , fails recognize cv::fourcc , cv_cap_prop_frame_width , cv_cap_prop_frame_height older versions. how go using them in newest version. here's sample code providing example of might need them, , unable use them in opencv 3.0.0 beta. #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/videoio/videoio.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/video/video.hpp> #include <opencv2/imgcodecs/imgcodecs.hpp> #include <opencv2/features2d/features2d.hpp> #include <opencv2/core.hpp> #include <iostream> #include <sstream> using namespace cv; using namespace std; int main() { videocapture cap("h:\\images\\v1.mp4"); cv::videowriter writer; string filename = "h:\output_video.avi"; int fcc = cv::fourcc('d', 'i', 'v', '3'); // error shown line int fps = 20; cv::size framesize(cap.get(cv_cap_prop_frame_width), cap.get(cv_cap_prop...

excel - How to use VBA to color and frame cells with value -

i'm trying color , frame column in data. there blank rows inside. want color cells value. data position might change, want use input box color , frame . the data this. select range column b. 1 2 b 3 4 5 b 6 7 8 b 9 10 11 b 12 13 14 b 15 16 17 b 18 19 20 b 21 22 23 b you don't need vba - use conditional formatting. highlight entire column b, go "conditional formatting" under home tab. click "new rule" , choose last 1 in list, "use formula determine cells format.", enter in box =$b1<>"" . click "format" , go "fill" - choose color want, , hit "ok" , "ok". should it! edit: ah, input box - can expand on want that? mean using "color , frame"?

vb.net - Why can't I have two methods with the same parameters but different returns? -

.net allows... public function one(a integer) string... public function one(b string) string... it figures out 1 call looking @ type of parameters, like... dim string = one(5) ok, why can't this... public function one(a integer) string... public function one(b integer) integer... the same amount of information available compiler... dim integer = one(5) ' should know call second version the specific problem i'm trying solve return values in dictionary(of integer, myclass) is visible com interop . return .values ienumerable . lose type inside own code, pita. if have 2 methods have 1 returns ienumerable , returns list(of myclass) , api same in both places. have 2 different method names, kind of defeats purpose. i'm open solution fixes underlying problem... there single type can return avoids directcast in own code, while still being visible com interop? short answer : because return type isn't included in method's signature the r...

android - Error:Execution failed for task ':app:dexDebug'.....' finished with non-zero exit value 2 -

error:execution failed task ':app:dexdebug'. com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command 'c:\program files\java\jdk1.7.0_75\bin\java.exe'' finished non-zero exit value 2 i read suggestion try of them still can not problem.plz help here dependencies -> dependencies { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.1.1' compile files('libs/google-play-services.jar') compile files('libs/parse-1.3.2.jar') compile files('libs/parse-1.6.0.jar') } remove 1 parse.jar (android studio not know version prefer) compile 'com.google.android.gms:play-services:7.5.0' instead of compile files('libs/google-play-services.jar') as google services contain res files, therefore cannot imported through .jar remove compile filetree(dir: 'libs', include: ['*.ja...

CUDA - what's the most efficient way to compute euclidean distance between 2 float3? -

currently i'm using following code compute euclidean distance between 2 float3 took 1 of nvidia samples. inline __host__ __device__ float3 operator-(float3 a, float3 b) { return make_float3(a.x - b.x, a.y - b.y, a.z - b.z); } inline __host__ __device__ float dot(float3 a, float3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; } inline __host__ __device__ float euclideandistance(float3 v) { return sqrtf(dot(v, v)); } is there (maybe more low level) way faster? cuda has functions norm3d{f}() in math library best fit when computing euclidean distance of 3-vectors ensure maximum accuracy , avoid overflow in intermediate computation. if need normalize vectors, want @ rnorm3d{f}() . canonical choice operation , should optimal. note might possible run computations in distance squared instead, rather distance, eliminate expensive square root operation , should considerably faster using euclidean distance. [this answer assembled comments , added community wik...

mysqli - some checkbox with one buttom for some row to insert in different table php -

i have problem. want insert row (each select checkbox) database table. have pages: ricercatitoli.php <div id="ricerca" class="content"> <form action="ricercatitoli.php" method="post"> <p>inserire il titolo</p><input type="text" name="titol" class="test"> <p>inserire il numero</p><input type="text" name="numer" class="test"> <br><br> <center><input type="submit" value="ricerca" class="btn"></center> </form> </div> ricercatitoli.php <?php $servername = "localhost"; $username = "root"; $password = "ephp"; $db="magazzino"; $titolo = isset($_post["titol"]); $numero = isset($_post["numer"]); // create connection $conn = mysqli_connect($servername, $user...

php - "Allow from xxx.xx.xx" in .htaccess not working -

i have code in .htaccess folder. .htaccess folder in directory: /api/.htaccess api.php location: /api/api.php i have code in .htaccess: <files api.php> order deny,allow deny allow 127.0.0.1 allow 122.109.32.241 allow 130.211.76.20 </files> my goal block every 1 ips. problem im still getting 403 error though ip on allow. error: forbidden don't have permission access /api/api.php on server. apache/2.2.15 (centos) server @ accountdispenser.com port 80 edit: ok after playing around method works: $_server['http_x_forwarded_for']; but how .htaccess work method?

How to show 2-D matrix in matlab -

Image
hi guys, want show 2-d array in matlab picture below,but dont know should search for. appreciated. you looking spectogram plotting, surf map: figure surf(y0, 'edgecolor', 'none'); view(0,90); axis tight; where y0 matrix (assuming value in matrix magnitude). you may use spectrogram plotting tool, check out spectrogram i might add, in cases, use log(abs(y0)), log magnitude particularly @ showing results overall data not sparse.

regex - Removing contents of bracelets -

we have free text: sal{del{rf}ghladfs}wds{w12rf}qq output should be: salwdsqq please share various approaches if possible. example : lapply, gsub, for/while loop, grep this works in r string1 <- "sal{del{rf}ghla}dfs}wds{w12rf}qq" string2 <- gsub("{[^{}}]*}", "", string1, perl = true) string3 <- gsub("{.*}", "", string2, perl = true) string3

c++ - Adding file as header in source-source transformation using clang -

#include <stdio.h> int main(void) { workfunc(); return 0; } i have sample code above, function being called in 'main' in header file 'header.h'. after transformation, code must like #include <stdio.h> #include "header.h" int main(void) { workfunc(); return 0; } please help. using clang, c++ coding , transformation code available in link i recommend call along same way call header files program , should work.

Reconciling Show/Hide JQuery Script into PHP -

i have php script outputs results query. add @ end 2 buttons show/hide final element, not sure how this. the following php script: while($result = mysqli_fetch_array($iname)) { echo "<b>event name:</b> " .$result['eventname']; echo "<br> "; echo "<b>location:</b> ".$result['location']; echo "<br>"; //this add 2 buttons, show "hidden" content when clicked and here have written in html script, reconcile php output: <!doctype html> <html> <head> <scriptsrc="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js></script> <script> $(document).ready(function(){ $("#hidden").hide(); $("#hide").click(function(){ $("#hidden").hide(500); }); $("#show").click(function(){ $("#hidden").show(500); }); }); </script> </head> <body> <button id="show...

c# - Is it a bad idea to copy project folders for backup? Add existing items instead? -

i'm learning c# (self-teaching first real programming language other vba). consistently, text book asks me create new project , add bunch of existing items old project when don't want mess existing project. seems way of creating backup. never said not copy folders i've been doing , works fine. the ide doesn't allow save whole project new name (i.e. save as: "backup of projectname") instead close ide , copy folder. it's been great time saver rather following laborious instructions fear i'm teaching myself bad habit. please tell me fears unfounded. in case else comes along seeking answers - note question has been answered via discussion in comments. it sounds practice won't blow there's better way: "version control system" or "vcs". i'm going have little research , pick 1 before semi-bad habit gets ingrained. thanks @xantos , @daniellane!

json - Use the Mozilla Backpack Connecti API with PHP -

i issue badge mozilla backpack connect api ( check ! ). so, have followed this document still cannot issue badge ! i have exact same problem when try new access token using refresh token. i've posted "get new access token" code here because it's bit easier understand issuing one. i in php curl , not in javascript . here code : $data = array( 'grant_type' => 'refresh_token', 'refresh_token' => $refreshtoken ); $url = $apiroot .'/token'; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_post, count($data)); curl_setopt($ch, curlopt_postfields, http_build_query($data)); curl_setopt($ch, curlopt_httpheader, array( 'content-type: application/json' )); curl_setopt($ch, curlopt_verbose, true); curl_setopt($ch, curlopt_stderr, fopen('php://output', 'w+')); curl_setopt($ch, curlopt_returntransfer, true); $response = curl_exec($ch); var_dump($response); cur...

java - How can I call GetRawInputDeviceInfo using JNA? -

i want call getrawinputdeviceinfo java application using jna . this jna library interface looks like: public static final uint ridi_deviceinfo = new uint(0x2000000b); public static dword rim_type_keyboard = new dword(1); public static class rid_device_info extends structure { public dword cbsize; public dword dwtype; public rid_device_info_ riddeviceinfo_; @override protected list<string> getfieldorder() { return aslist("cbsize", "dwtype", "riddeviceinfo_"); } } public static class rid_device_info_ extends structure { public rid_device_info_mouse mouse; public rid_device_info_keyboard keyboard; public rid_device_info_hid hid; @override protected list<string> getfieldorder() { return aslist("mouse", "keyboard", "hid"); } } public static class rid_device_info_mouse extends structure { public dword dwid; public dword dwnumberofbuttons; public dword dwsamplerate; ...

delphi - Error when TChart is docked -

i av when dock form, wich contains tchart , form. error not occure when autopaint property of tchart set true . i have tested c++builder xe6, xe7 , delphi builder xe6 standard version of teechart . steps reproduce: create new application 2 forms (form1 , form2). both forms should shown. in constructor of form1 set docksite = true paste following code in constructor of form2: dragmode = dmautomatic; dragkind = dkdock; tchart* chart1 = new tchart(this); //don't forget delete chart1->parent = this; chart1->autorepaint = false; start application , dock form2 form1 dragging mouse. can reproduce or has idea whats going wrong? like david said, question answered now. think new updates on issue seen @ qc. https://quality.embarcadero.com/i#browse/rsp-11239

pingfederate - How to get SAML Response from Ping Federate Service provider to local server? -

i have done end-to-end configuration idp , sp in ping federate. saml response generated @ idp , same received @ sp.but, want response @ local server in order use user's attributes logic. tell me how shall achieved? i opentoken @ target resource configure in ping federate. thanks, aswini j in pingfederate terminology trying accomplish last mile integration after saml assertion processed pingfederate server operating in sp role. there 2 approaches work best providing subject & attribute information via last mile integration, agentless reference id integration kit, or opentoken integration kit. if application java, .net, or php, there examples of integration available ping. the simple configuration read attributes saml assertion opentoken , use opentoken integration kit (php, java, or .net), agent library in application. documentation opentoken integration kit shows code write read opentoken within application. configuration in pingfederate sp server need sp...

swift - Compressing unicode strings -

i looking algorithm compress unicode strings in swift. strings compress relatively small (no more 160 characters). i found lzw compression implemented here . copy pasted code worked ascii characters added unicode characters, got fatal error: unexpectedly found nil while unwrapping optional value while compressing, on line result.append(dict[w]!) guess algorithm doesn't support unicode characters since dict[c] undefined unicode character c . how can tweak algorithm in order support unicode characters or should try other compression methods? if so, ones? edit by changing loop @ beginning from for in 0 ..< 256 { let s = string(unicodescalar(i)) dict[s] = } to for in 0 ..< 0xffff { let s = string(unicodescalar(i)) dict[s] = } i can algorithm work, although, solution requires calculation time , memory.

bit manipulation - Check if bit has toggled in C -

i working on bitwise manipulation (in c) , wanted know how check if bit has toggled between previous value , new value. example : oldvalue = 0x0ff //0000 1111 1111 in binary newvalue = 0x100 //0001 0000 0000 in binary in example want check if bit8 (9th bit) has toggled 0 1. i know if want know if bit set, can use : value & (1 << 8) so, correct ? : if( (oldvalue & (1 << 8)) == (newvalue & (1 << 8)) ) //return 0 if toggled you can in 2 steps: first, use xor find all bits have toggled: int alltoggled = oldvalue ^ newvalue; then mask bit want keep - example, shifting alltoggled right, target bit @ position zero, , mask 1 : int targetbittoggled = (alltoggled >> 8) & 1; now combine these 2 expressions single condition: if ((oldvalue ^ newvalue) & (1 << 8)) { // ... bit @ position 8 has toggled } note instead of shifting xor -ed values right shifted bit mask left.

Is there a standard way to get an ActiveRecord item within Ruby on Rails from a given URL? -

is there standard way activerecord item in ruby on rails given url? have data in external rdf database can query urls items in ruby on rails code. want hold of activerecord objects belonging these urls inside ruby on rails program. example of query results database: "http://localhost:3000/data_files/5", "http://localhost:3000/assays/3", "http://localhost:3000/assays/5" i know parse , call: datafile.find(5) assays.find(3) assays.find(5) but thought there might standard bit of code this. can see have multiple types of object search for, , need right object type using id number. on basic example should work. def get_object_from_url url_string class_string = url_string.split('/')[-2] object_id = url_string.split('/')[-1] class_string.camelize.constantize.find_by_id(object_id) end would require more complicated logic depending on url's.

ruby on rails - Having trouble running rspec -

so trying learn how write tests, having them @ work soon. i following guide here: http://everydayrails.com/2012/03/19/testing-series-rspec-models-factory-girl.html and trying run command, quarter of way down page rspec spec/models/contact_spec.rb so first ran problem on large app @ work, ran issues. decided follow steps smaller app working on. still ran issues. created brand new app, (just did 'rails new' , tinkered gem files). blank rails app, again went through tutorial reading, , again when got command, ran issues. the error is: (followed 10 lines of gem file errors don't think need listed) /users/kdweber89/.rvm/gems/ruby-2.1.5/gems/rspec-core-3.2.2/lib/rspec/core/configuration.rb:1226:in `load': cannot load such file -- /users/kdweber89/desktop/railspractice/rspectesting/spec/models/spec/models/contact_spec.rb (loaderror) i have no idea doing wrong this, since have followed tutorial best can. could take quick @ me? look @ path in error m...

Bash script - String within a string as option value -

i using nfcapd capture netflow export packets. has -x option call program when new flow output file available. want call nfdump whenever new file becomes available, run nfcapd this: #!/bin/bash t="nfcapd -p 5566 -l /root/nfcapd_log/ -t 5 -x \"nfdump -r %d%f \"" echo $t eval $t which calls nfdump fine see output on screen. i pass path new file nfcapd -r option in nfdump. my problem need pass fmt: %ts %te %td %pr %sa %da %sp %dp %ra %in %out %pkt %ipkt %opkt %ibyt %obyt %fl %dir %ismc %odmc %idmc %osmc argument nfdump string tell type of flow information want, needs in quotes. have experimented escaping quotes getting nowhere. script far: #!/bin/bash t1="nfcapd -p 5566 -l /root/nfcapd_log/ -t 5 -x \"nfdump -r %d%f -o \\\"fmt: %ts %te %td %pr %sa %da %sp %dp %ra %in %out %pkt %ipkt %opkt %ibyt %obyt %fl %dir %ismc %odmc %idmc %osmc\\\" \" " echo $t1 eval $t1 but nfdump doesn't format information printed. i new bash ...

jql - Jira / Cards assigned to a user in a given timeframe -

we use jira extensively in our project, , attempting create custom reports should list cards assigned user within given timeframe. for example: cards worked on in august 2014. is possible without direct db access? p.s. have tried playing update timestamp, yet list cards assigned me anytime not in timeframe interested in. not work --> assignee = currentuser() , updated > "2014/08/01" , updated < "2014/10/31" should like: assignee currentuser() during ("2014/08/01", "2014/10/31") from looking @ advanced searching documents .

c++ - Delete a file instead of marking it for deletion -

i writing service windows (from xp 8.1). need recursively delete folder , use deletefile , removedirectory that. don't want use shfileoperation because has max_path limit. the problem sometimes, removedirectory fails error_dir_not_empty , if directory empty. found out because deletefile works asynchronously, "marks" file deletion. therefore, adding small delay (sleep) before calling removedirectory fixes issue. looking cleaner method. so, there way ensure marked files , deleted? i tried call flushfilebuffers directly on directory, without success. edit: claiming ntdeletefile can delete file if there handles open on it. checked , it's wrong, @ least on windows 8.1: file removed when handles closed. i don't want use shfileoperation because has max_path limit. on vista+, can (and should) use ifileoperation instead of shfileoperation() . not limited path length limitations, , can used safely in service, unlike shfileoperation() : ...

php - Wordpress - Passing a class method to the query_var hook -

i have following code in wordpress try , achive stage can use esc_url(get_permalink() . '?month=' . get_query_var('month')); . in attempt learn more wordpress , make class allow me add more values , when need them, created following class , linked query_vars filter: //create needed vars // $custom_query_values = array('month','day'); new _custom_query_vars($custom_query_values); class _custom_query_vars { public $_custom_vars; function __construct($custom_vars){ $this->_custom_vars = $custom_vars; add_filter('query_vars',array(&$this, '_add_custom_querys')); } public function _add_custom_querys(){ // return array of values // foreach($this->_custom_vars $value) { $vars[] = $value; } print_r($vars); return $vars; } } /*function add_custom_query_var( $vars ){ $vars[] = "month"; $vars[] = "day...

javascript - Off centered Bootstrap Collapsable panel -

Image
i have bootstrap collapsible panel off centered indicator arrow. center arrow. here's css im using: .panel-heading a:after { font-family:'glyphicons halflings'; content:"\e114"; float: right; color: grey; } .panel-heading a.collapsed:after { content:"\e080"; } <div class="panel panel-default" id="pnlsubmission"> <div class="panel-heading"> <h4 class="panel-title" style="text-align:center;"> <a data-toggle="collapse" data-target="#collapsefour" href="#submission" class="collapsed"><h3>submission<span style="color:#ffcc33">.</span></h3></a> </h4> </div> <div id="collapsefour" class="panel-collapse collapse"> <!-- <div class="pane...