Posts

Showing posts from March, 2012

python - How to covert this binary string to a normal string? -

i have binary string , trying convert normal string. [b'\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe4\xb8\xad\xe5\x9b\xbd\xe9\xa2\x86\xe5\x85\x88\xe7\x9a\x84\xe5\xae\x9e\xe5\x90\x8d\xe5\x88\xb6sns\xe7\xa4\xbe\xe4\xba\xa4\xe7\xbd\x91\xe7\xbb\x9c\xe3\x80\x82\xe5\x8a\xa0\xe5\x85\xa5\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe6\x89\xbe\xe5\x88\xb0\xe8\x80\x81\xe5\x90\x8c\xe5\xad\xa6\xef\xbc\x8c\xe7\xbb\x93\xe8\xaf\x86\xe6\x96\xb0\xe6\x9c\x8b\xe5\x8f\x8b\xe3\x80\x82'] there no normal string mode,string encoding , , string in encoded, based on terminal decoding or custom decoding can real string. as default encoding of terminal utf-8 ,it decode string utf-8 encoding , print result : >>> s=[b'\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe4\xb8\xad\xe5\x9b\xbd\xe9\xa2\x86\xe5\x85\x88\xe7\x9a\x84\xe5\xae\x9e\xe5\x90\x8d\xe5\x88\xb6sns\xe7\xa4\xbe\xe4\xba\xa4\xe7\xbd\x91\xe7\xbb\x9c\xe3\x80\x82\xe5\x8a\xa0\xe5\x85\xa5\xe4\xba\xba\xe4\xb

Unable to retrieve data from meteor collection -

i'm trying retrieve data meteor collection. while being able insert data, data not getting fetched. i'm using iron router. page appears blank without error or warning message in browser console. list-article.js template.articlelist.helpers({ articles: function () { return articles.find(); } // articles: [ // { "articletitle": "title1" }, // { "articletitle": "title2" } // ] }); list-article.html <template name="articlelist"> {{#each articles}} <li>{{articletitle}}</li> {{/each}} </template> connecting meteor mongodb using terminal, data exist: command: db.articles.find(); { "_id" : "ctck6hkfx3nkotae4", "articletitle" : "sdfsdf" } { "_id" : "jyncggxtsfeq9y9bi", "articletitle" : "sdfsdfsdf" } { "_id" : "dgvjdzu4feqraex7a", "articletitle&qu

ios - Collection View vertical padding issue -

Image
i making collection view horizontally scrolled. collection view in uitableview cell my height of collection view 170 making cell of 75x75 -(uiedgeinsets)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout *)collectionviewlayout insetforsectionatindex:(nsinteger)section; return uiedgeinsetsmake(4, 5, 6, 3); } this inset setting. padding top 4 left 5 right 3 , bottom 6. collection view has 20 items horizontally scrolled. problem vertical spacing of items when 2 rows made. want keep minimum. used this - (cgfloat)collectionview:(uicollectionview *)collectionview layout:(uicollectionviewlayout*)collectionviewlayout minimumlinespacingforsectionatindex:(nsinteger)section { return 2.5; } it provided 2.5 padding between various items still vertical padding can see image vertical space between 2 lines of images around 10. want decrease 2.5. did change in return uiedgeinset if increase padding bottom, collection view makes single row dont want. ex

prolog - Compatibility of different clp(FD) library implementations -

is there place can find collection of differences in clpfd implementations? there kind of list of languages support 1 form or of constraint logic programming. denoted clp(*): see section "logic programming based constraint logic": https://en.wikipedia.org/wiki/constraint_programming#some_languages_that_support_constraint_programming whether of languages on list support clp(fd) not sure. wiki page doesn't make comparison matrice. start different systems. there many interesting dimensions of clp(fd) systems: - bignums supported: gnu no, swi-prolog yes, jekejeke yes - negative integers supported: gnu no, swi-prolog yes, jekejeke yes - arithmetic expressions allowed: t.b.d. - set notations allowed: gnu limited, swi-prolog sup/inf, jekejeke sup/inf - reification supported: gnu yes, swi-prolog yes, jekejeke not yet - special constraints supported: gnu cardinality, swi-prolog cardinality , others, jekejeke not yet - labeling parameters: t.b.d. bye

javascript - How to access and click button of popup window? -

i working on adf.ly link bypasser using popup window have 1 problem problem if first goto adf.ly , run code google chrome console it's work if first don't goto adf.ly , run code in example google.com chrome window console it's stop working want click skip button without going adf.ly popup window skiper code below: var newwindow = window.open("https://adf.ly/dkcdx"); newwindow.window.onload = function() { newwindow.focus() settimeout(function() { if(newwindow.window.document.getelementbyid('skip_ad_button')){newwindow.window.document.getelementbyid('skip_button').click();; }else{ //nothing } }, 8000);}; thanks. your problem same-origin-policy . javascript in webpage can not access websites on domain . this why working adfly page, not google. an option implement skipper chrome extension , these can access allowed websites like.

Composer local packages -

Image
i can't composer work local packages. package a: { "name": "package/a", "repositories": [ { "type": "vcs", "url": "../b" } ], "require": { "package/b": "dev-master" } } package b: { "name": "package/b", "repositories": [ { "type": "vcs", "url": "../c" } ], "require": { "package/c": "dev-master" } } package c: { "name": "package/c", } now installing package b works fine , resolves package c properly. installing package fails because can not resolve package c package b, dependency of package a. i couldn't find @google, looks composer can't handle kind of complexity in local packages. i'm wrong. here small illustration better understanding of problem. compos

Call hierarchy does not work on class names or variables Android Studio -

Image
ctrl + alt + h ,call hierarchy works on methods , constructors not work class names , variables unlike eclipse. is there workaround available ? i searched alot did not find solution thanks alt + f7 show usage of classes , variables.

java - GWT: Maven error: jar must be 'pom' to import the managed dependencies -

i made sample gwt app using webappcreator . when running mvn command, example mvn package , getting error: [info] scanning projects... [error] [error] problems encountered while processing poms: [warning] 'dependencymanagement.dependencies.dependency.type' com.google.gwt:gwt:jar must 'pom' import managed dependencies. @ line 21, column 19 [error] 'dependencies.dependency.version' com.google.gwt:gwt-servlet:jar missing. @ line 34, column 17 [error] 'dependencies.dependency.version' com.google.gwt:gwt-user:jar missing. @ line 39, column 17 [error] 'dependencies.dependency.version' com.google.gwt:gwt-dev:jar missing. @ line 44, column 17 [error] 'dependencies.dependency.version' com.google.gwt:gwt-codeserver:jar missing. @ line 49, column 17 @ [error] build not read 1 project -> [help 1] [error] [error] project com.babken.stockwatcher:stockwatcher:1.0-snapshot (/home/void/workspace/stockwatcher/pom.xml) has 4 errors [error

algorithm - Printing lexicographically sorted subsets from a given string -

for ex - if string "abc", answer should ab abc ac b bc c (only lexicographically smallest combination set of characters should appear) have solved problem string containing 15 or more characters, taking lot of time. how can reduce running time of algorithm? here , n length of string. here code: int n = int.parse(console.readline()); var str = console.readline(); string coll = string.empty; coll = coll + " " + str[0]; (int j = 1; j < n; j++) { var items = coll.split(' '); foreach (var item in items) { coll = coll + " " + item+str[j]; } } var tt = coll.split(' ').orderby(a => a); foreach (var item in tt) if (!string.isnullorempty(item)) console.writeline(item); for string of length n, there 2^n po

security - How to obscure sensitive data written in Javascript? -

i have developed web application makes use of google sign-in within angularjs application. since client_id , api_key written in javascript think it's quite easy find them out browser's dev console. apparently it's possible "obscure" js code (e.g. how can obfuscate (protect) javascript? ), concern is: make impossible potential attacker access keys? if not, what's best practice in case? i've heard of kind of backend obscure keys written in js. kind of "gateway" just mention, concerns not google apis code write not "open source" unless decide so edit : since i'm not sure doubt completley clear, here actual question what methodology can use prevent users "stealing" keys? there exist service serves gateway? shall design 1 on own? does make impossible potential attacker access keys you can compress and/or obfuscate process always reversable long application requires plain keys. all code wr

Zend Framework: SetIntegrityCheck(false) and then update the object -

i getting data 2 tables using join , putting setintegritycheck(false) in model. need call save() on object. know when put setintegritycheck(false) , cannot call save() , delete() or update() object. have seen this question, doesn't address answer. so way around? zf supports table data gateway , row data gateway pattern. afaik setintegritycheck() allow join tables within db_table_select build sql query. anyway can not hydrate custom sql results db_table_row objects - supports save() . have update each row separatly. more sofisticated approach have use data mapper pattern - doctrine.

ios - Split NSDate that stretches over several days into several spans -

i have 2 nsdates define span, 1 set them this spana: 12:00 today spanb: 12:00 tomorrow this equals 24 hours, need create 2 ranges instead of one, no spans stretch across midnight. outcome of example above this: spana: 12:00 today spanb: 23:59 today spanc: 00:01 tomorrow spand: 12:00 tomorrow i'm not sure how this. came idea use function this: - (nsinteger)daysbetweendate:(nsdate *)fromdatetime anddate:(nsdate *)todatetime { nsdate *fromdate; nsdate *todate; nscalendar *calendar = [nscalendar currentcalendar]; [calendar rangeofunit:nscalendarunitday startdate:&fromdate interval:null fordate:fromdatetime]; [calendar rangeofunit:nscalendarunitday startdate:&todate interval:null fordate:todatetime]; nsdatecomponents *difference = [calendar components:nscalendarunitday fromdate:fromdate todate:todate options:0]; return [difference day]; } which returns how many days span stretches across, o

naming conventions - Are there best practices for (Java) package organisation? -

a little while ago, saw question answered here regarding fine-grained organisation of java packages. example, my.project.util, my.project.factory, my.project.service etc. i can't find now, may ask question. are there best practices regards organisation of packages in java , goes in them? how organise classes in java project? for instance, project i'm working on few people has package called beans. started out being project containing simple beans, has ended (through poor experience , lack of time) containing (almost). i've cleaned them little, putting factory classes in factory package (classes static methods create beans) have other classes business logic , others simple processing (not business logic) retrieving message code properties file. your thoughts , comments appreciated. package organization or package structuring heated discussion. below simple guidelines package naming , structuring: follow java package naming conventions structure

python - SKLearn SVM : Different Membership Scores for Same Data -

i training svm 2 times, first, data loaded file , data directly assigned in code. this code from sklearn import svm import numpy np x = np.genfromtxt("x.txt",delimiter=" ") y = np.genfromtxt("y.txt",delimiter=" ") fromfile_clf = svm.linearsvc() fromfile_clf.fit(x, y) fromfile_dec = fromfile_clf.decision_function([[1,2,2]]) u = [[1,1, 0], [1,-1, -1], [-1,1,1], [-1,-1,1]] v = [0, 1, 2, 3] direct_clf = svm.linearsvc() direct_clf.fit(u, v) direct_dec = direct_clf.decision_function([[1,2,2]]) print("loaded file") print("x") print x print("y") print y print("membership") print fromfile_dec print("\n\ndata fed directly") print("u") print u print("v") print v print("membership") print direct_dec the output of above code is loaded file x [[ 1. 1. 0.] [ 1. -1. -1.] [-1. 1. 1.] [-1. -1. 1.]] y [ 0. 1. 2. 3.] membership [[ 1.33332130e+00 -2.54545

php - Extending ArrayObject: Why does get_object_vars return an empty array? -

given following class, why get_object_vars return empty array? happens when i'm extending php's arrayobject in documentation can't manage find out reason behavior. class test extends arrayobject { public $foo; public $bar; public function setfoobarvalues( array $values ) { $this->foo = !empty( $values['foo'] ) ? $values['foo'] : null; $this->bar = !empty( $values['bar'] ) ? $values['bar'] : null; } public function getarraycopy() { return get_object_vars( $this ); } } running following code first sets object's values shows get_object_vars not return object's properties. $object = new test( array( 'lemon' => 1, 'orange' => 2, 'banana' => 3, 'apple' => 4 ) ); $object->setfoobarvalues( array( 'foo' => 'x', 'bar' => 'y' ) ); var_dump( $object->getarraycopy() ); expected res

c++ - Sharing data between de-coupled functions\methods without globals -

basically need 2 or more functions reside in different source files , cannot know each other share data. globals instant solution, they're universally frowned upon. they're pretty inevitable in case? here's simplified explanation of need using globals: file1.c int foo; void change_foo() { // calculation determine new value of foo foo = ... } file2.c extern int foo; void use_foo() { // value of foo // not aware of change_foo()'s existence can't call or called } 1) how 1 eliminate need global variable here? making int foo static inside either function instantly couple both functions. defining variable inside main() , calling both functions within main() not option me. 2) there more elegant solution in oo language c++? 2 methods 2 different namespaces need share data. 3) can see problem happening often. 1 noticeable example need share resource or other entity (that cannot serializable in meaningful way) between 2 independent android activ

Go - Logging responses to incoming HTTP requests inside http.HandleFunc -

this follow-up question in go, how inspect http response written http.responsewriter? since solution there requires faking request, works great unit test not on live server. i dump out http response web service returning in response requests receives users log file (or console). output should tell me headers , json payload. how 1 go that? if there httputil.dumpresponse equivalent takes http.responsewriter argument rather http.response perfect, can access header http.responsewriter r = mux.newrouter() r.handlefunc("/path", func (w http.responsewriter, r *http.request) { fmt.printf("r.handlefunc /path\n") resp := server.newresponse() defer resp.close() r.parseform() // server work here // ... // insert debug code here, // // dump = http.dumpresponsefromwriter(w) // fmt.printf("%s\n", dump) }); http.handle("/path", r) middleware chaining a common solution problem called middleware

can we create our own System class in java , if yes then how? -

public void mysystem class{ //here mysystem own system class in place of system class available in java.lang package // } yes, can. write necessary code , you're go. it's same other class.

php - message sending issue via twilio -

i using twilio send message having issue of open ssl extension said that, uncaught exception,open ssl extension not enabled then uncommented open ssl in php.ini file still facing same issue kindly guide me, please.

osx - Sending emails using XAMPP and PHP using Mac Yosemite -

i confused on start sending emails. have search web amount of content available different packages , softwares has confused me. wondering if here had simple or knows of simple tutorial of how can send email using xampp. im new using local host , far have used mysql , apache xampp load , view php files application. i appreciate if me start setting xampp send emails when use php. some sites suggest separate server needed emails such phpmailer while others suggest few config changes need making changing in php.ini files i'm cautious change incase whole xampp crashes! is link good? http://www.websnippetz.com/2013/01/send-email-from-xampp-localhost.html many using sendmail package xampp can't find download that. anyone tried worked them? please confused developer guys! to send emails localhost need email-server postfix or exim or send e-mails on smtp described on site link. the easiest way use abstraction layer swift mailer http://swiftmailer.org/docs/s

c - GtkStatusBar gets stuck at a /random/ position and wants me to mousehover button -

i keep simple i have function inside_thread runs while loop , calls function update_progressbar updates gtkstatusbar . i calling inside_thread in thread using g_thread_new("processing", gthreadfunc, null); callback function on_starter_clicked . it tends job, works fast , updates status bar according progress of while loop. the problem (at unspecified place) progress bar gets stuck , gets unstuck if mouseenter or mouseleave button in application. strange behavior must admit what wrong? no, can't update gtkprogressbar thread. there 2 solutions problem, , both involve gdk_threads_idle_add() : 1. wait idle callback in case,your thread schedule progress bar update gdk_threads_add_idle() , wait finish. don't know best way glib is, there's can (gmutex?). idea this: gboolean updateprogressbar(gpointer data) { gtk_progress_bar_set_fraction(progressbar, value); tellotherthreadtocontinue(); return g_source_remove; // ==

jquery - If input is checked not working -

i want make jquery shoot action triggered click or pressed key while input#show1 checked. way tried below seems simple way check if input checked doesn't work somehow. did wrong in code appreciated! <script> if ($('input#show1').is(':checked')) { alert("show1 checked"); } </script> <input type="radio" id="show1" name="group"> <label for="show1">show</label> <input type="radio" id="hide1" name="group" checked> <label for="hide1">hide</label> two options here, either execute conditional check on dom load or check on change. have to wait on document loaded, can using $(document).ready() call. calling function on click mplungjan suggested work well, though don't it. want happen when value changes unchecked checked, , not when it's checked , it's clicked again. therefore can use change . $(docume

java - How to write method that returns hash set of common string -

how create new hash set combines common string values (case sensitive) 2 other sets? the main method contains: public static void main(string[] args) { set<string> set1 = new hashset<string>(); set<string> set2 = new hashset<string>(); set1.add("blue"); set1.add("red"); set1.add("yellow"); set2.add("blue"); set2.add("red"); set2.add("orange"); } the method header is: public static set<string> buildlist (set<string>set1, set<string>set2){ set<string> set3 = new hasset<string>(); } if understood question correctly need retain common values both hashset if yes use set1.retainall(set2) code: public static void main(string[] args) { set<string> set1 = new hashset<string>(); set<string> set2 = new hashset<string>(); set1.add("blue"); set1.add("re

scala - java.util.NoSuchElementException: Column not found ID in table demo.usertable in Cassandra Spark -

i try write rdd[cassandrarow] existing cassandra table using spark-cassandra-connector. here piece of code val conf = new sparkconf().setappname(getclass.getsimplename) .setmaster("local[*]") .set("spark.cassandra.connection.host", host) val sc = new sparkcontext("local[*]", keyspace, conf) val rdd = sc.textfile("hdfs://hdfs-host:8020/users.csv") val columns = array("id", "firstname", "lastname", "email", "country") val types = array("int", "string", "string", "string", "string") val crdd=rdd.map(p => { var tokens = p.split(",") new cassandrarow(columns,tokens) }) val targetedcolumns = somecolumns.seqtosomecolumns(columns) crdd.savetocassandra(keyspace, tablename, targetedcolumns, writeconf.fromsparkconf(conf)) when run code following exception exception in thre

ios - Swift Call ViewController after url loading finishes -

i'm building app following: user logins username , password, after login retrieve data website through html parsing. these data want pass them other viewcontroller table view controller show data in cells there. i connected login button other viewcontroller seague, can't keep waiting till data available. how can this? override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "supplierdetails" { let detailviewcontroller = segue.destinationviewcontroller supplierdetails detailviewcontroller.data = data } } func postrequest() { self.spinner.hidden = false self.spinner.startanimating() let request = nsmutableurlrequest(url: nsurl(string: "http://example.com/login.aspx")!) request.httpmethod = "post" let poststring = "something" request.httpbody = poststring.datausingencoding(nsutf8stringencoding) let task = nsurlsession.sharedsessio

regex - Opening a file in Ruby - unknown regexp options - Prgra ERROR? -

i trying open file , store contents useable input methods in separate file. specifically, have 1 file "test_int_file.rb", has 1 integer on each line. use each integer input method. i have attempted open file using command in same file methods stored: file.open("/desktop/programs/test_int_file.rb") my plan use following each line separate integer input (stored in array) can pass method: file_arr = [] file.open("/desktop/programs/test_int_file.rb").each_line |line| file_arr << line.to_i end so 2 main questions here: 1) when attempt file.open("/desktop/programs/test_int_file.rb") on mac, error in terminal: unknown regexp options - prgra doing wrong in opening file? 2) block of code above work input file of integers array of integers? thanks in advance!

c++ - Magick++ Error when reading BLOB into Image -

i'm trying export image raw pixel data rgba png using magick++ library. however, i'm getting strange error when i'm attempting run it: terminate called after throwing instance of 'magick::errorcorruptimage' what(): test: unexpected end-of-file `': no such file or directory @ error/rgb.c/readrgbimage/229 aborted this relevant code part (i omitted filling pixel vector, doesn't change anything): #include <iostream> #include <vector> #include <imagemagick/magick++.h> using namespace std; int main(int argc, char *argv[]) { magick::initializemagick(*argv); int rres, ires; cin >> rres >> ires; //rgba //rres: horiz. resolution, ires: vert. resolution vector<unsigned char> image(rres * ires * 4); magick::blob blob(&image[0], rres*ires*4); magick::image img; img.size(to_string(rres) + "x" + to_string(ires)); img.magick("rgba"); img.read(blob); i

javascript - HTML Button Won't Change JS Variable -

using js, on canvas, have ball moving across canvas. works fine. i have created button element in html , want function, "changeballdirection()" called onclick. changeballdirection() should change variable xballdirection, should change direction of ball. the variable xballdirection doesn't change. printed xballdirection on canvas confirm wasn't changing. code below. first time posting, please let me know basic breaches in etiquette may have committed. thanks. <script type="application/processing" data-processing-target="pjs"> void setup() { size(400, 400); }; framerate(20); var r=0; var xballdirection = 1; var changeballdirection = function (direction) { xballdirection = direction; }; //draw ball on canvas , move right void draw() {

php - Wordpress ACF - Get taxonomy values -

i add new custom field load books genres (taxonomy) in "writer" page (category). look @ settings: http://awesomescreenshot.com/0df4qucud7 i need show checked genres on writer page. of coure if theres no checked genres code shows nothing (if tag). how can values? acf plugin: https://wordpress.org/plugins/advanced-custom-fields/ you getting term id's of selected genres. id can field get_field('field_name', 'genre-cat'); in situation genre-cat can replaced output of field term ids (you have each term selected, use foreach statement). see full documentation acf on how values taxonomy term: http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/

c++ - Where is the stack implemented? -

this question has answer here: what , stack , heap? 25 answers c++ allows programer use either stack allocated memory or dynamic memory on heap. clear on how stack operates (i have created stacks exercises in c++) still curious how , "the stack" defined. is "the stack" feature of language, feature of os or feature of hardware? have vague idea each stack relating each of many active thread processes perspective of operating system. suggest me it's implemented on software level , not hardwired feature of cpu or motherboard. i imagine, in case of c++, compiler might have inserted implementation of stack each binary. or maybe os applies it's own stack implementation each running process? how , defined? i found similar question here don't see answered , hope re-state question more directly. "is "the stack" f

Regex for lastname or firstname in rails -

i know question on asked, couldn't find fits in case , works rails. i'm looking simple regex words can contain: letters(no digits) white spaces . (dot) or - (dash) the following regex allows letters, white space, dot , dash: /[a-z\s.-]/i your validation in model be: validates_format_of :first_name, :with => /[a-z\s.-]/i

objective c - pushViewController pushes nil -

i trying push view controller screen. push successful when later try access property of pushed view controller including textboxes , labels, nil . how avoid this? i doing way because need code decide view controller push. appreciated. myvc *vc = [self.storyboard instantiateviewcontrollerwithidentifier:@"myvc"]; [self.navigationcontroller pushviewcontroller:vc animated:yes]; after code you've wrote, need either approach properties this: vc.property = assignedvalue; make sure have synthesized properties, or initialised them setter in vc's viewdidload

asp.net - Database is removed from Microsoft SQL Server, Why? -

i created new empty website in visual studio express 2013. created asp.net folder: app_data. then went sql server management studio. created new database in provided path app_data of website created. i named database "facebookdata" then went visual studio; found database in app_data folder , in server explorer. i went web.config, , under added <connectionstrings> <add name="dataconnectionstring" connectionstring="data source=(localdb)\v11.0;attachdbfilename=|datadirectory|\facebookdata.mdf;integrated security=true" providername="system.data.sqlclient" /> </connectionstrings> i click build -> rebuild solution when close sql server management studio, , reopen again. database named "facebookdata" missed sql server management studio databases list!!!. i still find in visual studio in app_data folder , server express. if close , open sql server management studio before adding web.config.

javascript - Fast way to turn normal js into angular syntax? -

so have app hits gmail api, authorizes then, gets list of of email ids, fetches emails. have written in plain old java script want convert angular. i've watched bunch of videos , read lot of documentation find videos never go far doing this. how structure this? use factory or can drop js in controller method? function handleclientload() { gapi.client.setapikey(apikey); window.settimeout(checkauth,1); } function checkauth() { gapi.auth.authorize({client_id: clientid, scope: scopes, immediate: true}, handleauthresult); } function handleauthresult(authresult) { var authorizebutton = document.getelementbyid('authorize-button'); if (authresult && !authresult.error) { authorizebutton.style.visibility = 'hidden'; makeapicall(); getmessages(); } else { authorizebutton.style.visibility = ''; authorizebutton.onclick = handleauthclick; } } function handleauthclick(event) { gapi.aut

android - AVI/MP4 on videoview -

i trying run avi/mp4 video on videoview in app, when app open appears "can't play video", testing on mobile. videoview = (videoview)findviewbyid(r.id.videoview); mediacontroller mediacontroller = new mediacontroller(this); mediacontroller.setanchorview(videoview); videoview.setmediacontroller(mediacontroller); videoview.setvideopath("/sdcard/"+file); videoview.start(); the log: 03-28 20:52:30.723 8474-8474/mjksites.loopvideo d/mediaplayer﹕ getmetadata 03-28 20:52:30.842 8474-8491/mjksites.loopvideo w/mediaplayer﹕ info/warning (3, 0) 03-28 20:52:32.530 8474-8490/mjksites.loopvideo e/mediaplayer﹕ error (1, -1004) 03-28 20:52:32.538 8474-8474/mjksites.loopvideo e/mediaplayer﹕ error (1,-1004) 03-28 20:52:32.538 8474-8474/mjksites.loopvideo d/videoview﹕ error: 1,-1004 android not support avi video container format - message seeing normal message when try play unsupported video format. see here date list of supported formats: htt

sorting - Instant sort when put new value in array C++ -

i have dynamically allocated array containing structs key pair value. need write update(key,value) function puts new struct array or if struct same key in array needs update value. insert , update combined in 1 function. the problem is: before adding struct need check if struct key existing. i can go through elements of array , compare key (very slow) or can use binary search, (!) array must sorted. so tried sort array each update (sloooow) or sort when calling binary search funtion.....which each time updating finally, thought there must way of inserting struct array it placed in right place , sorted. however, couldn't think of algorithm came here ask because google refuses read mind. i need make code faster because array accepts more 50 000 structs , i'm using bubble sort (because i'm dumb). take @ red black trees: http://en.wikipedia.org/wiki/red%e2%80%93black_tree they ensure data sorted, , has complexity of o ( log n ) inserts. a bina

c - Root node being set from seemingly nowhere in binary tree -

when inserting node binary tree(that doesn't accept duplicates) whatever reason root not being set , weirder fact root node seems set whatever node being entered. here 2 files i'm using. put comment in capital letters in tree.c show weirdness happening. thing mention trees nodes hold "integ" variable work expected within loop. main.c #include <stdio.h> #include <stdlib.h> #include <string.h> #define maxrelations 10 #define maxtuples 100 #define maxcolumns 15 #define maxlen 15 struct tree_node { //string or integer char *sori; char *string; int integ; char *column; struct tree_node *left_child; struct tree_node *right_child; }; struct column { char name[maxlen+1]; char si[1]; int bytez; }; struct db { int columnno; struct column columns[maxcolumns]; struct tree_node datanodes[maxcolumns]; }; int main(int argc, char *argv[]) { file *config; file *query; file *schema; file *data

python - Setting up SQLite database for cluster analysis -

i'm new databases. i'd advice on how set , use sqlite database cluster analysis , topic modeling tasks. i have 2 gb file each line json object. here example json object file: {"body": "heath ledger's joker...", "subreddit_id": "t5_2qh3s", "name": "t1_clpmhgo", "author": "l3thaln3ss", "created_utc": "1414799999", "subreddit": "movies", "parent_id": "t3_2kwdi3", "score": 1, "link_id": "t3_2kwdi3", "sub_type": "links - high"} i have created sqlite database so: import json import sqlite3 import sys def main(argv): if len(argv) != 2: sys.exit("provide database name.") dbname = argv[1] db = sqlite3.connect(dbname) db.execute('''create table if not exists comments (name text primary key, author text,

c# - razor html output result -

i trying output results in @helpers code , code looks this @helpers listfiles(string id, string cnumber,){ foreach(loopitem in getloop("items")){ if(i.getvalue("userid") == id){ <li>@i.getvalue("name")</li> }else{ if(i.getvalue("userid") != id){ <li>@i.getvalue("name")</li> } } } } as result li elements want if statement true should wrap li elements in ul element , else statement should wrap li in new ul element. please one possible way using 2 foreach , 1 each user id group : @helpers listfiles(string id, string cnumber,){ <ul> foreach(loopitem in getloop("items").where(o => o.getvalue("userid") == id)){ <li>@i.getvalue("name")</li> } </ul> <ul> foreach(loopitem in getloop("items").where(o =

arrays - Javascript - Group by one property, sort by another -

i have array of objects, , have them sorted 1 property (a number). have sort button allow user sort them attribute (a string). how can sort them specific value, , keep them in order of number sort in javascript? a quick example, using person name, age, , favorite color: steve, 27, blue joe, 28, red john, 30, green jane, 33, blue julie, 35, blue kevin, 40, red so, if user wanted sort list people favorite color of red, i'd want show this: joe, 28, red kevin, 40, red steve, 27, blue jane, 33, blue julie, 35, blue john, 30, green the order of property after selected 1 doesn't matter, long grouped , sorted age. example, above list (sorted red ) have john listed after kevin, long steve, jane , julie stayed in same order. basically, want group by string, , sort group number. thank help! sounds you're trying order (color = red), color, age (not sql syntax): first red, grouped color, age per group. that's tricky in 1 sorter... i think one: f

Matlab OOP: Create a handle class that (inherits from) is also a double? -

i create class inherits (and acts) double handle. example: a = myhandledoubleclass(); % instance of handle double. a.val = 1; % set value of 1. b = % assign b value of % but, b double, not object >> b b = 1 now if change value of (for example set a.val = 2 ) b should change has same value (or more correctly both , b in effect pointers same value). is possible in matlab somehow? edit: further clarify, these handle objects should later on used normal doubles , need act such access operations (for example b=a , b=a(ind) etc. without having explicitly access value property (its ok use property field set value, a.val = 1 ). purpose have double object used in many places (other objects, including patches) , have change value in 1 place (and other references update automatically due handle property). example: one application this, crate patch vertices of double class f = [1

How do you change the default programming language visual studio 2013? -

Image
i installed visual studio 2013 again after got new pc, when create new file creates vb file instead of c#. i changed default programming language in web.config shown here: i tried reloading project still not work. the web project placed on local ftp server. when make new project, under templates should see node visual basic , 1 visual c# different types of projects listed under language. believe vs remembers 1 used last.

signal processing - Audio spectrum visualization normalize loudness countour -

Image
i've written audio spectrum visualizer can see on following screenshot. works pretty peaks not normalized. think caused fact: equal-loudness contour . does know how balanced peaks (like horizontal line)? here code: https://github.com/frankred/openframeworks-music-visualization/blob/master/ofapp.cpp well, if know equal-loudness contour, why not divide it?

Bubble sort code on Java -

this code supposed bubble sort eclipse keep telling me there syntax errors on line 9: - syntax error on token "(", { expected - syntax error on token "arr", ( expected after token anyone knows happening? package porra; public class vai { public static final int arraylen = 0; public static void main(string[] args){ class bubblesort (int[] arr) { boolean swap = true; int = 0, j = 0, temp; while (swap) { swap = false; j++; (i = 0; < arraylen - j; i++) { if (arr[i] > arr[i + 1]) { temp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = temp; swap = true; } } system.out.print("ordem" + j + " : "); this.printarray(arr); system.out.println(""); } return; } private void printarray(int[] arr2) { // todo auto-generated method stub } } } } you're mixing class declaration constructor declaration. this: class bubblesort{ pu

pyside - python and ghost crash -

i'm trying ghost work python , have followed instructions installation on http://ghostpy.readthedocs.org/en/latest/ run from ghost import ghost gh = ghost it throws error process finished exit code -1073740771 (0xc000041d) when run import pyside print(pyside.qtcore.__version__) print(pyside.__version__) it gives me 4.8.5 1.2.2 suggesting both qtcore , pyside installed according instructions. know how troubleshoot this? i'm using python 3.4 , pycharm 4.0.5. you typed gh = ghost without parentheses () . should such: gh = ghost() from docs: from ghost import ghost url = "http://www.ebay.com/" gh = ghost() #right here # load main page of ebay page, resources = gh.open(url, wait_onload_event=true) # full main bar , click on search button gh.set_field_value("#gh-ac", "plane") gh.click("#gh-btn") # wait next page gh.wait_for_selector("#e1-15") # save image of screen gh.capture_to("p

ruby - How does Soundcloud API with pagination work? -

Image
i used code given via soundcloud: this error in terminal results read: i can't figure out did wrong.. :\ this result of when type "puts tracks" you can see next_href displayed @ bottom. if take @ data returned, might in sub-property called "collection", correct iterator "tracks.collection.each"

algorithm - Find the i-th greatest element -

i want use divide-and-conquer procedure computation of i-th greatest element @ row of integers , analyze asymptotic time complexity of algorithm. algorithm ith(a,low,high){ q=partition(a,low,high); if (high-i+1==q) return a[q]; else if (high-i+1<q) ith(a,low,q-1); else ith(a,q+1,high); } is right? if so, how find time complexity? the time complexity described following recurrence relation: t(n)=t(n-q)+t(q-1)+Θ(n) but how can solve recurrence relation, without knowing value of q? or there algorithm less time complexity computes i-th greatest element @ row of integers? this variation of quick select algorithm (which finds i-th smallest element rather i-th greatest element). has running time of o(n^2) in worst case, , o(n) in average case. to see worst case, assume searching nth largest element, , happens algorithm picks q largest element in remaining range. calling ith function n times. in addition partition subroutine takes o(n) total

html - 'data:post-snippet' truncation in blogger -

let's wrote post on blogger: abc def ghi <div class="pls-exclude-from-snippet">jkl mno pqr stu vwxyz</div> instead of listing z, want blogger set data:post.snippet 'abc def ghi' (letting blogger know stop if reads token: div class 'pls-exclude-from-snippet'). how do that? i found here https://productforums.google.com/forum/#!topic/blogger/x9lxrjxnb2s still have tweak little, works. think gonna post people similar problem had. here's code. before </head> , add: <script type='text/javascript'> //<![cdata[ function stopiffound(strx,token){ var thelocation = strx.indexof(token); if(thelocation!=-1){ strx = strx.substr(0,thelocation); } return strx; } function removehtmltag(strx, chop){ strx = stopiffound(strx,'<div class="pls-exclude-from-snippet">'); if(strx.indexof("<")!=-1){ var snippet = strx.split