Posts

Showing posts from January, 2012

xcode - Application Loader: I can't save my ITMSP file -

Image
when creating new in app purchase application loader, can't seem deliver package, or save applicationloader configuration (.itmsp) file. i seem following message: the document x not saved y.itsmp. file doesn’t exist. of course doesn't exist - i'm creating it! this 1 confused me while too. click title bar , type name in, press enter, save, job done. as blogged here: http://bit.ly/1fs3tct

android - how to update or delet from database -

i new database created simple database .please let me know how delete single row data base , how edit single row database :) in advance void createdatabase(string time, string day,string course,string room,string syl){ database = openorcreatedatabase("newdb",mode_private, null); sql = "create table if not exists examtab (time varchar ,day varchar ,course varchar ,room varchar ,syl varchar );"; c = database.rawquery(sql, null); database.execsql(sql); string insertsql = "insert examtab values('"+time+"','"+day+"','"+course+"','"+room+"','"+syl+"');"; database.execsql(insertsql); database.close(); } create, delete, update : sqliteopenhelper « database « android public dbadapter(context ctx) { this.context = ctx; dbhelper = new databasehelper(context); } private static class data...

python - Problems with the pseudocode in CLRS -

i'm using clrs introduction algorithms. trying implement algorithm written in pseudocode in book, in python. however, i'm having problems because book starts indexing 1. how implemented merge sort, doesn't work correctly: def mergesort(a, start, end): if(start < end): middle = math.floor((start + end)/2) mergesort(a, start, middle) mergesort(a, middle + 1, end) merge(a, start, middle, end) def merge(a, start, middle, end): n1 = middle - start + 1 n2 = end - middle l = [0] * n1 r = [0] * n2 in range(0, n1): l[i] = a[start + - 1] j in range(0, n2): r[j] = a[middle + j] = 0 j = 0 k in range(start, end): if(i >= n1): a[k] = r[j] j += 1 elif(j >= n2): a[k] = l[i] += 1 elif(l[i] <= r[j]): a[k] = l[i] += 1 else: a[k] = r[j] j += 1 how should conv...

java - String object is immutable but reference variable is mutable. What does that mean? -

