Posts

Showing posts from January, 2010

c# - Order List By Distinct And Object Property Larget value -

i need arrange list have distinct object items largest object x property. example: have list of objects: mylist : object[0] : name: dani x:3; object[1] : name:dani; x:1; object[2]: name:joey; x:5; object[3]: name:joey; x:1; i need find distinct objects largest x values new list 2 objects so: new list: object[0] :name:dani;x:3 object[1] :name:joei;x:5 how can find new list? lambda ex nice... myobjects.groupby(o => o.name).select(g => g.orderbydescending(o => o.x).first()) seeing don't provide details of linq provider using, best general approach. can speed things in linq2objects using maxby extension method in morelinq : http://code.google.com/p/morelinq/ myobjects.groupby(o => o.name).select(g => g.maxby(o => o.x))

php - CodeIgniter form helper/post data issue -

i'm building basic website in ci. i've constructed form using form helper , doing along these lines: view (from create_form.php): <?php $this->load->helper('form'); ?> <?php echo form_open('site/create_article'); ?> <?php echo form_label('title:', 'title'); ?><br /> <?php echo form_input('title'); ?><br /><br /> <?php echo form_label('body:', 'text'); ?><br /> <?php echo form_textarea('text'); ?><br /><br /> <?php echo form_submit('submit', 'post article'); ?> controller (from site.php): function create_article() { $this->load->model('site_model'); $this->load->helper('form'); $post_check = $this->input->post('submit'); if ($post_check === true) { $this->site_model->create_article($post_check); $this->load->view(&#

java - Checking for updates from network continuously - how? -

when phone receives text message, upload database. on tablet should notification new message possible. how efficiently check new messages database? don't think background process queries database every few seconds efficient @ all. drain battery , it's huge waste of network. have static broadcastreceiver in app listener. if text message comes in receiver started , onreceive() called. can invoke service/ activity save database , put notification. here's nice tutorial started.

javascript - How to get the first unique multivalue (array-notated) inputs in a form using jQuery? -

i have form this: <form> <select name="user_id[]"></select> <select name="user_id[]"></select> <select name="user_id[]"></select> <select name="user_id[]"></select> <select name="tag_id[]"></select> <select name="tag_id[]"></select> <select name="stack_id[]"></select> <!-- ... etc. --> </form> i want jquery collection consisting of first multivalue elements name: <form> <select name="user_id[]"></select> <!-- --> <select name="user_id[]"></select> <select name="user_id[]"></select> <select name="user_id[]"></select> <select name="tag_id[]"></select> <!-- --> <select name="tag_id[]"></select>

Python 3 and Unicode - How do I print newlines (general problems understanding this) -

i have sifted through lots , lots of python/unicode explanations can't seem make sense of this. here situation: i pulling loads of comments off reddit (making bot) , store them in mongodb, need able print out comment trees in order manually check what's going on. i have had no problems far putting comments db, when try print stdout cp1252 charset having trouble characters doesn't support. as have read, in python 3 internally (strings) stored unicode, it's input , output must bytes, fine - can encode unicode cp1252 , in couple of situations see \x** characters don't mind - guessing represent out of range characters? the problem printing out comment trees (to stdout) using \n (linefeeds) , tabs easy over, apparently when encode unicode string newline escape sequences escapes them printed literals. for reference here encode statement: encoded = post.tree_to_string().encode('cp1252','ignore') thanks edit: what want is |parent c

linux - Why the website cannot be accessed without www? -

Image
for example, if visit example.com website cannot visited. instead, have explicitly use www.example.com in order access correctly, fact turns out annoying since people don't want type www time. what's solution here? i'm using linux servers. you have add a record on dns service provider , , host name should www . this: first column host name , second record type , ignore third , last 1 (different provider differs), fourth ip address , pointing server.

java - Only mapping from department side is mapped and not from inverse side.How can i say this is a Many to Many -

below code package com.hibernate.mapping.mtm; import java.util.arraylist; import java.util.list; import org.hibernate.session; import org.hibernate.sessionfactory; import org.hibernate.transaction; import org.hibernate.cfg.configuration; /** * @author prajapati * */ public class main { /** * @param args */ public static void main(string[] args) { // todo auto-generated method stub sessionfactory sf= new configuration().configure("com/hibernate/mapping/mtm/hibernate.cfg.xml").buildsessionfactory(); session sn = sf.opensession(); transaction tx = sn.begintransaction(); department dept1 = new department(); dept1.setid(20l); dept1.setdepartmentname("development"); department dept2 = new department(); dept2.setid(10l); dept2.setdepartmentname("acco

performance - Linux x86/x86-64 Fortran 90/95/2003/2008 compiler, which? and, why? -

well, i've been asking myself question quite long time now. i started using gnu fortran compiler ( gfortran ) , quite happy. started hearing intel fortran compiler ( ifort ) better because optimized intel processors (and therefore optimized computers today consequence intel has greater share of market). after started using ifort , truth i'm not happy because not detect errors gfortran (i.e. question: "reference passing changing values of matrix" ). it true there other fortran compilers but, actually, never use other gfortran , ifort . so ask you: advantages , disadvantages of each one? best one, if optimization not important? in opinion, best stick standard you're comfortable with, , write code conforming standard. then, choice of compilers dictated support said standard. here extensive list of compiler support 2003 , 2008 standards. i myself used g95 lot because liked debug messages. nowadays, commonly use fortran 2008 features, , use

php - Get away from MySQL query inside foreach loop. foreach causes issues with while loop? -

i have following code: <?php //the company_array: $company_array = array( "aaa" => "aaa", "bbb" => "bbb", "ccc" => "ccc", "ddd" => "ddd" ); $platform_data = 'pc'; //just keep short :) foreach ($company_array $company) { if ($stmt = $mysqli->prepare("select price, time $company platform = ? order time asc")) { $stmt->bind_param("s", $platform_data); $stmt->execute(); $stmt->bind_result($price[$company], $time[$company]); $i=0; while ($stmt->fetch()) { $company_info[$company][$i] = array('price' => $price[$company], 'time' => $time[$company]); $i++; } $stmt->close(); } ?> now had issues this, last iteration of loop seems break, if print $company_info last company displays fine, last 1 seem repeat last value

mongodb - Can not retrieve file from gridFs using the java driver (but can using python) -

note; we've rewritten backend in python now, though still nice know did wrong, it's not big of thing anymore. i've got known file in database has following objectid "5251ad0d56c02c34fbad2a3d" i know it's there, since can inspect both mongo cli client , pymongo: >>> import pymongo, gridfs, bson >>> client = pymongo.mongoclient() >>> db = client['playtest'] >>> fs = gridfs.gridfs(db, 'attachments') >>> gridout = fs.get(bson.objectid.objectid("5251ad0d56c02c34fbad2a3d")) >>> gridout.filename u'vasalis-03.png' >>> however when try retrieve using java following code import com.mongodb.basicdbobject; import com.mongodb.db; import com.mongodb.dbcollection; import com.mongodb.dbobject; import com.mongodb.gridfs.gridfs; import com.mongodb.gridfs.gridfsdbfile; import com.mongodb.gridfs.gridfsinputfile; import com.mongodb.mongoclient; import org.bson.types.objec

laravel - After update from local to server : Class 'category' not found -

edit: changed lowercase 'c' uppercase 'c' in belongsto.... carelessness... on local machine ok, error after upload server. i have basic 1 one relationship: symbol.php - model: class symbol extends eloquent { protected $table = 'symbols'; protected $softdelete = true; public function category() { return $this->belongsto('category', 'id_category'); } } category.php - model class category extends eloquent { protected $table = 'categories'; } i call relationship this: $symbol = symbol::find($id); but if want access data: $symbol->category->name; on local machine ok after upload server error: symfony \ component \ debug \ exception \ fatalerrorexception class 'category' not found $instance = new $related; (line 527) any ideas? but why works on local? different server settings? if worked on local machine , not on server think, have windows oper

android - How to display a Video from an URL -

i have button on main tab of apps attempts launch video url via second activity i have tested blank activity , displayed 'hello' when said button click. removed 'hello' editext , added codes java file suggested in similar post. when video btn clicked, message ;can't play video, ok' i have tested youtube link valid link. yet logcat error message include : 10-07 09:04:36.785: i/mediaplayer(11397): path null 10-07 09:04:36.795: d/mediaplayer(11397): setdatasource ioexception happend : 10-07 09:04:36.795: d/mediaplayer(11397): java.io.filenotfoundexception: no content provider: http://youtu.be/rfrg1xfoxeq where go here ? an xml second activity follows :- <videoview android:id="@+id/videoview1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </tablelayout> corresponding java file @override protected void oncreate(bundle savedinstancestate) { super.oncre

When sharing on Android, why do hashtags work with the browser, but not the Twitter app itself? -

i using similar method sharing on twitter like: how tweet both url , hashtags this allows users without twitter app open browser , share. however, have noticed hashtags passed message when being shared via browser. if user chooses official app, hash tag disappears. known bug? thanks! try so: sharevia("twitter", "example.com"); .... private void sharevia(string packagename, string content) { string toshare = content; intent shareintent = new intent(android.content.intent.action_send); shareintent.settype("text/plain"); shareintent.putextra(android.content.intent.extra_text, toshare); packagemanager pm = mactivity.getpackagemanager(); list<resolveinfo> activitylist = pm.queryintentactivities(shareintent, 0); (final resolveinfo app : activitylist) { if ((app.activityinfo.packagename).contains(packagename)) { final activityinfo activity = app.activityinfo; final comp

java - Android fixed header on ListActivity -

Image
i quite new listviews, that's begin with. anyways, want do, obviousy hold button or whatever on top of list, created programmatically , 1 xml file. xml file: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/linearlayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" tools:context=".main" > <imageview android:id="@+id/picid" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingbottom="10dp" android:paddingright="10dp" android:paddingtop="10dp" /> <linearlayout android:id="@+id/linearlayout2" android:layout_width="match_parent"

Unix return value "-bash" -

i not know return value means grep abc letters echo $? 0 echo $0 gives "-bash" "-bash" return value mean the question should moved https://unix.stackexchange.com/ . but anyway, $0 value of variable holds name of application that's executing command. it's argv[0] in c. example: cdshines@v3700:~|⇒ echo $0 # i'm in zsh /bin/zsh cdshines@v3700:~|⇒ bash # let's run bash: cdshines@v3700:~$ echo $0 bash cdshines@v3700:~$ sh # need go deeper: $ echo $0 sh $ zsh # deeper! cdshines@v3700:~|⇒ echo $0 zsh cdshines@v3700:~|⇒ # hit ctrl-d (pop 1 level): $ echo $0 sh $ # pop again: cdshines@v3700:~$ echo $0 bash cdshines@v3700:~$ exit # again: cdshines@v3700:~|⇒ echo $0 /bin/zsh # we're @ starting point

rascal - Java 1.5 grammar doesn't build -

anybody java 1.5 grammar working in rascal? https://raw.github.com/cwi-swat/rascal/master/src/org/rascalmpl/library/lang/java/syntax/java15.rsc i get: $ java -jar rascal-0.5.1.jar java15.rsc disambiguate.rsc parse error in cwd:///java15.rsc <997,24> <997,25> 997 freaky stuff: bool expectedamb({(expr)`(<reftype t>) <expr e>`, appl(_,[(expr)`(<exprname n>)`,_*])}) = true; // (a) + 1 bool expectedamb({appl(_,[_*,(expr)`(<reftype t>) <expr e>`]), appl(_,[appl(_,[_*,(expr)`(<exprname n>)`]),_*])}) = true; // 1 + (a) + 1 default bool expectedamb(set[tree] t) = false; char 24 ` think. terence yes, grammar uses newer syntax concrete syntax. current stable rascal release not support this. (that why public release not contain grammar yet) to use grammar have download unstable release ( replace stable in update url unstable ) or build rascal locally rascal shell. in these cases, won't need separate files. to answe

Using ansible to launch a long running process on a remote host -

i'm new ansible. i'm trying start process on remote host using simple ansible playbook. here how playbook looks like - hosts: somehost gather_facts: no user: ubuntu tasks: - name: change directory , run jetty server shell: cd /home/ubuntu/code; nohup ./run.sh async: 45 run.sh calls java server process few parameters. understanding using async process on remote machine continue run after playbook has completed (which should happen after around 45 seconds.) however, playbook exits process started run.sh on remote host terminals well. can explain what's going , missing here. thanks. give longer time async 6 months or year or evenmore , should fine. or convert process initscript , use service module. and add poll: 0

jQuery each() giving me two different results with nested objects -

i'm trying use code below , works way want alerting honda, toyota, , ford in second each(). first 1 outputs 0. why doing that? var cars = { honda : {0: "accord", 1: "prelude", 2: "civic"}, toyota: {0: "camry", 1: "corolla", 2: "brz"}, ford: {0: "mustang", 1: "focus"} } $(cars).each(function(key, value)) { alert(key); }) $.each(cars, function(key, value) { alert(key); }) your first example outputs 0 because when $(cars) , you're wrapping cars object in jquery object, object 1 element index 0. also should note distinction between both "each" methods: jquery.each() or $.each() : a generic iterator function, can used seamlessly iterate on both objects , arrays. .each() : iterate on jquery object, executing function each matched element.

matlab - Inner matrix dimensions error must agree error when plotting -

i'm attempting plot function: f(x) = x * e^(x) * cos(x) 0 2*pi. i've tried running: x = 0:pi/100:2*pi; y = x*exp(x)*cos(x) however, every time attempt set y. matlab throws me 'error using *' , says inner matrix dimensions must agree. insight why happens? you have use .* (element-wise multiplication), not * (matrix multiplication)

Regex with preg_replace in PHP -

it's long time ago haven't played php , regex , i'd find regex following work. my string contains : <pre code="...">some piece of code</pre> other non code content <pre code="...">some piece of code</pre> other non code content... the goal replace <pre>code</pre> by & code ...` where "code" inside <pre>&</pre> should escaped htmlspecialchars... i've tried few regex didn't succeed. any idea? thanks generally, using regex parse html bad idea. there plenty of simple scenarios, regex enough solve particular problem, , great. i argue in case using regex bad idea, not cover cases , insecure. possibly trying prevent xss vulnerabilities, , regex based solutions error-prone. but completeness sake: preg_replace_callback( '/(<\\s*pre(?:\\s[^>]+)?>)(.*?)(<\\/\s*pre\s*>)/', function ($match) { return $match[1].htmlspecial

php - Loading custom javascript in a Wordpress plugin -

ok, driving me nuts: i'm trying build simple wordpress plugin, , i'm trying make sure js separate php. i've gone through codex, , various tutorials, either making assumptions, or i'm idiot because it's not working...basically, i'm ultiamtely hoping add rows using ajax custom table when add post, first of i've got hello world working on add post page... surely it's dead easy: here's javascript in myplug/js/myplugin.js: jquery(document).ready(function(){ alert("dothis"); }); here's version works in plugin (but bad): function admin_load_js(){ echo '<script type="text/javascript" src="http://www.mysite.com/wp-content/plugins/myplugin/js/myplugin.js"></script>'; } add_action('admin_head', 'admin_load_js'); this marginally better, doesn't work (jquery not defined): function admin_load_js(){ echo '<script type="text/javascript" src=&qu

python 2.7 - unable to read a tab delimited file into a numpy 2-D array -

i quite new nympy , trying read tab(\t) delimited text file numpy array matrix using following code: train_data = np.genfromtxt('training.txt', dtype=none, delimiter='\t') file contents: 38 private 215646 hs-grad 9 divorced handlers-cleaners not-in-family white male 0 0 40 united-states <=50k 53 private 234721 11th 7 married-civ-spouse handlers-cleaners husband black male 0 0 40 united-states <=50k 30 state-gov 141297 bachelors 13 married-civ-spouse prof-specialty husband asian-pac-islander male 0 0 40 india >50k what expect 2-d array matrix of shape (3, 15) but above code single row array of shape (3,) i not sure why fifteen fields of each row not assigned column each. i tried using numpy's loadtxt() not handle type conversions on data i.e though gave dtype=none tried convert strings default float type , failed @ it. tried code: train_data = np.loa

java - Getting a sum from ArrayList<Number> using non-loop recursion -

i working on lab assignment school , wondering if give me advice. instructor wants add different number objects array list , display result. wants addition in non-loop recursive format. i've done similar problem before integers, cannot seem solution because there more 1 primitive type time. here code have far: main: import java.math.biginteger; import java.util.arraylist; public class testsummation { public static void main(string[] args) { arraylist<number> alist = new arraylist<number>(); alist.add(new integer(4)); alist.add(new double(3.423)); alist.add(new float(99.032)); alist.add(new biginteger("32432")); double result = summation.sum(alist); system.out.println(result); } } class holds recursive method: import java.util.arraylist; public class summation { public static double sum(arraylist<number> alist) { if (alist.size() < 1) { return 0; } else { return sum(alist); } }

ios7 - SpriteNode not following cgpath -

Image
i have problem new game sprite... "car" follows track on first lap on seems getting offset @ end of every lap. tell me doing wrong ? - (void)createscenecontents{ self.backgroundcolor = [skcolor blackcolor]; self.scalemode = skscenescalemodeaspectfit; // creating car , track skspritenode *mycar = [self newcar]; mycar.position = [[self trackshape] position];; [self addchild:mycar]; skshapenode *track = [self trackshape]; track.position = cgpointmake(48, 40); [self addchild:track]; } - (skspritenode *)newcar{ // generates rectangle sprite node skspritenode *hull = [[skspritenode alloc] initwithcolor:[skcolor graycolor] size:cgsizemake(20,50)]; cgpathref pathref = [[self bpath] cgpath]; // car should follow track // ok on first lap skaction *hover = [skaction sequence:@[[skaction followpath:pathref duration:20.0], ]]; hull.physicsbody = [skphysicsbody bodywithrectangleo

c - What happens inside of this condition statement? while (a = foo(bar)) -

it may sounds silly, want know happening when execute while(a = function(b)){}. suppose got null return value of read_command_stream. can out of loop? while ((command = read_command_stream (command_stream))) { if (print_tree) { printf("# %d\n", command_number++); print_command (command); } else { last_command = command; execute_command(command, time_travel); } } struct command struct command { enum command_type type; // exit status, or -1 if not known (e.g., because has not exited yet). int status; // i/o redirections, or null if none. char *input; char *output; union { // and_command, sequence_command, or_command, pipe_command: struct command *command[2]; // simple_command: char **word; // subshell_command: struct command *subshell_command; } u; }; the syntax says: while (expression) { ... } and expression can lot. can be: a constant: while (1

Segmentation fault in C txt file I/O -

ok guys, purpose of program read text file called orginal.txt containing names in format: kyle butler bob jones nathan moore the program takes these names 1 @ time , turns them like: kyle.butler@emailaddress.com this address stored line line in new text file called final.txt problem is, can't work, gives me segmentation fault , not writing final.txt #include <stdio.h> #include <stdlib.h> #include <string.h> void write(char line[100]); int main() { file *fp; fp = fopen("original.txt", "r+"); char line[100]; char mod[30]="@fakeemail.com\n"; while (fgets(line, 100, fp) != null){ int i; for(i=0; i<100; ++i){ if(line[i]==' '){ line[i]='.'; } if(line[i]=='\n'){ line[i]='\0'; } strcat(line, mod); } file *fp2; fp2 = fopen("final.tx

jquery - Load external data into a Div or iFrame? -

what best way load full page of data including external js files current page? know how way better? iframe or div? @ moment jquery ajaxing data div. toggling div when not needed. an iframe used used containing media files/content. such pdf, flash, image, video, etc. iframe can used containing html, wont great deal have great result(except need it). if want embed/attach external html page think should use div element. if want add media content web page, should use iframe element. can create toggle button using javascript. js want embed can embedded on main page(master page contains attached files/contents) or on page want embed. careful, don't attach 2 or more js has same function, make browser confused (ex : attach jqueryui-1.9.0 , jqueryui-10.0.2).

assembly - toUpper/toLower in mips -

i need write program using mips take string , switch uppercase letters lower case , lowercase letters uppercase. instinct write if statements using letter numerical values wondering if there better way go this. yes, there better way of doing this! ascii values of corresponding upper , lower case alphabetical characters differ 0x20 . instance, 'a' = 0x41 , 'a' = 0x61 . basically, sixth bit set lower case characters, , cleared upper case. the simplest implementation uses bit-bashing trick - if can identify character letter, can upcase using: ch &= ~0x20; or downcase with: ch |= 0x20; remember, won't work other alphabetic ascii characters. can check whether character matches (ch >= 'a' && ch <= 'z') || (ch >= 'a' && ch <= 'z') . another approach avoids if entirely build 256-entry table consisting of intended output each character, , indexing each character. may slightly more e

multithreading - PHP Threading Explained -

in given php page, if 1 'echoes' given piece of information, sent user, , no others. decides client receives data, , can changed? furthermore, 1 use single script send data multiple clients? short answer: no long answer: when connect webserver, web server responds sending piece of data. in case 'echo'. connection closed , history. theoraticly possible send 1 piece of data multiple clients long connected webserver. i.e web browser shows 'loading page' practically , not possible, because once connection closed, user has hit refresh button again connect server , fetch new data i suggest read fantatic article give broad sense on how web servers work. http://computer.howstuffworks.com/web-server.htm

gruntjs - Cannot get grunt to perform uglify -

i'm using grunt , trying uglify js file produced concat task. concat works fine, uglify fails following error. running "uglify:dist" (uglify) task >> uglifying source "dist/myapp.js" failed. warning: uglification failed. used --force, continuing. warning: cannot read property 'min' of undefined used --force, continuing. node --version outputs v.0.11.8-pre grunt --version outputs grunt-cli v0.1.9 grunt v.0.4.1 here gruntfile.js . copied documentation , removed tasks don't need. module.exports = function(grunt) { grunt.initconfig({ pkg: grunt.file.readjson('package.json'), concat: { options: { separator: ';' }, dist: { src: ['src/**/*.js'], dest: 'dist/<%= pkg.name %>.js' } }, uglify: { options: { banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' },

performance - Finding max record with java -

i have problem statement , know best way of solving in java. i have large number of records(1 million say) records have timestamp , value. have output in span of each 15 min highest value. e.g. timestamp -07-10-2013 10.15 - 14 -07-10-2013 10.18 - 13 -07-10-2013 10.19 - 18 -07-10-2013 10.30 - 16 -07-10-2013 10.34 - 10 -07-10-2013 10.38 - 17 -07-10-2013 10.42 - 30 -07-10-2013 10.54 - 23 -07-10-2013 10.57 - 44 output -07-10-2013 10.19 - 18 -07-10-2013 10.42 - 30 -07-10-2013 10.57 - 44 what best way of doing in java. iterating through each record looks tedious thing. great. you can't max value without iteration through each value, unless have kind of predefined order, can use optimization. i use map accumulate highest value, comparing stored, way can highest value in 1 iteration through records.

java - How to create SublimeText like build files in notepad++? -

is such option available in notepad++ ? for example , custom java build in sublimetext2 : { "cmd": ["javac","-d","../bin","$file"], "file_regex": "^(...*?):([0-9]*):?([0-9]*)", "selector": "source.java" } and takes file i'm working on , compiles bin folder. ps: i'm eclipse user , use text editor casual stuff or when i'm learning new.

Unable to obtain text box value (html) in jsp -

<form name="myform" action="myservlet" method="post"> please enter search query here:<br> <input type="search" name="searchtext" id="searchtext" size="100" autocomplete="on" /> <input type="submit" name="search" value="search" /> <textarea cols="30" rows="10">result displayed here</textarea> <a href="newhtml1.html">click here</a> if result not displayed search query. </form> in servlet arg = request.getparameter("searchtext"); out.println(arg); but getting output null. it should be <input type="text" name="searchtext" .../>

c++ - void function Math error -

#include <iostream> using namespace std; void compute_coins(int change, int quarters, int dimes, int nickels, int pennies); void output(int quarters, int dimes, int nickels, int pennies); int main() { int change, quarters, dimes, nickels, pennies; char again = 'y'; cout << "welcome change dispenser!\n"; while(again == 'y'){//creating loop allow user repeat process cout << "please enter amount of cents have given between 1 , 99\n"; cin >> change; while((change < 0) || (change >100)){//making loop make sure valid number inputed cout << "error: sorry have entered invalid number, please try again:"; cin >> change; } cout << change << " cents can given as: " << endl; compute_coins(change, quarters, dimes, nickels, pennies); output(quarters, dimes, nickels, pennies); cout << "would enter mo

objective c - tap gesture not recognized on uiimageview -

i added 2 uiimageview s, 1 on subview uiview ( imageview1,imageview2 ). in first view top uiimageview hidden( imageview2 ) , in second view bottom imageview hidden( imageview1 ). allocating tap gesture: uitapgesturerecognizer *singletap = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(onetap:)]; uitapgesturerecognizer *singletap1 = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(onetap:)]; set user interaction both uiimageview yes. [singletap setnumberoftapsrequired:1]; [singletap1 setnumberoftapsrequired:1]; // adding gesture uiimageview add tap gesture recognizer , selector respectively. [imageview1 addgesturerecognizer:singletap]; [imageview2 addgesturerecognizer:singletap1]; but taps not recognized. can 1 tell me mistake is? try setting setuserinteractionenabled:yes before adding gesture recognizer. [imageview1 setuserinteractionenabled:yes] [imageview2 setuserinteractionenabled:yes] [imageview1 addges

artificial intelligence - classification with four classes by matlab -

i have classification problem 4 classes of input vector.the 4 classes are a = [1 , 1; 1 ,2]; b = [2,2; -1,0]; c = [-1,-2;2,1]; d = [-1,-2; -1,-2]; i wan implement problem matlab, use code : c = [-1,-2;2,1]; = [1 , 1; 1 ,2]; b = [2,2; -1,0]; d = [-1,-2; -1,-2]; hold on grid on plot(a(1,:),a(2,:),'bs') plot(b(1,:),b(2,:),'r+') plot(c(1,:),c(2,:),'go') plot(d(1,:),d(2,:),'m*') = [0 1]'; b = [1 1]'; c = [1 0]'; d = [0 0]'; p = [a b c d]; t = [repmat(a,1,length(a)) repmat(b,1,length(b)) repmat(c,1,length(c)) repmat(d,1,length(d)) ]; net = perceptron; e = 1; net.adaptparam.passes = 1; linehandle = plotpc(net.iw{1},net.b{1}); n = 0; while (sse(e)) n = n+1; [net,y,e] = adapt(net,p,t); linehandle = plotpc(net.iw{1},net.b{1},linehandle); drawnow; end but code does'nt work have no idea why, please me.... as has been suggested thewaywewalk, trouble while -loop , fact not provide adequate check

How to write Hello World in pure c (Without using any c library)? -

i know linux kernel source in pure c. want know how can write simple hello, world program in pure c without using printf api? i know linux kernel source in pure c. it not. linux kernal infamous frequent use of non-standard extensions gcc compiler. so want know how can write simple hello, world program in pure c without using printf api? printf wrapper around os api functions. mean ask how write printf using linux api functions? becase "pure c" defined in c standard iso 9899, has nothing linux os.

servicestack - Missing Interface on Service stack -

i wasnt sure post have downloaded latest src service stack. i can see project file: https://github.com/servicestack/servicestack/blob/master/src/servicestack/servicestack.csproj references: <compile include="auth\iauthrepository.cs" /> but when go here: https://github.com/servicestack/servicestack/tree/master/src/servicestack/auth there no iauthrepository. hence build of service stack wont compile. thanks russ

java - LibGDX: Sequence Not Working -

i cannot use sequence @ all, these gives me error. this.addaction(sequence()); this.addaction(sequence(setx(gety()))); no matter sequence won't work, despite these being imported. addaction not work either, nor addaction & actions.sequence.. nothing far goes. import com.badlogic.gdx.scenes.scene2d.actions.actions; import com.badlogic.gdx.scenes.scene2d.actions.addaction; edit: needed make class actor. this worked fine me. do in constructor of screen want action: image.addaction(sequence(fadeout(3), run(new runnable() { @override public void run() { game.setscreen(new menuscreen(game)); } }));

Magento Mobile Shoppe Theme onepage checkout not working on CE 1.8 -

i'm having real issue checkout i'm stuck on step 3 shipping method. one thing noticed "your checkout process" on right hand side doesn't load content. can me please? here posted second question answer checkout progress disappeared backward 1 one. look code in frontend/default/theme/layout/checkout.xml <checkout_onepage_progress> <!-- mage_checkout --> <remove name="right"/> <remove name="left"/> <block type="checkout/onepage_progress" name="root" output="tohtml" template="checkout/onepage/progress.phtml"> <block type="checkout/onepage_payment_info" name="payment_info"> <action method="setinfotemplate"><method></method><template></template></action> </block> </b

c# - TcpListener : how to stop listening while awainting AcceptTcpClientAsync() -

i don't know how close tcplistener while async method await incoming connections. found code on so, here code : public class server { private tcplistener _server; private bool _active; public server() { _server = new tcplistener(ipaddress.any, 5555); } public async void startlistening() { _active = true; _server.start(); await acceptconnections(); } public void stoplistening() { _active = false; _server.stop(); } private async task acceptconnections() { while (_active) { var client = await _server.accepttcpclientasync(); dostuffwithclient(client); } } private void dostuffwithclient(tcpclient client) { // ... } } and main : static void main(string[] args) { var server = new server(); server.startlistening(); thread.sleep(5000); server.stoplistening();

Store input values in session variable and get them back (PHP related) -

i have form in there 10 fields, of them drop downs. halfway through there 1 drop down list mandatory , next link adding new item drop down. add new link goes form entry can made , entry reflected in drop down. want when form comes original form values in fields prior drop down must retained. remember link element data not getting posted values cannot taken session without pressing submit button. tried session not working because said without pressing button values not posted no question of getting them in session. or hint appreciated. problem happens on social networking sites. when start filling profile somewhere in between asked upload image. link takes page after loading photo come original form , values still retained. form still not complete , not submitted filled values there. here code drop down list think code not of help. scenario important in case: <tr> <td> dealer name </td> <td> <?php if(isset($_get['n

c++ - Time complexity of nested loop: where does cn(n+1)/2 come from? -

consider following loop: (i =1; <= n; i++) { (j = 1; j <= i; j++) { k = k + + j; } } the outer loop executes n times. i= 1, 2, ..., inner loop executed 1 time, 2 times, , n times. thus, time complexity loop t(n)=c+2c+3c+4c...nc =cn(n+1)/2 =c/2(n^2)+c/2n =o(n^2).. ok don't understand how time complexity, t(n) determines c+2c+3c. etc.. , cn(n+1)/2? did come from? the sum 1 + 2 + 3 + 4 + ... + n equal n(n+1)/2, gauss series . therefore, c + 2c + 3c + ... + nc = c(1 + 2 + 3 + ... + n) = cn(n+1) / 2 this summation comes lot in algorithmic analysis , useful know when working big-o notation. or question summation comes @ all? hope helps!

php - retrieve input type file value using get method -

this question has answer here: how file path in html <input type=“file”> in php? 3 answers i m trying update images using method user_form.php <form action='upload.php' method='get'> <input type='file' name='user_img' /> <input type='text' name='username' /> <input type='submit' name='update' value='update'> </form> upload.php if(isset($_get['update'])) { echo 'username: '.$_get['username']; echo 'file name: '.$_files['user_img']['tmp_name']; } i m getting correct value username, however, blank value filename. can please let me know if can use $_files variable method? if yes please point out m going wrong in above sample code. thank you. you cannot upload files using http request.

c# - iTextSharp aspx to pdf, Server.Execute error -

in asp.net have made webpage used fill in offer form. there 3 divs. left div has textboxes fill in. middlesector form itself. right div has buttons. so far i've been able export midlesector pdf stuff filled in on left , all. problem neglects css, has been made using absolute positioning. therefore ask how include css style looks way it's supposed instead of 1 continuous text. this code middlesector: <div id="middlesector" runat="server"> <%--><asp:gridview id="gridview1" runat="server"></asp:gridview>--%> <asp:image id="textarea1" runat="server" imageurl="images\vissergroup.png"></asp:image> <label id="textarea2" runat="server" cols="20" name="s2"></label> <label id="textarea3" runat="server" cols="20" name="s3">visser international trade & engineering</labe