Posts

Showing posts from July, 2012

node.js - Login With Evernote -

im trying connect evernote meteor. but im having bad time, trying oauth token, trying follow example evernote sample meteor , pretty old (2 years), try follow , idea. i can connect evernote, login page , email verification, problem raised on meteor method. handlecallback , wich need "verify" param, wich in case ouath_token second try. on evernote npm readme suggest use oauthjs, , try code. var hostname = "http://sandbox.evernote.com"; var options,oauth; options = { consumerkey: 'xxxxxxxxx', consumersecret: 'xxxxxxxxx', callbackurl : 'http://localhost:3000/oauth/auth', signaturemethod : "hmac-sha1", }; oauth.request({'method': 'get', 'url': hostname + '/oauth', 'success': function(data){ console.log(data); }, 'failure': function(data){

jquery - Using Datatable's server side processing with Django Templates -

i have been using datatables on django implementation. tables displayed on web pages have gotten big enough need enable server side processing take load off client side. unable datatables work server side processing. urls.py: urlpatterns = patterns('', url(r'^get_customers$', views.get_customers, name = "get_customers"), ) views:py def get_customers(request): json_test = json.dumps({ "draw": 1, "recordstotal": 1, "recordsfiltered": 1, "data": [ "test", "test", "test", "test" ]}) return httpresponse( json_test, content_type="application/json" ) template: <table id="table_id" class="t

javascript - RegEx to find inner content of [code] tags -

if have string value of this: [code] hi [/code] i can use regex tag , middle content: /(?:(\[code\]))([\s\s]*)(?:(\[\/code\]))/gi but if have string value multiple [code] tag sets returns single match instead of multiple: [code] hi [/code] [code] hello [/code] i'm running regex through text.replace parse middle content like: text.replace(re, function(match, open_tag, middle, close_tag) { //do stuff here return open_tag + middle + close_tag; }); but said, it's not being there 2 separate code sets, single , that's use of \s matching everything. how parse properly? quick jsfiddle: http://jsfiddle.net/rutsk28l/ simply use non-greedy variant: /(?:(\[code\]))([\s\s]*?)(?:(\[\/code\]))/gi regex101 demo the ungreedy unifier *? unifies 0 or more, least possible. you can furthermore omit capturing of [code] blocks in brackets: /\[code\]([\s\s]*?)\[\/code\]/gi regex101 demo making regex bit shorter , more readable.

jquery - How can I hook into a true "OnChanged" event for an HTML Textbox (Input type Text)? -

i have following jquery, intent of replacing alert custom validation code has been entered in textbox: $(document).on("change", '[id$=txtbxssnoritin]', function () { alert('the textbox change event occurred'); }); however, event fires/the alert seen when "textbox" loses focus. entering value not invoke event; leaving control/element fires event. should using event (other "change") or how can capture each change of content? i don't want let user type in "warble p. mcgokle" , then, after tab out or click elsewhere, tell him/her/it value entered invalid. that's surefire way mugshot plastered onto center of company dartboard. update in jsfiddle, tymejv's script did work me; actually, changed to: $(document).on("input", "textarea", function() { alert('you entered ' + this.value); }); ...but doesn't work me (in project/webpart): $(document).on("input", &

How to read a String from user in java (Socket Programming) -

i writing client/server program. when tried read string client using scanner.nextline() not wait write text on console , process next statement. writing program in binary i/o because more efficient text i/o. datainputstream fromserver = null; dataoutputstream toserver = null; scanner scanner = new scanner(system.in); try{ socket = new socket("localhost",8000); toserver = new dataoutputstream (socket.getoutputstream()); fromserver = new datainputstream ( socket.getinputstream()); } catch(ioexception e){ system.out.println(" error in connection: " + e); e.printstacktrace(); } system.out.println("connection established..."); try{ //this not processing settext = scanner.nextline(); toserver.writeutf(settext); toserver.flush(); // area server double area = fromser

r - All column names are in one cell -

this code. point find blank rows in 1 column, in case defined address.1, , replace corresponding row 1 of 2 other columns, defined here rf_ms_address1 , rf_ghq_address1: withblanks <- read.csv("file.csv", stringsasfactors = false) fun <- function(x, y, z) { y[y == ""] <- z[y == ""] #substitute missings in y values z x[x == ""] <- y[x == ""] #substitute missings in x values y x #return } noblanks <- within(withblanks, "address.1" <- fun("address.1", "rf_ms_address1", "rf_ghq_address1")) write.table(noblanks, "file.csv", sep = ",", col.names = true, row.names = false) the resultant file has headers in single cell, separated period. example: "contactid.email.address.first.name.middle.name.etc." naturally want them in separate cells, right file unusable. doing wrong result? this sample representation of first row: contactid.email.addr

Database Trigger doesn't save -

i'm new triggers. i'm trying write trigger using sql server 2014. here code create trigger deletetrigger on student delete delete [stu-course] [stu-course].sid in ( select deleted.sid deleted ) go i right click on database triggers in path mydatabase ->programmability ->database triggers , select new database trigger , write code there. doesn't save; , when click on database triggers again , there no sign of trigger. should do? the reason can't find under database triggers folder it's dml trigger, not database trigger (these ddl triggers). note create trigger page on msdn: server-scoped ddl triggers appear in sql server management studio object explorer in triggers folder. folder located under server objects folder. database-scoped ddl triggers appear in database triggers folder. folder located under programmability folder of corresponding database. if have executed create trigger script, , did not errors (the syntax looks ok me

c++ - initialize char array with quotes and curly braces -

i'm little confused. logically difference between these codes? #include <iostream> using namespace std; int main(){ char a[5]="abcd"; // cout << a; return 0; } second is char a[5]={"abcd"}; // third is char a[5]={'a','b','c','d'}; // char a[5]={"abcd"}; char a[5]={'a','b','c','d','\0'}; in both cases, array of characters a declared size of 5 elements of type char: 4 characters compose word "abcd" , plus final null character ('\0') , specifies end of sequence , that, in second case, when using double quotes (") appended automatically.attention adding null character separating via commas. series of characters enclosed in double quotes ("") called string constant . c compiler can automatically add null character '\0' @ end of string constant indicate end of string. source: this link can bett

javascript - How to put RGBA background above the image or div area? -

Image
i need use rgba background above grid. used of jquery interect div area. don't know how put background-color in image while i'm using jquery. there way can using jquery ? or other methods ? // grid function $(function() { $(".single_grid").hover(function() { var panelid = $(this).attr("data-panelid"); $("#" + panelid).css({}).toggle(); }) $(".single_grid").mouseover(function() { var imageid = $(this).attr("data-imageid"); $("#" + imageid).css({ opacity: "0.3" }) }) $(".single_grid").mouseleave(function() { var imageid = $(this).attr("data-imageid"); $("#" + imageid).css({ opacity: "1" }) }) }) .grid_panel { width: 100%; height: auto; } #sub_grid_panel { height: 760px; margin: 0 auto; width: 1125px; } #sub_grid_panel li { float: left; } .single_grid { width:

Making use of docker for development: a use case -

my question little vague tried looking answer here , there not understand if can leverage docker work. requirements try different versions of java, python , other software different versions of eclipse, linux package , other tools. @ end make ubuntu installation complete mess , time broken. started using vm solve of problem make pc slow frequent switching. so question can achieve work using docker without affecting os? can run gui application, install different package without affecting underlying os. switch actively between different docker container , underlying os. clean/remove unused/broken install of docker instance (containers?) etc. pointer similar use case or how helpful. thanks. ps- if doesn't fit please move best fitted. sorry non programming question. can done? yes, there examples of docker images run graphical application, running containers might bit tricky. see instance can run gui apps in docker container? is docker right tool problem ? m

html - How to control how a div displays regardless of its contents? -

i have div displays html comes database. unfortunately, html database can potentially screw layout of entire page. is iframe full proof option making sure outer container appears in proper place , without affecting other items on page? or there strategies making sure outer div appear in proper place in proper size regardless of contents? you add following style misbehaving div: div{ max-width: 500px; // adjust liking overflow: hidden; // prevents strings seeping out div } you can same max-height, that's less necessary in cases.

javascript - JS - Adding arrays to an array with variable name manipulation using for -

so have arrays (in reality have 30-40): var p1 = ["john", "bio", "john.png"]; var p2 = ["kate", "bio", "kate.png"]; var p3 = ["mary", "bio", "mary.png"]; which have respective information each person want use in html. i want add each of these arrays array have final result of: var people = [["john", "bio", "john.png"], ["kate", "bio", "kate.png"], ["mary", "bio", "mary.png"]]; is there way of adding these p1 , p2 , p3 arrays people array using loop? i tried this: for (var = 1; <= 30; i++) { var topush = "p" + i; people.push(topush); } but creates , pushes strings array. how can around this? thanks! you should start people array instead of creating individual variables each array create arrays this: var people = new array

sql server - Inserting Dataset + additional columns into a table -

this seems pretty straightforward problem life of me, can't seem figure out how this. i have dataset [a combination of union's] needs inserted table. dataset: select col1 a, col2 b, col3 c union select col1 a, col2 b, col3 c table structure: create table tbl1 varchar(50), b varchar(50), c varchar(50), userid varchar(50), timestamp timestamp i'm trying: insert tbl1 --syntax error here (select col1 a, col2 b, col3 c union select col1 a, col2 b, col3 c) --syntax error here ,'user' ,getdate() i syntax errors on line select starts , ends [comments] is there way of doing this? you're gonna want make union subquery. insert tbl1 select a, b, c, 'user', getdate() ( select col1 a, col2 b, col3 c union select col1 a, col2 b, col3 c ) r

java - Appending to a file in android -

the question how append existing file. i'm using mode_append fileoutputstream fos = openfileoutput("filename", mode_append);. file created , object saved ,but when call method again on same file - nothing happens. mode_private works 1 insert creates new file every time it's called. spent whole day researching , couldn't find answer desperate help. public void createfile (view v) throws ioexception, jsonexception { jsonarray resultslog = new jsonarray(); jsonobject exercise2; string pickval1 = stringarray[numpick1.getvalue()]; string pickval2 = stringarray[numpick2.getvalue()]; string pickval3 = stringarray[numpick3.getvalue()]; string pickval4 = stringarray[numpick4.getvalue()]; exercise2 =new jsonobject(); exercise2.put("rep", pickval1 + " kg " + pickval2 + " kg " + pickval3 + " kg " + pickval4 + " kg "); exercise2.put("type", caller + " on

ios - ResearchKit stepResult for a TextChoiceQuestion -

i'm using researchkit's stepresultforstepidentifier method other question types, can't find correct syntax pre-populate results textchoicequestion. below unsuccessful attempt @ setting result sample textchoice question in orkcatalog. advice on correct approach? func stepresultforstepidentifier(stepidentifier: string) -> orkstepresult? { var stepresults = [orkquestionresult]() if stepidentifier == "textchoicequestionstep" { var questiondefault = orkchoicequestionresult(identifier: stepidentifier) questiondefault.choiceanswers?.append("choice_2") stepresults.append(questiondefault) } var defaults = orkstepresult(stepidentifier: stepidentifier, results: stepresults) return defaults } is choiceanswers array nil ? when questiondefault.choiceanswers?.append , choiceanswers might nil , might nothing. instead questiondefault.choiceanswers = ["choice_2"]

How to set an "empty" element in any part of an Array in C -

i'm doing program insert numbers in array, simple thing here, exemple: if(menu==1){ system("cls"); result=lastposition(array,20); if(result==25){ printf("\n error! array full!"); printf("\n press enter continue"); getch(); } else{ printf("\n\n\toption 1 selected: \n"); printf("\n type number add array: "); scanf("%i",&value); if(array[0]!=null){ printf("\n first space filled, moving itens"); changeplace(array,20,value); printf("\n items moved success!\n"); }else { array[0] = value; } printf("\n number %i added!\n",value); printf(" press continue.\n"); getch(); } so, is, type number, , inserts in 20 positions array, in first position (thats why function "lastposition&q

java - How do I stop my sound/music from playing in another frame? -

i used following code play song it's 11 minutes long how can stop it? this code in jframe 1. how can make stop in jframe 2? inputstream test =getclass().getclassloader().getresourceasstream("musics/menu.wav"); audiostream audio = new audiostream(test); audioplayer.player.start(audio); i tried chaning audioplayer.player.start(audio); audioplayer.player.**stop**(audio); no success. normal java naming conventions variables start lower case letters, audio in audiostream audio = new audiostream(test); may misinterpreted class, not local variable. i think this link can stop method, if that's code isn't working. if you're not having trouble stop method nor variable names, suggest use separate class hold audiostream objects , make them static, class in same package can access it. your class this: public class audiohelper { static inputst

C - Is realloc'ing arrays to arrays twice the size efficient in dynamic data structures? -

lately i've been writing lot of code in c , i've noticed, thing takes time in programs resizing dynamic data structures. let's have array characters , want append characters end of array. way: check if there enough memory allocated. if not, realloc array array having twice size (using realloc) if there enough memory now, append characters, else go point 2. i'm wondering if efficient enough. example think of tree structure hold arrays in nodes of tree, , way instead of copying old elements new array before appending something, add newly malloc'ed elements next node of tree , append characters there. way avoid unnecessary copying... so that's 1 way of doing resizing differently. should else or solution of copying old elements new array twice size efficient enough? as "most efficient" questions, way know measure actual performance in real-life conditions. generally speaking, there can big performance gains having items in consecut

c# - How to maintain Start and End index of DataTable -

i have datatable contains 13 rows. want create batch of 5 rows start , end index i want create array or hashtable store start , end index decimal remainder = decimal.divide(dsresult.tables[0].rows.count, 5); var numberofrequests = math.ceiling((decimal)remainder); above code give me out put 3 13 records means 5+5+3 so expected array or hashtable below 0 0 4 1 5 9 3 10 12 first column incremental value, second column datatable row start index third column datatable row end index please suggest me how implement this. try this datatable dt = new datatable(); dt.columns.add("index", typeof(int)); dt.rows.add(new object[]{1}); dt.rows.add(new object[]{2}); dt.rows.add(new object[]{3}); dt.rows.add(new object[]{4}); dt.rows.add(new object[]{5}); dt.rows.add(new object[]{6}); dt.rows.add(new object[]{7}); dt.rows.add(new obj

c# - Reference to automatically created objects -

i attempting serialize , deserialize complex object graph: class a contains read property containing immutable array of objects of type b . objects of type b , immutable array, created in constructor of type a . other types contain references objects of type b obtained accessing array of object of type a . during deserialization, need references b end pointing @ appropriate object created a constructor index, rather making brand new b objects json. i'm trying use preservereferenceshandling json.net. understandably not work, because attempts use deserialized versions of b rather a -constructed versions. is there strategy can use here without modifying types? edit: clarify , make extremely clear, solution must not modify type itself. can touch contract resolver, binder, reference resolver, etc. not type. also, b types cannot deserialized. must made a 's constructor. update your question doesn't give example of trying accomplish, i'm guess

c++ - Trying to calculate ASCII code sum of my "sir" (string) class -

#include <iostream> #include <string.h> using namespace std; class sir{ int lung; //sir lenght char* sirul; //pointer first character form sir public: sir(const char*);//constructor,for test ~sir();// destructor char operator[](int index); int cod(); }; int sir::cod() { sir u=*this; char* s=sirul; int i,sum,l=lung; if (lung=0) cout<<"ascii code sum 0"; else { for(i=0; i<l; i++) { sum=sum+int(s[i]); } } return sum; } sir::sir(const char* siroriginal) { int lungime=strlen(siroriginal);//string length lung = lungime+1; sirul = new char[lung]; strcpy(sirul,siroriginal); } sir::~sir(){ delete sirul; } char sir::operator[](int index){ if(index<lung && index >=0)return sirul[index];//verificare minima, verific daca este in limite return '\0'; }

SharePoint 2013 file upload with Jquery -

i developing page users able upload local machines files sharepoint 2013 server. currently have managed experiment ajax calls , use rest api creating simple .txt files , additional folders. the problem facing response getting when trying upload .doc file or other file using arraybuffer data. here code (which again working data passed simple string: url = "http://temp-sharepoint/_api/web/getfolderbyserverrelativeurl('documents')/files/add(overwrite=true,url='"+filename+"')"; jquery.ajax({ url: url, type: "post", data: arraybuffer, processdata: false, headers: { "accept": "application/json; odata=verbose", "x-requestdigest": jquery("#__requestdigest").val(), "content-length": arraybuffer.bytelength },

Can the Pebble timeline be used via Pebble.js? -

it's unclear whether timeline features supported when using pebble.js approach (e.g. no c code). can comment? yes, can use pebble.js call regular pebblekitjs functions (e.g., pebble.gettimelinetoken ). as far pushing pins timeline, pins pushed via timeline web api, means can use ajax function make request api within pebble.js.

android - gradle - library duplicates in dependencies -

i have android project gradle. problem is: in project view see few versions of support-v4 libraries, example support-v4-21.0.3 , support-v4-22.2.0 . but in build.gradle don't have support-v4 @ all. but have ~10 other dependencies in build.gradle . example appcompat-v7:22.2.0 . can suggests appcompat-v7:22.2.0 depens on support-v4-22.2.0 in maven dependencies , implicitly pulls it. have no ideas pulls support-v4-21.0.3 . as far know libs packed in apk , increase weight of apk. so have next questions: how avoid library duplicates? how see maven dependencies in android studio? how detect library require library? example library require support-v4-21.0.3 in project? to find duplicate dependencies or required dependencies , can visualize library dependencies in tree. execute gradle command below. gradle -q dependencies yourproject:dependencies --configuration compile note that, run gradlew in windows below. gradlew -q dependencies yourproject:d

java - Apache FELIX JAX-RS Change context path -

i develop rest web service , expose in bundle under felix. i'm using jax-rs connector web service. service works fine if want access resource template url http://ip:port/services/path/to/my/resource the goal change context path services access resource url http://ip:port/path/to/my/resource i tried change admin config has been described in faq of jax-rs connector still have problem servicereference configurationadminreference = bundlecontext.getservicereference(configurationadmin.class.getname()); if(configurationadminreference != null) { configurationadmin confadmin = (configurationadmin) bundlecontext.getservice(configurationadminreference); if(confadmin != null) { configuration configconnector = confadmin.getconfiguration("com.eclipsesource.jaxrs.connector",null); dictionary<string, string> props = configconnector.getproperties() if (props == null) { dictionary<string, string> props = new hashtable&

Java- How to fix my exception in spring framework? -

import java.awt.list; import java.util.properties; public class collectionexample { private list examplelist; private properties exampleprop; public list getexamplelist() { system.out.println("list element : " + examplelist); return examplelist; } public void setexamplelist(list examplelist) { examplelist = examplelist; } public properties getexampleprop() { system.out.println("list element : " + exampleprop); return exampleprop; } public void setexampleprop(properties exampleprop) { this.exampleprop = exampleprop; } } and main class : public class collectionexample { private list examplelist; private properties exampleprop; public list getexamplelist() { system.out.println("list element : " + examplelist); return examplelist; } public void setexamplelist(list examplelist) { examplelist = example

javascript - How to force an update of a css selector inside context? -

let's have css code: .context-1 .test { background-color: #ff0000; } .context-2 .test { background-color: #00ff00; } .context-3 .test { background-color: #0000ff; } <div class="context-1"> <div class="test"> hello, world! </div> </div> works great. if i'm trying switch .context-1 .context-2 - div.test doesn't update it's background-color . why background color not update? i added complete source code of such case, here is: <script> var xs = [-infinity, 768]; var sm = [768, 992]; var md = [992, 1200]; var lg = [1200, infinity]; var width; $(window).resize(function() { width = $(this).width(); mediaquery(xs, sm, md, lg); }); function mediaquery(xs, sm, md, lg) { if (width >= xs[0] && width < xs[1]) { console.log("xs"); hide_xs(); } if (width >= sm[0] && width < sm[1]) { con

javascript - Finding the ul inside a div and append li tag to that ul using jquery -

i want find ul element inside div , append li tag inside ul using jquery. given below in code parent div id=select_name_chosen,i want find ul class="chosen-results , append li in div using jquery. please solve issue. jquery code using. var parent = $("div#select_name_chosen"); var childul = parent.children('.chosen-results'); childul.append($("<li class='active-results' data-option-array-index='0'>name</li>")); <div class="chosen-container chosen-container-multi chosen-with-drop chosen-container-active" style="width: 350px;" title="" id="select_name_chosen"> <ul class="chosen-choices"> <li class="search-field"> <input type="text" value="select subject" class="default" autocomplete="off" style="width: 110px;" tabindex="4"> </li> </ul> <div class="chosen-dr

adding XY data from SQL database table in client application using Arcgis Javascript -

i trying figure out how take lat/lon information sql database table , use information create map layer using arcgis javascript api. my understanding in order import layers map, data needs come web service. have , arcgis server/portal in can publish , store map services admin, there no intuitive create map layers client application outside of pulling data map service. as of now, registered 1 of our sql databases server recognize db workspace, not know how reference sql table , pull data class in can convert table xy layer add map. i saw there "dataadapterlayer" class , sample esri , not clear how use (also, not work on machine, works on esri site). anybody have clue how add location data sql table? dataadapter layer option? there better way?

html - Cannot show DropDownList in Google Chrome with encoding characters -

i having issue dropdownlist in asp.net , google chrome: in data sources, have values encoding characters: <script>alert('xss')</script> then bind dropwdownlist. dropdownlist contain options after encoding: <!doctype html> <body> <select> <option selected="selected" value=""></option> <option value="1753">&lt;script&gt;alert('xss')&lt;/script&gt;</option> <option value="1758">&lt;script&gt;alert('xss')&lt;/script&gt;</option> <option value="1801">&lt;script&gt;alert('xss')&lt;/script&gt;</option> <option value="2024">&lt;script&gt;alert('xss')&lt;/script&gt;</option> </select> </body> but dropdownlist cannot open in google chrome, still can open in firefox , ie. wrong poi

ios - How to publish a video file on the internet to stream it in an app using swift? -

i'm using code play video in ios app. want able stream video, not have hard copped in. have video file, how publish onto mp4 webpage have streamed in app? here example video webpage ... are there tools online me this? import uikit import mediaplayer // add mediaplayer framework class viewcontroller: uiviewcontroller { var movie:mpmovieplayerviewcontroller? override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. let movieurl:nsurl? = nsurl(string: "http://download.wavetlan.com/svv/media/http/mp4/convertedfiles/mediacoder/mediacoder_test1_1m9s_avc_vbr_256kbps_640x480_24fps_mpeg2layer3_cbr_160kbps_stereo_22050hz.mp4") if movieurl != nil { self.movie = mpmovieplayerviewcontroller(contenturl: movieurl!) } } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. }

regex - replace placeholder tags with dictionary fields in python -

this code far: import re template="hello,my name [name],today [date] , weather [weather]" placeholder=re.compile('(\[([a-z]+)\])') find_tags=placeholder.findall(cam.template_id.text) fields={field_name:'michael',field_date:'21/06/2015',field_weather:'sunny'} key,placeholder in find_tags: assemble_msg=template.replace(placeholder,?????) print assemble_msg i want replace every tag associated dictionary field , final message this: name michael,today 21/06/2015 , weather sunny. want automatically , not manually.i sure solution simple,but couldn't find far.any help? no need manual solution using regular expressions. (in different format) supported str.format : >>> template = "hello, name {name}, today {date} , weather {weather}" >>> fields = {'name': 'michael', 'date': '21/06/2015', 'weather': 'sunny'} >>> template.format(**fields) hello, nam

javascript - background inner ring Google Maps (hole in polygon) -

i have problem polygons inner rings in google maps. i've done several tests , examples not work correctly. this example works correctly: var paths = [[ new google.maps.latlng(38.872886, -77.054720), new google.maps.latlng(38.872602, -77.058046), new google.maps.latlng(38.870080, -77.058604), new google.maps.latlng(38.868894, -77.055664), new google.maps.latlng(38.870598, -77.053346) ], [ new google.maps.latlng(38.871684, -77.056780), new google.maps.latlng(38.871867, -77.055449), new google.maps.latlng(38.870915, -77.054891), new google.maps.latlng(38.870113, -77.055836), new google.maps.latlng(38.870581, -77.057037) ]]; http://jsfiddle.net/5569fn01/1/ and example real data: var paths = [[ new google.maps.latlng(40.432901, -3.693242), new google.maps.latlng(40.432896, -3.693366), new google.maps.latlng(40.432842, -3.694789), new google.maps.latlng(40.432833, -3.694912), new google.maps.latlng(40.432999, -3.6949), new googl