i studying kathy sierra java book. came across 1 question this: public class { public static void main(string args[]){ string s1 = "a"; string s2 = s1; //s1=s1+"d"; system.out.println(s1==s2); } } output: true two points didn't understand here are: when uncomment s1 = s1 + "d" output changes false . same thing happens if replace string wrapper integer or int . again, when change code use stringbuffer this: stringbuffer sb = new stringbuffer("a"); stringbuffer sb2 = sb; //sb.append("c"); system.out.println(sb == sb2); now output doesn't changes i.e. remains true if uncomment sb.append statement. i can't understand strange behavior. can 1 explain me. s2 reference s1 in first case. in second case, + translated s1.concat("d") creates new string, references s1 , s2 point different string objects. in case of stringbuffer , reference never ...

Sorting multiple lists by the values of another list in java -

i have 6 arraylists shown below: index: 0 1 2 3 4 5 [12345.12 |123.0 |12.12 |1234.0 |123.12 |123.12 ] <double> [2000-01-11 |2000-01-11 |2000-01-11 |2000-01-12 |2000-01-12 |2000-01-11] <string> [1234 | 1234 | 1234 | 1235 | 1235 | 1234 ] <string> [4 | 10 | 16 | 24 | 30 | 20 ] <integer> [7 | 13 | 19 | 27 | 34 | 25 ] <integer> [9 | 15 | 21 | 29 | 35 | 40 ] <integer> using java, i want sort them values of first list in descending order . if values in first list equals, sort 2 equal values corresponding values in second list in natural order . strings in second list can sorted in natural order calling collection.sort(second_list). (example: because elements @ index 4 , 5 equals, have sort them elements @ index 4 , 5 in ...

java - android fully_qualified_classname is not assignable to 'android.app.application' -

i created new project in android studio. fresh new project. no activities. 1 single java class named myapplication. have extended class 'application' it's subclass of application. go modify manifest file add android:name=".myapplication" and of course, of course, gradle gods angered , send me curse: om.my_name.the_project_name.myapplication' not assignable 'android.app.application' less... (ctrl+f1) please me solve why error! full manifest code: <?xml version="1.0" encoding="utf-8"?> <!-- auto-complete email text field in login form user's emails --> <uses-permission android:name="android.permission.get_accounts" /> <uses-permission android:name="android.permission.read_profile" /> <uses-permission android:name="android.permission.read_contacts" /> <application android:name=".myapplication" android:allowbackup="true" ...

Facebook Open Graph scraping error for SSL website -

since we've made our website ssl secure , pci compliant, facebook open graph scraper can no longer read open graph meta tags. here's sample of our code meta tags in {head} of https://fantasydecathlon.com <meta property="fb:app_id" content="576816272427310" /> <meta property="fb:admins" content="223653" /> <meta property="og:title" content="fantasydecathlon: world series of fantasy sports" /> <meta property="og:type" content="website" /> <meta property="og:site_name" content="the fantasydecathlon" /> <meta property="og:image" content="https://fantasydecathlon.com/img/logo.jpg" /> but facebook open graph scraper gives error: curl error : ssl_connect_error unknown ssl protocol error in connection fantasydecathlon.com:443 and object @ url ' https://fantasydecathlon.com/ ' of type 'website' i...

java - Loop cuts last two groups of my array, when it outputs values -

i have tab[110] array random 1 , 0 ints, so: 1001111001011110... , on untill end of array. trying output 7 different rows of bits according hamming code. loop works groups starting bits, index in array 2,4,8,16. 32th loop cuts half of them (so start output 64, not 32) , group 64th skipped completely. int x=0; int sum=0; int pointer=0; boolean w = true; system.out.println("grupy bitow parzystych"); (int i=2; i<=7; i++) { system.out.println("\n"); switch(i) { //case 1: pointer=1; case 2: pointer=2; break; case 3: pointer=4; break; case 4: pointer=8; break; case 5: pointer=16; break; case 6: pointer=32; break; case 7: pointer=64; br...

vb.net - Statement is not valid in a namespace -

the code below returned statement not valid in namespace using vs-2010. please review code , recommend reasonable fix, research indicates should have bases covered importing presiding namespaces. what more should to make valid? the rest of these comments here past mandate verbose. imports system imports system.web imports system.web.security ' membershipprovider.createuser public overrides function createuser(byval username string, _ byval password string, _ byval email string, _ byval passwordquestion string, _ byval passwordanswer string, _ byval isapproved boolean, _ byval provideruserkey object, _ byref status membershipcreatestatus) membershipuser return me.createuser(username, password, email, _ ...

Using Convolution Neural Net with Lasagne in Python error -

i have used frame work provided daniel nouri on eponymous website. here code used.it looks fine change made change output_nonlinearity=lasagne.nonlinearities.softmax , regression false.otherwise looks pretty straight forward from lasagne import layers import theano lasagne.updates import sgd,nesterov_momentum nolearn.lasagne import neuralnet sklearn.metrics import classification_report import lasagne import cv2 import numpy np sklearn.cross_validation import train_test_split sklearn.datasets import fetch_mldata import sys mnist = fetch_mldata('mnist original') x = np.asarray(mnist.data, dtype='float32') y = np.asarray(mnist.target, dtype='int32') (trainx, testx, trainy, testy) = train_test_split(x,y,test_size =0.3,random_state=42) trainx = trainx.reshape(-1, 1, 28, 28) testx = testx.reshape(-1, 1, 28, 28) clf = neuralnet( layers=[ ('input', layers.inputlayer), ('conv1', layers.conv2dlayer), ('pool1', layers.maxpoo...

html - Fluid login form with different transparency of background holder -

i wanted know how create fluid layout this: have form holder placed in middle of screen. background of holder white, on top left side transparent triangle. have created in combination svg graphic , background property. found solution isn't best , have problems creating fluid layout this. please, @ code , suggest if have ideas. here picture how should like. html: <body id="login"> <div class="container"> <h1>login</h1> <div class="red-line"></div> <p class="email-sent">your password reset email has been sent.</p> <section class="login"> <div class="login-header"> <a href="index.html"><img src="assets/logo_menu_white.png" alt="" class="login-logo"></a> </div> <div class="login-form-holder"> <input type="e...

node.js - Express 4 node js , Access session data in public javascript file -

i need use session data in 1 of javascript file in public folder, can't access , did try make session global, app.use(function(req,res,next){ res.locals.session = req.session; next(); }); but doesn't make defferent

java - How a hash map load factor is determined during initialisation? -

when hash map initialised, 16 slots created. them empty in beginning. load factor ratio of number of elements occupied size of hash map. default or initial load factor must 0 right? while referring java book deitel , deitel says default load factor 0.75. how possible? from javadoc the load factor measure of how full hash table allowed before capacity automatically increased. it's threshold.

java - Static method file path -

this question has answer here: different ways of loading file inputstream 5 answers how path of file in same package class? this doesn't work. public static void saveallmockdata() throws exception { inputstream inputstream = getclass().getclassloader().getresourceasstream("mockdata.json"); } you can use inputstream = yourclassname.class.getresourceasstream("mockdata.json""); or can specify package path getclass() .getresourceasstream("/abc/efg/mockdata.json");

PowerShell Out-file -width does not truncate content when exporting to a file -

i have windows 7 , powershell 4.0. when exporting content file -width parameter not format based on given setting. here sample of trying do: "it nice hot sunny day" | out-file -filepath ".\output.txt" -encoding ascii -width 10 the result of export not truncated @ 10th character. not truncated @ all. cannot figure out what's wrong. this came of surprise me, apparently, -width parameter works formatted objects: string(s) input, no effect ps c:\> "it nice hot sunny day" |out-file '.\output.txt' -width 10 -force; gc '.\output.txt' nice hot sunny day format-table , works ps c:\> new-object psobject -property @{text="it nice hot sunny day"} | format-table |out-file '.\output.txt' -width 10 -force; gc '.\output.txt' text ----- a... format-list , works, in strange manner: ps c:\> new-object psobject -property @{text="it nice hot sunny day"} | format-table |out-file ...

Android - How can i create a "black list" for the files of my application -

in app have many files (images , audio files). there way can "mark" files cannot read other app music player audio , gallery images? question is: can create sort of "black list" prevents other app see files? edit as recommended me, try making ".nomedia" file folder contains files in way: file no_media_file = new file (my_path, "/.nomedia"); try { no_media_file.createnewfile(); } catch (ioexception e) { e.printstacktrace(); } the file ".nomedia" created correctly (i verified using "es file explorer") if open "play music" app can still play audio file... doing wrong? i solved problem inserting files in folder named this: ".my_folder" , it's worked!

differences between ionic platforms -

is there difference between ionic.platform and $ionicplatform and should 1 used on other? example when calling "ready" on either of them appears same thing $ionicplatform have import first. there better ladder?

javafx 8 - Adding a custom component to SceneBuilder 2.0 -

Image
i have need have selection listener , select method on pane able monitor , present highlight when node clicked on. i did following: public class panewithselectionlistener extends pane { private objectproperty<annotation> selectedannotation = new simpleobjectproperty<>(); public panewithselectionlistener() { super(); selectedannotation.addlistener((obs, oldanno, newanno) -> { if (oldanno != null) { oldanno.setstyle(""); } if (newanno != null) { newanno.setstyle("-fx-border-color: blue;-fx-border-insets: 5;-fx-border-width: 1;-fx-border-style: dashed;"); } }); setonmouseclicked(e->selectannotation(null)); } public void selectannotation(annotation ann){ selectedannotation.set(ann); } } and works great - not able work scenebuilder anymore since fxml references panewithselectionlistener rather pane. not sure how custom pane scenebuilder. have looked @ other qu...

java - Sending queries several times , HttpPost -

i make application sending post request sends gps coordinates, unfortunately realized sent 3 , 5 or 1 . so not understand why same coordinates sent multiple times. //méthode appelée au démarrage du service @override public int onstartcommand(intent intent, int flags, int startid) { shownotification();//appel de la méthode qui créé la barre de notification if (monlocationmanager != null && monlocationprovider != null) { //vérification toutes les 30 secondes (40000 millisecondes ) si la position change //d'au moins 20 métres. si c'est le cas, l'écouteur (instance de majlistener) //va etre averti monlocationmanager.requestlocationupdates(monlocationprovider, 30000, 20, new majlistener(this)); } // si le service est tué il ne redémarrera pas return service.start_not_sticky; } furthermore , believe emulator not have problem thank you

php - How do I configure a Debian webserver for push Git repo on it? -

i working in php developer team , have debian linux web server in local area network , installed lamp on it. so ok until planned using git version control system , use in our team work. our scenario when push git repository linux server, website hosted on takes effects , in our lan network can access this: 192.168.1.100/mysite every thing ok, can pull server , push it! problem when access website on server mysite folder in /var/www didn't take effect. i've searched internet , find should have bare repository connected master repository. i'm new git , don't know how it. edited: if possible tell me how on gui, have sourcetree.anything else ok. if launching project first time on server, have clone first. suppose trying launch this repo github account. have this: go directory. is: /var/www run commant: sudo git clone https://github.com/eaiman/bitmaphandler.git if console saying git not command or this, have install first. install git:...

java - Is it okay to create a DTO counterpart of a table in a database assuming its persistent ignorant domain model and the DTO is in the repository? -

what prompted me ask question class example invoice has private fields , dont want use setters because calculations of sort. instead options are: fields in constructor or reflection reconstitute object database (which occurs in repository layer(repository pattern)) don't create separate dto, use orm framework. modern orm frameworks (such hibernate) can map private fields without needing getter/setter. yes, use reflection internally, don't have write of yourself.

android - How to stopService when App is fired -

i got problem puzzling me long time activity a in application app in ondestroy(), need call function b() release resource, when press home , remove app , ondestroy() can not callback. should do? not call b() in onpause() or onstop() ps: making android musicplayer, need stopservice() when app killed, help!

javascript - Filter array by common object property in Angular.js? -

i've been struggling on few hours. situation is, have app, receives data people in json format: "people": [ { "name": "ivan", "city": "moscow", "country": "russia" }, { "name": "john", "city": "seattle", "country": "united states" }, { "name": "michael", "city": "seattle", "country": "united states" } ] and need filter them groups based on city (to displayed in dropdown <ul> s. i.e. user clicks "seattle" , <li> s john , michael displayed. how can done? use angular-filter grouping. view code this: <ul ng-repeat="(key, value) in people | groupby: 'city'"> city: {{ key }} <li ng-repeat="person in value"...

MongoDB remove object from array deletes complete array -

i have document one: { "_id" : 0, "name" : "aimee zank", "scores" : [ { "type" : "exam", "score" : 1.463179736705023 }, { "type" : "quiz", "score" : 11.78273309957772 }, { "type" : "homework", "score" : 6.676176060654615 }, { "type" : "homework", "score" : 35.8740349954354 } ] } on document want delete score has lowest score of type homework. first, i'm trying on mongo shell, put values manually. db.students.update({ _id:0}, {$unset: {"scores.score":6.6761760...

php - How to use class on primary menu ul instead of div in wordpress -

i used php coding in wordpress primary menu. <?php wp_nav_menu( array( 'menu' => 'top menu', 'theme_location' => 'primary', 'depth' => 2, 'menu_class' => 'nav navbar-nav', )); ?> this output in preview. <div class="nav navbar-nav"> <ul> <li class="active"><a href="#"> news <span class="sr-only">(current)</span></a></li> <li><a href="#">funny pictures</a></li> <li><a href="#">funny videos</a></li> <li><a href="#">goverment jobs</a></li> <li><a href="#">health</a></li> <li><a href="#">best shoping deal</a></li> </ul> </div> this should work below, not above. please explain change need mad...

css float - HTML5 "fixated" floating DIVs? -

i'm having a hard time putting question down in keywords unable check duplicates , such, apologize in advance. i'm trying write first html5 page, , noticed through preview that, if reduce browser window size, divs move positions trying fit smaller space, making mess of everything. i'd remain fixated in fullscreen mode, popping horzontal/vertical scrollbars navigation , namely happens 99% of web pages ever stumbled upon. i suspect issue "float" style use, since "floating" sounds opposite of "fixated", couldn't find way keep divs side side. i'll add code make examples on: var xx=screen.availwidth; var yy=screen.availheight; <header> <h1>big title</h1> </header> <div id="twoblocks"> <div id="leftblock" style="float:left;width:85*xx/100"> <div id="lefttop"> <section> (some text here) </section> </div> ...

oauth - authorization code for Github API used in R -

i trying access api information on http://github.com . created in application in github (in developer application) url , try access thru r using httr libraries. following code library(httr) oauth_endpoints("github") myapp <- oauth_app("github",key = "#####################",secret = "########################" ) (key replaced client id , secret replaced secred id) github_token <- oauth2.0_token(oauth_endpoints("github"), myapp) this prompted me following use local file cache oauth access credentials between r sessions? 1: yes 2: no i selected 2 (as tried option 1 earlier) following displayed httpuv not installed, defaulting out-of-band authentication please point browser following url: https://github.com/login/oauth/authorize?client_id=72939e1b6d499f4f1894&scope=&redirect_uri=urn%3aietf%3awg%3aoauth%3a2.0%3aoob&response_type=code enter authorization code can 1 tell me authorization code is? ...

c# - Selecting Multi-line strings through Entity Framework -

i using entity framework 4 in c# (yes know should upgrade thats besides point). i have 70,000 private rsa keys stored in database format this: note - demo key -----begin rsa private key----- miicxqidemodemodemodemodemoebgslt0n21onxrjbuwxfki7cn6clxpas+neuk bzaeijudjlqcga37ezv40uqnmgkplzo3ypee9qvkrvc4q3oi3s+ukfet7ejyvcwr wlnedoqvzydz8cwllce2yhoncmlyj3v3yst0n10oryakyaddbcd5pmbbuwieb7co +qkbgctldemodemodemodemodemonnvbwyfvlhfjpds1+5dtzbkog6zap+a/vkf1w 3psfl7vfbggqievai+4htulvzu0w0wqpqukw+rgzvt8fg1uwbrzukscjbscure/j 1i6iizz0sudjuynn+eorc12p1nrslf2buw3nfiognt849r9jakea1v+5agmjlzpp xz/etst7tb1wmeovnxu+s/h2kcw6+wcvlueryib2/e/lktbygxu5/ohimdgbqbb+ 28bu7lymuwjbam12343234235aeidmvgjchspoaqwnclv/fsex/6e8dxmhdhtena stt+v4k1rlkslm2aliz8kz2u8k45sepsvwecqqcmececqvtfuivc+8ekvlm536ot xrliedokrak8yrqqfezzaloxkotkixhbjuvt39spk+xzu30fwrdle858ebphakb+ lexh7ejtrxn3dhr1mdhjwolzm59dzgwfmueznnh+ommzsay21iouiaxjnkfxeclo frvuv5euqkvguji1/25jakaxzy7yjsjxanbgb9txakohhni2ywi/r9yewhzlorno oj49w6l9uawanxxmcrn...

php - Laravel Lumen Call to undefined function App\Http\Controllers\back() -

hello working on own authentication system using laravel's lumen , getting error call undefined function app\http\controllers\back() whenever try login wrong credentials. function looks in controller: public function loglink(request $request) { $input = $request->all(); $user = array( 'username' => $input['username'], 'password' => $input['password'] ); if (auth::attempt($user)) { $user = auth::user(); return view('auth.welcome', compact('user')); } else { return back()->withinput(); } } is there need include/call in controller? you can use back() shortland in laravel now. lumen need add redirect() : return redirect()->back()->withinput(); read more: http://lumen.laravel.com/docs/responses#redirects

c++ - Linked list insertion -

the emissonlist object list of shows info. problem in insert function. class emissionlist { private: emission *head=null; public: void insert(emission *anode); emission *gethead() { return head; }; void puthead(emission *newhead) { head=newhead; head->next = null; } void printemissions(); }; void emissionlist::insert(emission *anode) { emission *ptr=gethead(); if (head == null){ puthead(anode); }else{ while(ptr!= null){ ptr = ptr->next; } ptr = anode; ptr->next=null; }} i trying add list encounter problems. first of design of class emissionlist bad. nevertheless function can defined following way void emissionlist::insert( emission *anode ) { emission *current = gethead(); if ( current == null ) { puthead( anode ); } else { while ( current->next ) current = current->next; anode->next = current->next; current->next = anode; } }

r - Dynamically create expression for ggplot legend? -

Image
i want plot line graph, multiple lines, coloured depending on grouping variable. want set legend labels via scale -command: scale_color_manual(values = colors_values, labels = ...) the legend labels following: "x^2", "x^3", "x^4" etc., range dynamically created. dynamically create expression label text, i.e. "x^2" should become x 2 "x^3" should become x 3 etc. the amount of legend labels varies, thought as.expression(sprintf("x^%i", number)) , of course not work label parameter scale function. i have searched google , stack overflow, however, haven't found working solution yet, hope can me here. here's reproducible example: poly.term <- runif(100, 1, 60) resp <- rnorm(100, 40, 5) poly.degree <- 2:4 geom.colors <- scales::brewer_pal(palette = "set1")(length(poly.degree)) plot.df <- data.frame() (i in poly.degree) { mydat <- na.omit(data.frame(x = poly.term, y = ...

bash - using -sort in linux -

i want sort input of user sort in case (and function). never used before. have use array or something? for example user does: bash test.sh 50 20 35 50 normally in script happen: ping c -1 "192.168.0.$i" that results in 192.168.0.50 192.168.0.20 192.168.0.35 192.168.0.50 now want last numbers sorted , pinged smallest biggest number this: 20 35 50 , if have 2 times same number, script pings number 1 time. sortnumbers(){ } ... case -sort ) sortnumbers;; esac you can use this: #!/bin/bash array=($(printf '%s\n' "$@"|sort -nu)) echo ${array[@]} if run test.sh 34 1 45 1 5 6 6 6 , give output: 1 5 6 34 45 now can use variable $array for loop like: for in ${array[@]};do #do $i done explanation: the arguments of script piped command sort , output assigned array named array . options -n numerical sort , -u unique. assumed complete code (for clarification): #!/bin/bash array=($(printf '%s\n' "$@...

c++ - :: operator necessary to use with tolower()? -

transform(mystr.begin(), mystr.end(), mystr.begin(), tolower); i using transform function make string lowercase letters, after writing "using namespace std;" @ top of program whole bunch of errors(when writen above). when include :: operator before tolower parameter (such below) don't. why this? thought tolower function in std namespace , work have above. transform(mystr.begin(), mystr.end(), mystr.begin(), ::tolower); i have following includes: #include <iostream> #include <fstream #include <sstream> #include <algorithm> #include <vector> in error message see: error: no matching function call 'transform(std::basic_string<char>::iterator, ... then place 'tolower' in parameter list , <unresolved overloaded function type>);' it's resolve conflict between overloads of tolower between <cctype> 's int tolower(int c) , <locale> 's template <typename chart> chart...

classification - ROC curve in R using rpart package? -

Image
i split train data set , test data set. i used package rpart cart (classification tree) in r (only train set). , want carry out roc analysis using rocr package. variable `n. use' (response varible... 1=yes, 0=no): > pred2 = prediction(pred.cart, test$n.use) error in prediction(pred.cart, test$n.use) : **format of predictions invalid.** this code. problem? , right type ( "class" or "prob" ? library(rpart) train.cart = rpart(n.use~., data=train, method="class") pred.cart = predict(train.cart, newdata = test, type = "class") pred2 = prediction(pred.cart, test$n.use) roc.cart = performance(pred2, "tpr", "fpr") the prediction() function rocr package expects predicted "success" probabilities , observed factor of failures vs. successes. in order obtain former need apply predict(..., type = "prob") rpart object (i.e., not "class" ). however, returns matrix of ...

javascript - Saving a Google Chart Wrapper to image -

how can save chart wrapper image (png, jpg, bmp ... don't care) @ click of button. a normal google chart not problem, need right click on , save image. but how save image of chart in google chart wrapper??? i think relevant documentation you're looking on charts api website . method display chart png formatted image instead of svg. lose interactive features tooltips , selections. if still want features write link pops static chart image new window saved. since you're using chartwrapper need use like: var imageuri = chartwrapper.getchart().getimageuri(); the uri returns base64-encoded png image, modern browsers render image if used src attribute img tag, or entered directly address bar.

matlab - Evaluating K-means accuracy -

Image
i created 3-dimensional random data sets 4 defined patterns/classes in matlab. applied k-means algorithm on data see how k-means can classify samples based on created 4 patterns/classes. i need following; what function/code can use evaluate how k-means algorithm has identified classes of samples correctly? assuming set k=4 illustrated in image below: how can automatically identify number of classes (k)? assuming classes in data unknown? my aim evaluate k-mean's accuracy , how changes data (by pre-processing) affects algorithm’s ability identify classes. examples matlab code helpful! one basic metric measure how "good" clustering in comparison known class labels called purity. example of supervised learning have idea of external metric labeling of instances based on real world data. the mathematical definition of purity follows: in words means is, quoting professor @ stanford university here , to compute purity , each cluster assigned ...

C++ Default values in functions? -

how default values in functions work? question pertains example: int func(int number, std::string name = "none", int anothernumber); .. int func(int number, std::string name, int anothernumber){ ... } func(1, 2); ^error, name null yet we've defined default value? the compiler gives error complaining argument null , should not be. yet i've defined default value it. why this? if default parameter @ position k supplied, parameters in positions k+1 end must supplied well. c++ allows omit parameters in end positions, because otherwise has no way of matching parameter expressions formal parameters. consider example: int func(int a, int b=2, int c, int d=4); ... foo(10, 20, 30); this call ambiguous, because supplies 3 parameters out of four. if declaration above allowed, c++ have choice of calling func(10, 20, 30, 4); or func(10, 2, 30, 40); with defaulted parameters @ end , rule parameters matched position, there no such ambiguity: ...

javascript - Meteor show spinner on method call -

i have button calls method. when method called, have button change , show spinner (inside button itself). i have made button , css it. however, lost in how hook functionality show spinner when method called , stop showing when method returns successfully. how can this? (using template.subscriptionready ?) a simple solution activate spinner in event handler , deactivate in method call callback once method on server has returned or finished: 'click #methodbutton' : () => { activatespinner(); meteor.call('some method', (err, res) => { if(err) throw err; deactivatespinner(); }); }

Google charts multiline dynamic charts -

am new php coding & have few google charts working. of these charts i've generated far based on (date,number of event occurrences) type of chart. i'm trying plot google chart data output of sql query. the output of sql query looks below |series|date_1|date_2|date_3| |a|2|3| |b|4|6| |c|7|8| both series & date_1 can vary. say, based on various conditions in sql query, number of date_ can vary & can series. i have pass output google chart plot code. here i've tried coding far $link = mysql_connect("localhost", "user", "pass"); $dbcheck = mysql_select_db("database"); if ($dbcheck) { $chart_array_1[] = "['my_date','my_name','#num_occurences']"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $my_date=$row["my_date"]; $my_in...

xml - Restriction on attributes depending on other attributes in XSD 1.1 -

in xml file "multiplechoice" node defined in following way: <multiplechoice numberofchoices="" percentage="0"> text corresponding needs of xsd schema, xsd definition of mentioned following one: <xs:element name="multiplechoice" type="multiplechoicetype"/> <xs:complextype name="multiplechoicetype" mixed="true"> <xs:sequence> <xs:element minoccurs="0" maxoccurs="unbounded" ref="choice"/> </xs:sequence> <xs:attribute name="numberofchoices" type="xs:integer" use="required"/> <xs:attribute name="percentage" type="xs:integer" use="required"/> <xs:assert test="count(./choice) = @numberofchoices" /> </xs:complextype> what need add restriction "percentage" attribute: if in "actor" attribute have string "me",...

django - With @csrf_exempt still have Set-Cookie: csrftoken -

with django 1.8, not want have cookie set on homepage of site when users not logged in. decorate view @csrf_exempt like from django.views.decorators.csrf import csrf_exempt @csrf_exempt def mainhome(request): when @ query can see cookie still set, why ? rodo@roz-desktop:~/(master)$ curl -i http://127.0.0.1:8000/ http/1.0 200 ok date: sat, 13 jun 2015 08:59:27 gmt server: wsgiserver/0.1 python/2.7.8 content-type: text/html; charset=utf-8 vary: cookie x-queryinspect-duplicate-sql-queries: 2 x-queryinspect-total-sql-time: 34 ms x-queryinspect-total-request-time: 283 ms x-queryinspect-num-sql-queries: 3 set-cookie: csrftoken=sa5x0dyxgbamca0d84zznzl2wal0evkv; expires=sat, 11-jun-2016 08:59:27 gmt; max-age=31449600; path=/ as @daniel roseman indicated, @csrf_exempt not that. the middleware responsible session cookie sessionmiddleware . can read more in django docs: how use sessions . unfortunately, there no similar decorator in order exempt specific view. so in or...

Sequential numbering in PHP -

i want create sequential numbering in php, how that? example 0000009 next number 0000010 i have tried using sprintf or str_pad didn't format sprintf('%08d', 1234567) + 1; str_pad($value, 7, '0', str_pad_left) + 1; output: 2 you can use loop , precisely while loop that. after number has been generated use str_pad add number of zeros want. in while loop must have criteria or else iterate on , on again. example $number = 1; while ($number <= 10) { echo str_pad ($number, 7, '0', str_pad_left), '<br>'; $number++; // or rule want. } that's it

casting - Cast from unknown type in c# -

i have object contain value in string , origin type in field. class myclass { public string value; public type type; } myclass s=new myclass(); s.value = "10"; s.type = typeof(int); type tt = s.type; row.value[ind]= s[0].value tt; //i have error here how can cast value that's type. basically scenario want type cast type stored in variable. can @ runtime : myclass s=new myclass(); s.value = "10"; s.type = typeof(int); var val = convert.changetype(s.value, s.type); but since conversion done @ runtime, cannot store variable val in integeral collection i.e. list<int> or cannot int = val , coz @ complie time, type not known yet, , have compilation error, again same obvious reason. in little complex scenario, if had typecast user-defined datatype , wanted access different properties, cannot is. let me demonstrate few modifications code : class myclass { public object value; public type type; } and have ...

c++ - Image not being displayed using webcam in opencv -

i have started learn opencv, stuck in program. i trying run program displays video in-built webcam. #include <opencv2\highgui\highgui.hpp> int main() { cvnamedwindow("streaming", cv_window_autosize); cvcapture* capture = cvcreatecameracapture(0); iplimage* frame; while (1) { frame = cvqueryframe(capture); if (!frame) break; cvshowimage("streaming", frame); char c = cvwaitkey(33); if (c == 27) break; } cvreleasecapture(&capture); cvdestroywindow("streaming"); return 0; } all working fine no errors being thrown, when run program new window named streaming being opened , webcam light switch on (means webcam has started), inspite of no video being displayed in new window opened. can on this? beginner in this. thanks in advance!! i suggest migrating old cv implementation newly made methods opencv 2 . take @ videocapture class, has more intuitive methods. example, can use method isopened() check if webca...

pyqt4 - Python URLLib does not work with PyQt + Multiprocessing -

a simple code such: import urllib2 import requests pyqt4 import qtcore import multiprocessing import time data = ( ['a', '2'], ) def mp_worker((inputs, the_time)): r = requests.get('http://www.gpsbasecamp.com/national-parks') request = urllib2.request("http://www.gpsbasecamp.com/national-parks") response = urllib2.urlopen(request) def mp_handler(): p = multiprocessing.pool(2) p.map(mp_worker, data) if __name__ == '__main__': mp_handler() basically, if import pyqt4, , have urllib request (i believe used in web extraction libraries such beautifulsoup, requests or pyquery. crashes cryptic log on mac) this true. fails on mac, have wasted rows of days fix this. , there no fix of now. best way use thread instead of process , work charm. by way - r = requests.get('http://www.gpsbasecamp.com/national-parks') and request = urllib2.request("http://www.gpsbasecamp.com/national-parks...