Posts

Showing posts from September, 2012

jquery - How to Work with Twitter API -

i want json of national geographic channel , i'm creating template jquery , making live feeds of twitter on web page. this page want json https://twitter.com/natgeo and i'm using https://api.twitter.com/1.1/search.json?q=natgeo search json code says {"errors":[{"message":"sorry, page not exist","code":34}]} please if have time, focus on pairs of sets of name / value ; ordered lists of values twitter @natgeo. gwenaƫlle sachet

eclipse - FATAL EXCEPTION: main while Android application running -

i'm total newbie , i'm studying @ time make android applications. used 1 of tutorials. things well, reasons application began crush every time i'm going launch it. i tried hard see in logcat reason didn't manage to. grateful if tell me going on. here logcat: 08-30 19:13:21.955: w/dalvikvm(7272): threadid=1: thread exiting uncaught exception (group=0x41869d58) 08-30 19:13:21.955: e/androidruntime(7272): fatal exception: main 08-30 19:13:21.955: e/androidruntime(7272): process: alesto.androidinterview, pid: 7272 08-30 19:13:21.955: e/androidruntime(7272): java.lang.runtimeexception: unable start activity componentinfo{alesto.androidinterview/alesto.androidinterview.simplequestion}: java.lang.nullpointerexception 08-30 19:13:21.955: e/androidruntime(7272): @ android.app.activitythread.performlaunchactivity(activitythread.java:2209) 08-30 19:13:21.955: e/androidruntime(7272): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2259) 08-3

android - Reduce ImageSpan height and width -

i'm setting image drawable spannablestring textview image comes out larger text making weird. need reduce size of imagespan such it's same height text: here's i've tried: drawable.setbounds(0, 0, drawable.getintrinsicwidth(), drawable.getintrinsicheight()); spannablestringbuilder builder = new spannablestringbuilder(holder.temptext.gettext()); builder.setspan(new imagespan(drawable), selectioncursor - ":)".length(), selectioncursor, spannable.span_exclusive_exclusive); holder.temptext.settext(builder); holder.temptext.setselection(selectioncursor); holder.caption.settext(builder); you need measure textview 's height , use instead of intrinsic bounds: int lineheight = holder.temptext.getlineheight(); drawable.setbounds(0, 0, lineheight, lineheight);

java - Can't get OnTouchListner to work -

i trying create first android game (in eclipse) , cannot seem ontouchlistner work, because don't know how or create it. trying figure out taps screen. can please tell me how , create ontouchlistner! activity class: package com.gregsapps.fallingbird; import android.app.activity; import android.os.bundle; import android.view.motionevent; import android.view.view; import android.view.view.ontouchlistener; public class game extends activity implements ontouchlistener{ @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(new gameview(this)); } @override public boolean ontouch(view v, motionevent event) { // todo auto-generated method stub if(event.getaction() == motionevent.){ system.out.println("touch"); } return false; } } view class: package com.gregsapps.fallingbird; import android.r; import android.annotation.sup

ubuntu - Trouble adding ".sh" file to environment . -

i have application requires me start within "bin" folder running follows : ./pio commad i want able run without entering folder , running file "manually" (so say) . how may modify system such file may used following : pio command how go doing ? i newbie linux please provide me answer appropriate skill level . give me principles, give me links, give me clarity . there exists variable called path in every sh/bash session. example: $ echo $path /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games every 1 of directories, declared syntax directory1:directory2:directory3, place bash looks executable when type command. if type mousepad file.txt find executable called "mousepad" in folder /usr/bin . if want program called same way mousepad must either: place in 1 of directories contained in $path place link (symbolic or not) program in 1 of directories `$ sudo ln -s "/home/username/mydir

c++ - Accessing struct members and arrays of structs from LLVM IR -

if have c++ program declares struct , say: struct s { short s; union u { bool b; void *v; }; u u; }; and generate llvm ir via llvm c++ api mirror c++ declaration: vector<type*> members; members.push_back( integertype::get( ctx, sizeof( short ) * 8 ) ); // since llvm doesn't support unions, use arraytype that's same size members.push_back( arraytype::get( integertype::get( ctx, 8 ), sizeof( s::u ) ) ); structtype *const llvm_s = structtype::create( ctx, "s" ); llvm_s->setbody( members ); how can ensure sizeof(s) in c++ code same size structtype in llvm ir code? same offsets of individual members, i.e., u.b . it's case have array of s allocated in c++: s *s_array = new s[10]; and pass s_array llvm ir code in access individual elements of array. in order work, sizeof(s) has same in both c++ , llvm ir this: %elt = getelementptr %s* %ptr_to_start, i64 1 will access s_array[1] properly. when compi

html - Update webpage to show progress while javascript is running in in a loop -

i have written javascript takes 20-30 seconds process , want show progress updating progress bar on webpage. i have used settimeout in attempt allow webpage re-drawn. this how code looks like: function lengthyfun(...){ for(...){ var progress = ... document.getelementbyid('progress-bar').setattribute('style',"width:{0}%".format(math.ceil(progress))); var x = ... // processing settimeout(function(x) { return function() { ... }; }(x), 0); } } it not work, know why not work, don't know how refactor code make work. as know, problem here main process (the 1 takes lot of time), blocking rendering. that's because javascript (mostly) mono-threaded. from point of view, have 2 solutions this. first 1 cut down main process different parts , rendering between each of them. i.e. have (using promises) : var processparts = [/* array of func returning promises */]; function start(){ // call first proc

python - get empty list when finding last match -

i want find last word between slashes in url. example, find "nika" in "/gallery/haha/nika/7907/08-2015" i wrote in python code: >>> text = '/gallery/haha/nika/7907/08-2015' >>> re.findall(r'/[a-za-z]*/$', text) but got empty list: [] and if delete dollar sign: >>> re.findall(r'/[a-za-z]*/', text) the return list not empty '/haha/' missed: ['/gallery/', '/nika/'] anybody knows why? use lookarounds in re.findall(r'(?<=/)[a-za-z]*(?=/)', text) see demo $ means end of string getting empty string. haha missing because capturing / , / not left haha . when use lookarounds 0 width assertion , not consume / , captured.

java - Spring loading beans which are based on application.properties from a sub-module -

i have 2 spring modules, parent module has child modules dependency. both projects has own spring annotated beans , beans created using @bean . project child has child.properties in ressources, file used set properties bean in child project. project parent has own parent.properties used create beans in parent projects. => each 2 projects has serviceconfig class annotated @configuration use: parent: @bean public static propertyplaceholderconfigurer configuration(){ final propertyplaceholderconfigurer props=new propertyplaceholderconfigurer(); props.setlocations(new resource[]{new classpathresource("parent.properties")}); return props; } child: @bean public static propertyplaceholderconfigurer configuration(){ final propertyplaceholderconfigurer props=new propertyplaceholderconfigurer(); props.setlocations(new resource[]{new classpathresource("child.properties")}); return props; } now ques

sitemap - How to programmatically retrieve list of all pages in HippoCMS? -

in hippocms, i've created document type , want provide dynamic field list available pages, when creating new page through channel manager in cms (when clicked pages button, there list of pages available). can retrieve list parsing sitemap.xml provided forge-sitemap-based-on-hst-configuration-feed , seems there must better way it. couldn't find information it. please, me can. hippo cms content based cms. means while may have view of pages, pages don't exist such. can check code in sitemap plugin see how done, have check documents see if mapped , mappings see if there documents. have check both ways mappings can done on patterns , need not reference documents @ all. general case of course, situation may simpler.

How to set input field attribute 'readonly' from Angular component -

i want set 'readonly' property of quantity field during keypress on assetid field. <!-- asset id field--> <div class="form-group"> <label for="asset id">asset id:</label> <input autocomplete="off" type="text" class="form-control" id="assetid" name="assetid" formcontrolname="assetid" (keypress)="setassetid()"> </div> <!-- quantity field--> <div class="form-group"> <label for="quantity">quantity:</label> <input autocomplete="off" type="text" class="form-control" id="quantity" name="quantity" formcontrolname="quantity"> </div> here angular function: public setassetid(){ console.log('key changed'); this.form.controls['quantity'].patchvalue(1); this.form.controls['quantity'].set(&#

ios - authenticate_or_request_with_http_token always returning false with AFNetworking -

before_filter :restrict_access def restrict_access authenticate_or_request_with_http_token |token, options| true end end here can see i'm returning true authenticate_or_request_with_http_token , attempt force work. however, i'm encountering extremely strange issue. i'm sending in authorization header value token token=token value here the client here ios app using afnetworking. when ios app calls on localhost:3000, works expected, , not 401 error. with same exact code however, when run on remote server (heroku), 401. however, 401 occurs on remote server when client ios app. when running via paw or postman, works fine. it's mind boggling. here's ios code sets authorization header: [self.operationmanager.requestserializer setvalue:[nsstring stringwithformat:@"token token=%@", accesstoken] forhttpheaderfield:@"authorization"]; why running request ios simulator -> localhost work fine, running same request ios simulato

json - Azure CLI inline parameters not working -

i'm trying pass in parameters inline arm template within powershell using following command: azure group deployment create -f my_arm_template.json -g myresourcegroup -p '{\"slot\":\"blue\"}' --verbose and receive error: error converting value "blue" type 'microsoft.windowsazure.resourcestack.frontdoor.data.definitions.deploymentparameterdefinition'. path 'properties.parameters.slot' i'm using example given page: https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy/ i have tried without escaping quotes example , various other ways every other attempt breaks when trying validate template. update 1: have tried cmd in addition powershell same results. the problem wasn't way escaping json value giving. instead of: {"slot":"blue"} it should have been: {"slot":{"value":"blue"}}

c# - Unrecoverable error while loading a tagger model using nugetpackages -

Image
i have been trying create , run simple program using stanford-corenlp-3.5.2 nugetpackage. however after looking beginner code start have found following code props.setproperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");(link code example : http://sergey-tihon.github.io/stanford.nlp.net/stanfordcorenlp.html ) but whenever console app loads pos fires off runtime error stating not load tagger. i wondering if missing nugetpackages or if there additional setup have go through. (note. time have tried add postagger nuget package error saying class annotation referenced in 2 dlls.) i have found if remove of properties application run correctly new line looks "props.setproperty("annotators", "tokenize, ssplit"); any past runtime error can continue further analyse of sample text appreciated. thank you. attached picture reference.(apparently need more reputation in order post pic when can :) edit have added pictur

ios - How to compare my current location Lat and Log with a radius of 3 miles ? Xcode -

i have user's current location in form of lat , lon in view controller , i'm missing comparing user location file or gpx of location want compare , idea when user drives or place example college app said "welcome blag bla college ... thanks . i'm using xcode , swift . create cllocation object user's location, , 1 second location. use cllocation method distancefromlocation: calculate distance.

variable assignment - output from move constructor class -

class test { char *str; public: test(char *p_str) /**default constructor**/ { cout<<"default\n"; int l = strlen(p_str) + 1; str = (l ? new char[l] : 0); memcpy(str,p_str,l); } test(const test& ob) /**copy**/ { cout<<"copy\n"; int l = strlen(ob.str) + 1; str = (l ? new char[l] : 0); memcpy(str,ob.str,l); } test(test&& ob) /**move constructor **/ { cout<<"move constructor\n"; str = ob.str; ob.str = nullptr; } void my_swap(test &ob1 , test &ob2) /**swap function**/ { swap(ob1.str , ob2.str); } test& operator=(test ob) /**copy called because of pass value **/ { cout<<"copy assignment operator\n"; my_swap(*this,ob);

oauth - Node.js - How to use access / auth tokens? -

i have built first node.js app supposed installed on shopify store. if want see actual code looks (app.js) can view here . it's basic reading through won't hard. i know how authenticate installation of app (following shopify instructions) i don't how authenticate subsequent requests using permanent access token successful installation provides me with. by subsequent requests i'm referring requests either render app or requests install app, though app installed. right now, i'm storing shop's name (which unique) along permanent token shopify sends me in database . don't know if that's necessary . if i'm not mistaken, simply using browser's session ? how do ? , how use token every time request comes through check if valid one? thank help/suggestions! the code below sort of representation of my actual code looks in order give idea of issues : db.once('open', function(callback) { app.get('/', function (req,

java - Downloading Flowplayer Videos With Authentication -

my university has uploaded lecture videos on website. access them, credentials have entered possess. using simple apache server . videos embedded flowplayer , not provide means of downloading them. html source of video page following: <!doctype html> <html> <head> <meta charset="utf-8"> <title>show video</title> <script type="text/javascript" src="https://www.example.com/videos/javascript/jquery.js"></script> <link rel="stylesheet" type="text/css" href="https://www.example.com/videos/css/mta.css?timestamp=1440967823" /> </head> <body> <script src="javascript/flowplayer/flowplayer-3.2.12.min.js"></script> <div style="width: 256px; height: 256px; background-color: #ff00ff" id="player"></div> <script type="text/javascript"> $f("player", "javascript/flowplayer/flowplayer-3.2

Best practice to organize model code in ruby on rails -

in rails model can write many things in single file. (sample model) sample model: class payment < activerecord::base # database assosication has_many :post belongs_to :user # filter before_save :check_full_name # validation validates_presence_of :name # scope scope :is_paid, -> { where(:status => 'paid') } # constents status = { :paid => 'paid', :pending => 'pending', :failed => 'failed' } # methods def get_name # sample code goes here end end in model use database association, filter, validation, scope, functions. but best way organize model. i mean should go first association ? or validation or scope? i don't know if there best practice guideline this. share experience. what is: put constants in top. then, put filters , validators then, comes associations next, comes scopes and after that, methods also, while putting them, keep them in

parse.com - WatchKit Extension Bridging Header errors (in Swift Project) -

Image
i'm using parse framework in project, it works fine no errors in main app bridging-header above, but when try use in watchkit extension bridging-header kinds of errors . any ideas why happening? i'd use parse framework in watch app. this swift project, , created bridging headers adding dummy objective-c file named misc . watchos not have same frameworks ios. not able use parse sdk in watchkit.

regex - Are there any cases when submatch(0) would not work in vim regexp replace? -

i have following source data, on attempting perform global replace via vim's regexp search , replace: "text": [{ "uid": "...", "left": 50, "top": 715, "minsize": 60, "maxsize": 70, "width": "345px", "align": "center", "font": "...", "forbidden": "", "border": true, "printtype": 0 } my search/replace string looks like: :%s/"left": \(\d\+\)/"left": \=submatch(1)*0.66/g effectively, attempting reduce "left" property 66% of current value, in cases. unfortunately, resulting string becomes: "text": [{ "uid": "...", "left": =submatch(1)*0.66, "top": 715, "minsize": 60, &quo

c# - WCF asynchronous call not returning data -

i have problem regarding asynchronous call of wcf web service method. refuses return requested object when called using await operator. calling synchronous counterpart works fine or using result property on task<> object returns. being called wpf app's main thread serves client. didn't play around thread apartments, left generated. don't understand, i've created simple console test app, added same service reference , asynchronous calls work fine. i'm using visual studio 2013. public async task<getcomputerresponse> getcomputer(int computerid) { try { _client = new serviceclient(_endpoint); _client.open(); getcomputerrequest request = new getcomputerrequest() { computerid = computerid }; var result = await _client.getcomputerasync(request); // debugger seems stop execution here, refuses break @ next line /* _client.getcompute

soap - How can I call a ASP.Net made web service without using MSXML? -

i using particular language named “magik”, used use msxml2 run web services in 1 of projects failed use msxml, tried lot of thing make work changing msxml.dll , testing different version of msxml, using msxmlhttpserver , things may think of, somehow ate msdn website didn’t find helpfull. now looking other ways of calling soap webservice, said may post xml web method address parsing , using query string, didn’t succeed so. i can negotiate via tcp/ip, can send xml web service using tcp/ip connection? if there other way job appreciate it. currently connecting magik java application , when need call web service send request java application (there jar file creates data-bus between magik session , java application) have wrote java part using axis technology. hard job , should change lot of things keep project , match small change in web service consume. using msxml easy formerly, sadly not work now! first note can not use get call soap web services post work soap , c

sql - How to get pairs from sqlite -

i database , playing sqlite3 group project. i have 2 tables this: table 1: tv_show_id, tv_show_rating table 2: tv_show_id, cast_id each tv_show has 1 unique id, in table 2 there multiple cast_ids each tv_show so have this: table 1: 1234, 90 5678, 88 table 2: 1234, "person 1" 1234, "person 2" 5678, "person 1" 5678, "person 3" i want following results: (person a, person b, # of shows together) (person 1, person 2, 1) (person 1, person 3, 1) (person 2, person 1, 1) (person 2, person 3, 0) (person 3, person 1, 1) (person 3, person 2, 0) how can use joins these results? you can try this. fiddle select z.id,count(w.show_id) ( select distinct concat(x.cid,',',x.did) id ( select tt.cast_id cid,ttt.cast_id did t2 tt,t2 ttt tt.cast_id <> ttt.cast_id ) x left join t2 on x.cid = t2.cast_id ) z left join (select show_id, group_concat(cast_id order cast_id) cid t2

ios - SideMenuBar dont load -

Image
i have sidebar menu made tableview . when user click on 1 cell sidebar , shows tableview categories (check image below). problem i'm facing click on cell sidebar , loads right viewcontroller , if click again not load, knows column same one, nothing. i think problem in sidebar not load content because knows same indexpath . no? thank you screen : my sidebar code: import uikit import parse var opcoessidemenu: [string] = ["inicio","perfil","restaurantes","categorias","meu restaurante","sair"] class mymenutableviewcontroller: uitableviewcontroller { var selectedmenuitem : int = 0 override func viewdidload() { super.viewdidload() // customize apperance of table view tableview.contentinset = uiedgeinsetsmake(64.0, 0, 0, 0) // tableview.separatorstyle = .none tableview.backgroundcolor = uicolor.clearcolor() tableview.scrollstotop = false // preserve selection between presentat

c# - Can't edit Form1 textbox from Form2 -

this question has answer here: how update textbox in form1 form2? 3 answers in form1 have textbox filled char array values (*). in form2 change 1 of array values (change * letter) , have update form1 textbox. when press button - nothing happens. form2 code snippet: private void button2_click(object sender, eventargs e) { .... .... letter = (char)form1.number; textbox1.text = letter.tostring(); //shows me letter i'm replacing '*' } private void button3_click(object sender, eventargs e) { frm1 = new form1(); form1.chararray[convert.toint32(frm1.numericupdown2.value)] = letter; //which array value i'm changing frm1.textbox2.text = string.empty; (int = 0; < frm1.numericupdown1.value; i++) { frm1

How to increase volume android -

i'm trying increase/decrease volume on nexus player. made sample app works on phone , other android devices in house. not nexus player. after reading on guess google has blocked how. there methods using root enable this. here's current code use on phone. @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); textview = (textview)findviewbyid(r.id.textview); volumedown = (button)findviewbyid(r.id.volumedown); volumeup= (button)findviewbyid(r.id.volumeup); audiomanager = (audiomanager)getsystemservice(context.audio_service); currentvolume = audiomanager.getstreamvolume(audiomanager.stream_music); volumeup.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { /* audiomanager.adjuststreamvolume(audiomanager.stream_music, audiomanager.adjust_raise, 0);*/ audiomanager.adjustvol

Cassandra split brain partition -

we running 6-node cassandra cluster across 2 aws availability zones (ap-southeast-1 , ap-southeast-2). after running happily several months, cluster given rolling restart fix hung repair, , each group thinks other down. cluster information: name: megaportglobal snitch: org.apache.cassandra.locator.dynamicendpointsnitch partitioner: org.apache.cassandra.dht.murmur3partitioner schema versions: 220727fa-88d2-366f-9473-777e32744c37: [10.5.13.117, 10.5.12.245, 10.5.13.93] unreachable: [10.4.0.112, 10.4.0.169, 10.4.2.186] cluster information: name: megaportglobal snitch: org.apache.cassandra.locator.dynamicendpointsnitch partitioner: org.apache.cassandra.dht.murmur3partitioner schema versions: 3932d237-b907-3ef8-95bc-4276dc7f32e6: [10.4.0.112, 10.4.0.169, 10.4.2.186] unreachable: [10.5.13.117, 10.5.12.245, 10.5.13.93] from sydney, 'nodetool status' reports singapore nodes down: datacenter: ap-southeast-2 =

javascript - autocomplete is not a function Rails 4 -

there tons of discussions topic, don't see answer fits particular situation. in rails 4 application, trying use "autocomplete" jquery ui, this: $(function() { $(".donor_name").autocomplete({ source: '/donors/?format=json' }); }); the javascript console error is: uncaught typeerror: $(...).autocomplete not function which seems saying, isn't finding jquery ui. gemfile: group :assets gem 'jquery-ui-rails' end gem 'jquery-rails' and in app/assets/javascripts/application.js, //= require jquery //= require jquery_ujs (i tried require jquery-ui wasn't recognized) versions: jquery-rails 4.0.4 jquery-ui-rails 5.0.5 perhaps has seen before? update. @marsatomic, using gems, , other person, did follow directions in gem documentation. installation somehow doesn't find "jquery-ui". hoping had seen problem before. you first need jquery ui installed. rails gem , instruction

javascript - Angular $q Service - Limiting Concurrency for Array of Promises -

might give bit of background context problem: i'm building angular service facilitates uploading chunks of multipart form data (mp4 video) storage service in cloud. i'm attempting limit number of unresolved promises ( put requests of chunk data) happening concurrently. using $q.all(myarrayofpromises).then()... listen chunk upload promises being resolved, , return asynchronous call ( post complete file) when happens. think i'm encountering race condition algorithm, because $q.all() gets called before jobs have been scheduled files lot of chunks, succeeds smaller files. here's alogorithm. var uploadinchunks = function (file) { var chunkpromises = []; var chunksize = constants.chunk_size_in_bytes; var maxconcurrentchunks = 8; var startindex = 0, chunkindex = 0; var endindex = chunksize; var totalchunks = math.ceil(file.size / chunksize); var activepromises = 0; var queuechunks = function () { while (activepromises <= maxconcu

java - PyCharm startup failure -

my pycharm fails startup after reboot of system updates, disappears after showing splash screen. when tried start command line, shows following error: c:\program files (x86)\jetbrains\pycharm community edition 4.5.3\bin>pycharm.bat java hotspot(tm) server vm warning: ignoring option maxpermsize=250m; support removed in 8.0 start failed: internal error. please report https://youtrack.jetbrains.com java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:497) @ com.intellij.ide.bootstrap.main(bootstrap.java:39) @ com.intellij.idea.main.main(main.java:83) caused by: java.lang.exceptionininitializererror @ com.intellij.util.ui.uiutil.isunderdarcula(uiutil.java:129