Posts

Showing posts from March, 2012

python - Any way to issue telnet commands remotely ander double telnet session? -

what need: telnet 1.1.1.1 (no password or login required) #connected telnet localhost 1234 command_1 command_2 command_3 exit exit is there way write on bash or python ? you can pass input telnet using pipe. @ shell: $ echo "echo -e 'command_1\ncommand_2\ncommand_3' | telnet localhost 1234" | telnet 1.1.1.1

javascript - Why are link and script tags not typed as elements? -

i thought every element returned document.getelementbyid or document.createelement in fact version of dom element, , version found using typeof . however, discovered not case when tried script , link tags. jsfiddle demo html <link id="l"> <script id="s"> js var l = document.getelementbyid("l"); console.log(typeof l);//"object" var s = document.getelementbyid("s"); console.log(typeof s);//"object" var li = document.createelement("link"); console.log(typeof li);//"object" var sc = document.createelement("script"); console.log(typeof sc);//"object" why these elements typed objects? they elements, , same result other types of elements. try : var li = document.createelement("link"); console.log(li instanceof htmlelement); it logs true link instance of htmllinkelement specialization of htmlelement . but typeof returns "object&q

java - Run a native app with a web app on PhoneGap -

my question is: posible run native app using web app developed on phonegap?, need make that, reading necessary create plugin connect other native app, i'm starting programming on phonegap still don't understand much, , need create that. need explicit. thanks. yes, can create phonegap native plugin enable create custom functionality in native code, , expose phonegap applications via phonegap's native-to-javascript bridge. more information plugins , example of how implement them check tutorial: http://www.adobe.com/devnet/html5/articles/extending-phonegap-with-native-plugins-for-android.html

jquery - bookmark modal window so next time it opens if the page is open -

using bootstrap. i have lot of links on page. clicking on of links bringing modal window. the question: i able bookmark modal window next time use bookmark specific modal window appears. perhaps use hashtag in url e.g. www.website.com/foo#modal1 , make script displays modal depending on hashtag. javascript: $(document).on("ready", function(){ if(window.location.hash == '#modal1') { $("#modal1").modal('show'); } $(".open-modal").click(function(){ $("#modal1").modal('show'); window.location.hash = 'modal1'; }); $(".close-modal").click(function(){ $("#modal1").modal('hide'); window.location.hash = ''; }); }); html: <div id="modal1" class="modal hide fade"> modal <button class="close-modal">close modal</button> </div> <button cla

php - Needing to Pass Post Data to new page after Redirect (using iFrames) -

i in of sticky situation because client insists on keeping iframe functionality , wants page, after submitting information, review , on said information before submitting, if it's not right, go , re-submit changes. basically, before confused want use form's action , post method using button outside iframe.... i using codiqa's buttons outside iframe target inner frame's js functions, when call review function redirects page, however, new page not display information have seemingly passed along via ajax. can please tell me why isn't working? html , irrelevant because passing input ids , ajax data (eid collects , iterates through html input ids), strictly need special js function might missing. when codiqa button pressed, calling "reviewdata()" function in js: js //upload data //global variables var extractform = { 'cable_no' : "", 'section_no' : "", 'extract_ft' : "", 'cabl

c++ - QThread Memory Leak -

main.cpp: #include <qcoreapplication> #include <qtcore> #include "myobject.h" qthread* cthread; myobject* cobject; int main(int argc, char *argv[]) { qcoreapplication a(argc, argv); cthread = new qthread(); cobject = new myobject(); cobject->movetothread(cthread); qobject::connect(cthread, signal(started()), cobject, slot(dowork())); qobject::connect(cthread, signal(finished()), cthread, slot(deletelater())); qobject::connect(cthread, signal(finished()), cobject, slot(deletelater())); cthread->start(); return a.exec(); } myobject.cpp: #include "myobject.h" myobject::myobject(qobject *parent) : qobject(parent) { } void myobject::dowork() { qdebug() << "hi"; qthread::currentthread()->quit(); return; } myobject.h: #ifndef myobject_h #define myobject_h #include <qtcore> class myobject : pub

powershell - Can't Uninstall Sharepoint Application - Invalid State -

our sharepoint 2013 application failed install , stuck in odd state. followed recommended approach deleting application using powershell commands on hosted sharepoint server, doesn't execute properly. visual studio deployment/retract reports: skipping uninstall step because app sharepoint in invalid state , cannot uninstalled. powershell commands $instances = get-spappinstance -web http://mysite/sites/collection $instance = $instances | {$_.title -eq 'application.title'} uninstall-spappinstance -identity $instance executing ps command throws... system account cannot perform action. there no option sharepoint ui remove application, , retrying install fails. i've tried other user accounts execute powershell command ( other system account ), no dice. have delete developer site collection if there no other solution. i'm faced problem before on office 365 sharepoint online when deploy sharepoint hosted app. submit microsoft service requ

string - How do I copy a chunk of Unicode text? -

i have field "data" unicode text in displays properly. want copy chunk of , put field called "somedata". i tried following script in button on mouseup put word 2 of line 1 of unicodetext of field "data" t set unicodetext of field "somedata" t end mouseup non unicode text displays fine in field "somedata" unicode text not. here one-liner can test: set unicodetext of field 2 unicodetext of word 2 of field 1

algorithm - BFS - WordChain/Wordladder -

i need problem. want find longest shortest path between word , given endword. words have of length 4. have graph each node represents word , every word different in 1 position connected. i have list words. have proper function finds longest shortest path, starts every word in word list , bfs every word in word list. how can i, given endword, find word has longest shortest path given endword ? by longest shortest path mean shortest path words endword , longest path amongst them. how can 1 bfs ? thank you when doing breadth-first search, can tag each node in graph distance (the length of shortest path) source node. since word ladders reversible, try running breadth-first search end word, tagging each word how many hops away ending word. this, can keep track of word you've found that's far away possible start word. once you're done, can output word word distance far possible start word. hope helps!

javascript - xhr() call to sharepoint web part -

i trying use winjs.xhr() output of web part in sharepoint. i using fiddler dissect request , can see request has 4 actions, third returns of html/markup , fourth returns data retrieved sharepoint underlying data source, , somewhere merged together. when view source of page not see data fourth call in markup - meaning xhr() call not include data need. does have experience getting full output of web part control? goal take data web part , display in windows rt application.

visual studio - How can I mix the Concurrency Runtime with .NET code? -

i've been using concurrency runtime in c++ static library, , wanted use library in c++/cli project, take advantage of windows form designer , avoid mfc. unfortunately, concurrency runtime not compatible /clr switch required in c++/cli. tried surrounding included header files use concurrency runtime in "#pragma unmanaged ... #pragma managed" directives, while that's worked me other code in past, doesn't seem work in case. mean error: c:\program files (x86)\microsoft visual studio 10.0\vc\include\concrt.h(27): fatal error c1189: #error : error: concurrency runtime not supported when compiling /clr. i'm not super versed in mixing managed , unmanaged code, it's possible there's work-around i'm not aware of. on other hand, perhaps silly approach. if weren't fact find mfc impossibly complex, , form designer nice , easy, i'd pure c++. preference mixing two, suggestions? using concrt in c++/cli explicitly disabled in concrt.h via

associations - CakePHP associating Users with one City -

i have user table , table cities, want associate each other. guess, city can have multiple users 1 user can linked 1 city. i don't know how set tables up. when try $hasmany relation city , $hasone user getting error, because client_id field cannot found in cities table. cities table going fixed: no 1 ever change table. want store information city in table. edit: here tables , models (kept simple): clients { id, firstname, lastname, city_id } cities { id, name, some_other_data } and here models: // user class client extends appmodel { public $hasone = array( 'city' ); } // city class city extends appmodel { public $usetable = 'cities'; public $hasmany = array( 'client' ); } you need reverse relation; client 'belongsto' city. (i know, sounds illogical); // user class client extends appmodel { public $belongsto = array( 'city' ); } // city class city extends appmod

javascript - JQuery Post Array to PHP -

i know there many questions this, none of seem allow me understand. have following js code: function clicktosave() { var data1 = ckeditor.instances.texttobesaved1.getdata(); var data2 = ckeditor.instances.texttobesaved2.getdata(); var data3 = ckeditor.instances.texttobesaved3.getdata(); var data4 = ckeditor.instances.texttobesaved4.getdata(); var data5 = ckeditor.instances.texttobesaved5.getdata(); $.post('/admin/post_handler.php', { page_content_1 : data1, page_content_2 : data2, page_content_3 : data3, page_content_4 : data4, page_content_5 : data5 })} i'm trying post ckeditor php page pickup , know data goes where. js meant save several inline div id's simultaneously when user clicks save. had code working great when using 1 div id, multiple proving more challenging. i'm having little trouble replying people site makes posts little odd. above code won't work. following code work: function clicktosave() { var data1 = ckeditor.instances.texttob

android - Not seeing maps extending from MapActivity -

when upload apk device, can't see maps. i've tried fragmentactivity , can see maps without problem, in case using mapactivity don't. the google maps android api v2 service on. idea? in advance! code: package com.avargas.mapas2; import android.os.bundle; import android.view.menu; import com.avargas.mapas2.r; import com.google.android.maps.mapactivity; import com.google.android.maps.mapview; public class mainactivity extends mapactivity { private mapview mapa; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mapa = (mapview) this.findviewbyid(r.id.mapview); mapa.setbuiltinzoomcontrols(true); mapa.settraffic(true); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true;

socialengine - PHP message: PHP Notice: Undefined variable: -

in error log getting lot of php message: php notice: undefined variable: gendername in variables under $userdata['']. undefined because trying define them using array. wondering best way define variables not getting issues in logs anymore. if (!$location) $location = "-"; $userdata = array(); $userdata['id'] = $userinfo['user_id']; $userdata['username'] = $userinfo['username']; $userdata['gender'] = $gendername; $userdata['age'] = $age; $userdata['photo'] = $photo; $userdata['location'] = $location; $userdata['description'] = $description; $userdata['isadminormoderator'] = $typeuser; $userdata['profile'] = site."/".$userinfo['username'];

android - Trying to hide and show menu items on action bar -

i have looked through questions on stack overflow , can't find solution. @override public boolean onprepareoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.themenu, menu); menuitem item = menu.finditem(r.id.menu_settings); menuitem item2 = menu.finditem(r.id.menu_save); item.setvisible(isdown); item2.setvisible(isdown); return true; } this sets menu items visible (item1 , item2). onclick works fine public void inflatetextarea() { if(isdown == true) { isdown = false; linearlayout tl = (linearlayout)findviewbyid(r.id.content); tl.setvisibility(view.visible); scaleanimation scale = new scaleanimation(1, 1, 0, 1); scale.setfillafter(true); scale.setduration(500); tl.startanimation(scale); } } then sets isdown boolean false. on stack people onprepareoptionsmenu should fire everytime click not case. able hide 1 menu item on onclick function

sh - Bash string, passed to GDB -

i'm trying write bash script autorestart application have. want have program run in gdb. anyways not issue is. if watch gist: https://gist.github.com/lillecarl/5421446 you see on line 91 "call" file gdbcommands. really grinds gears must have external file, of gurus have suggestions on how merge wowadmin.sh? in case must, can separate file. prefer inside sh file. best regards carl hjerpe! you can pass multiple command using -ex switch. reason not documented in man (at least on centos), appears in full gdb manual http://sourceware.org/gdb/current/onlinedocs/gdb.html#invocation gdb -ex 'print "one"' -ex 'print "two"' my_prog

knockout.js - Knockout recursive template selective binding -

in example, i've got nested template display tree-view indented output, rendered html on leaf nodes not expect. how leaf nodes render expected html , not contain child container div? if put if binding outside template binding, javascript error: uncaught error: multiple bindings (if , template) trying control descendant bindings of same element. cannot use these bindings on same element. note: using if binding comment <!-- ko if: children().length > 0 --> work remove unwanted element, resulting html riddled comments , i'd prefer keep clean have potentially hundreds of leaf nodes. i've tried using 2 templates, 1 container , 1 without, , putting in condition name, template rendered nodetempl: data-bind="template: { name: (children().length > 0) ? 'nodetempl' : 'leaftempl', foreach: children }" i guess want apply different template based on state of child it's processing. a leaf node rendering this <div> &l

ajax - Chaning root of url load to javascript file? -

so when loading scripts or images .html file uses current location root of url call functions. when loading in external javascript file so: <script type="text/javascript" src="external_java.js"></script> anything gets called javascript file above use .html's location on server rather .js file's location. there way change this? that way when calling on xml file use .js location root of call? $.ajax({ type: "get", url: ../template/file.xml, datatype: "xml", success: function(xml) { /*do here*/ } }); you can absolute src of script files looking in document.scripts : so if know first script load on page src="external_java.js" , checking document.scripts[0].src give absolute path file. from there i'd replace file name nothing in got src , have absolute root path... eg: var root = document.scripts[0].src.replace("external_java.js", "&q

ios - Saving a proprietary file to Dropbox using Document Interaction -

i'm trying save custom file extension dropbox using documentinteractioncontroller. dropbox show in documentinteractioncontroller's "open in" menu when file has recognized extension such .txt. there number of related topics tried follow. 1 example: associating app's custom file in ios . the following shows uiexportedtypedeclarations: <key>uiexportedtypedeclarations</key> <array> <dict> <key>uitypeidentifier</key> <string>com.mysite.myapp.myext</string> <key>uitypedescription</key> <string>my special file</string> <key>uitypetagspecification</key> <dict> <key>public.filename-extension</key> <string>myext</string> <key>public.mime-type</key> <string>application/octet-stream</string> </dict> <key>ui

numpy - Hand gesture recognition (PCA) - Python -

this question has answer here: face recognition - python 1 answer i trying make hand gesture recognition principal component analysis (pca) using python. following steps in tutorial: http://onionesquereality.wordpress.com/2009/02/11/face-recognition-using-eigenfaces-and-distance-classifiers-a-tutorial/ here code: import os pil import image import numpy np import glob import numpy.linalg linalg #step 1: put training images 2d array filenames = glob.glob('c:\\users\\karim\\desktop\\training & test images\\new folder\\training/*.png') filenames.sort() img = [image.open(fn).convert('l').resize((90, 90)) fn in filenames] images = np.asarray([np.array(im).flatten() im in img]) #step 2: find mean image , mean-shifted input images mean_image = images.mean(axis=0) shifted_images = images - mean_image #step 3: covariance c = np.asmatrix(shifted_im

python - Index out of Range in a 'for' loop -

i working on project converting csv file arcgis shapefile, involves writing output separate file. have created list each column in each row , trying index column 36 , 37. however, getting list index out of range error message when doing this. suggestions may doing? while line: count = count + 1 line = infile.readline() print 'row', count, 'line info=', line[:72] linelist = line.split(',') newlist = linelist[:72] print 'line info =', newlist item in newlist[36]: item.replace("", "0") item in newlist[37]: item.replace("", "0") newline = ','.join(newlist) newline = newline + '\n' formatline = newline.replace("/","_") outfile.write(formatline) it if edit question include line error says having index out of range problem. i believe issue this: while line: # line other whitespace line = infil

Echo Joomla K2 Item Title in Main Template Using PHP -

i'm trying echo title of current k2 item i'm viewing, echo not occur within k2 template, should show in main site template. i tried this: <?php echo $this->title; ?> but displays full site title including company name because have set way in main joomla configuration. i don't want full site title generated 'title' tag in head of website; want generate name of specific item viewing. pretty easy, php knowledge limited. i realise pretty old. if still looking solution. not elegant want. firstly, in case weren't aware, can article id anywhere in doing jrequest:getvar('id') use request id url. $id = jrequest::getvar('id'); $id = explode(':',$id); echo $id[0]; the reason exploding because in site using aliases if , echo $id without see in form id:alias . using method, query database name associated id in k2_items table. create function else in templates folder assign variable echo in template. keeps te

c++ - Is this function really tail-recursive? -

i read recursion in programming interviews exposed (3rd ed.) present following recursive factorial function: int factorial(int n){ if (n > 1) { /* recursive case */ return factorial(n-1) * n; } else { /* base case */ return 1; } } on bottom of same page (page 108) talk tail-recursive functions: note when value returned recursive call returned, in preceding definition factorial , function tail-recursive . but case here? last call in function * call, won't stack frame preserved (if don't take compiler optimization account)? tail-recursive? no, it's not tail-recursive. result being returned factorial(n-1) still has multiplied n , requires factorial(n) regain control (thus mandating call factorial(n-1) call rather jump). with said, if tail-recursive, compiler still might not tco on it. depends on compiler , optimizations ask do.

c++ - Seg Fault when creating dynamic array of strings -

my friend writing text-based game , asked me @ code crashing. debugged , getting seg fault when creating dynamic array. i'm not sure why, recommended avoid pointers altogether , use vector solve problem i'm curious going wrong here. here's code: #include <iostream> #include <fstream> #include <string> #include <cstdlib> #include <ctime> using namespace std; class nation { public: void init(); string genname(); string getname(); private: string myname; int* myborderpoints; }; string nation::getname() { return myname; } string nation::genname() { int listlength = 0, listpos = 0, listrand = 0; string nametogen = ""; string* namepartlist; ifstream filename; filename.open("namepart1.txt"); listlength = filename.tellg(); namepartlist = new string[listlength]; // seg fault here while (filename.good()) { while (!filename.eof()) {

git svn - How do I update the perl subversion bindings on OSX? -

i'm having a problem git-svn may related perl svn bindings. after installing new versions of subversion , git using homebrew, git-svn using old version of svn: $ git svn --version git-svn version 1.8.2.1 (svn 1.6.18) $ svn --version svn, version 1.7.7 (r1393599) how make git-svn use newer version of svn? thanks this answer , found reasonable solution. ran sudo cpan svn::core , updated svn version of git-svn: $ git svn --version git-svn version 1.8.2.1 (svn 1.7.3) the native svn version unchanged. i'm left 2 different versions of svn, @ least same major version.

c++ - Why is the template function ambiguous? -

when compile code error saying call of overloaded swap(int&, int&) ambiguous but i've written 1 swap function here. can tell me why function ambiguous , changes need run program correctly? using namespace std; template <class t> void swap(t& x, t& y) { t temp; temp = x; x = y; y = temp; } int main() { int a, b; cout << "enter 2 elements: "; cin >> a; cin >> b; swap(a, b); cout << "a "<<a << '\t'<<"b " << b << std::endl; return 0; } why swapping function overloaded though has only swap function? you should use ::swap(a,b); //use 1 in global namespace, 1 defined if call 1 defined. since std has defined swap function template, compiler search std namespace if not use :: . more specifically, parameter a , b of type int , defined in std namespace , when compiler searches swap , find bot

cocos2d iphone - How to prevent blur from using colors outside of the texture? -

i'm trying create shader blurs, , i've done that. however, theres 1 problem. around texture there black background, , when shader runs grabbing color background , ends darkening entire image (but still blurs image fine, if lowering brightness). sure thats thought going on, set background white, , sure enough made image duller. don't know how prevent this, suppose grabbing them outside because blur size reaching outside texture boundary, there way prevent texture ups occuring outside of texture i'm dealing with? frag: precision mediump float; uniform sampler2d cc_texture0; uniform float u_time; const lowp int samples = 9; varying vec2 v_texcoord; varying highp vec2 transcord[samples]; void main() { vec4 sum = vec4(0.0); sum += texture2d(cc_texture0, transcord[0]) * 0.05; sum += texture2d(cc_texture0, transcord[1]) * 0.09; sum += texture2d(cc_texture0, transcord[2]) * 0.12; sum += texture2d(cc_texture0, transcord[3]) * 0.15;

php - How to grab an auto incremented variable and insert it into an insert query -

i trying couple of php insert queries relational database, running bit of issue. in order relation work need grab autoincremented value first query , insert second query relation between 2 exists. i have this: $query2 = "insert words values ('' ,'$name') "; -- first value listed '' auto-incremented primary key -- $query3 = "insert synonyms values ('' , '', $alias') "; -- first value listed auto incremented pk, second value needs fk or pk first query, don't know how place there. -- is there way this? appreciated. here sql fiddle y'all out: http://sqlfiddle.com/#!2/47d42 <?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('could not connect: ' . mysql_error()); } mysql_select_db('mydb'); mysql_query("insert words(word) values ('word1')"); $last_id = m

c# - Query String Value always 0 -

this easy one, cannot see wrong.. i have string being added url: /projects.aspx?pid=3 and in code behind trying grab value so: public partial class projects : system.web.ui.page { public int pid { get; set; } protected void page_load(object sender, eventargs e) { if (!page.ispostback) { pid = convert.toint32(request.querystring["pid"]); //this returning 0 when should have value. databind(true); populatetestsuitelist(); } testsuitesdatalist.itemcommand += new repeatercommandeventhandler(this.item_command); } when try @ value of pid in other functions, gives me '0'. don't see why won't give me 3 should? here example functions: private void executeinsert(string testsuitename, string testsuitedescription, int projectid) { sqlconnection conn = new sqlconnection(getconnectionstring()); string sql = "insert testsuites (projectid, testsuitena

database - Java creating a roster of unknown size -

i'm posting pick brain kind of question. array appropriate type of data holder roster of unknown size? i looking create small class 3 methods addtoroster //which add name proposed array taking in array , string. getroster //which return elements of roster printed console. remfrroster // take name, cycle through roster , remove if found. i'm beginner @ java. i've been programming week , looking find out few things. one, appropriate design methodology class? two, arrays preferred method storing roster of strings? lastly, have initialize array definite size or can have change size approaches limits of size initialized to? thanks, pano you use arraylist: arraylist<player> roster = new arraylist<player>(); roster.add(new player(32)); system.out.println(roster.get(0).getage()); an arraylist same thing array, it's size can changed. use arraylist if number of players on roster going change while program running. i.e

android - onCreate() in ContentProvider is not being called -

oncreate() method in contentprovider not being called. though when click on button, goes inside insert() method , returns java.lang.nullpointerexception . in oncreate() method have have @override public boolean oncreate() { log.v(tag,"inside create provider"); database = new databasesqlitemydb(getcontext()); return false; } log cat shows: 04-20 01:23:00.543: v/clicked(1607): clicked 04-20 01:23:00.553: v/provider(1607): inside insert 04-20 01:23:00.573: v/database(1607): created 04-20 01:23:00.573: e/pkg.onput_clicklistener(1607): java.lang.nullpointerexception 04-20 01:23:00.583: v/pkg.onput_clicklistener(1607): in exception code in manifest : <provider android:name="somepkg.customcontentprovider" android:authorities="somepkg.provider" /> while creating uri upon click : { myuri=builduri("content", "somepkg.provider"); this.putno=putno; mconte

c - why does my printf statement pop up simultaneously? and get an infinite loop? -

why when start program, start doing first printf statement, , input, simultaneously 2 printf statements. what's causing infinite loop well? starting program player 1: choose symbol: this part, both output simultaneously player 2: choose symbol: player1, enter placement: and infinite loop. due simultaneous output? code include <stdio.h> int check(char player); void move(char player); char board[3][3] ; int main(void) { int first; char player1, player2; printf("player 1: choose symbol: \n"); player1 = getchar(); printf("player 2: choose symbol: \n"); player2 = getchar(); int i=0; int win;char turn; while(win == 0) { if((i%2) == 0){ turn = player1; move(player1); win = check(player1); print();} else { turn = player2; move(player2); win = check(player2);

dart - How to implement Iterable<E> -

i trying port java code below dart , puzzled this. in java iterable interface clean 1 method , implement snap. how code best transformed dart? /** * chess squares represented bitmap. */ public class chesssquares implements iterable<chesssquare> { private static class chesssquaresiterator implements iterator<chesssquare> { long bits; int nextbit; public chesssquaresiterator(long bits) { this.bits = bits; nextbit = long.numberoftrailingzeros(bits); } @override public boolean hasnext() { return (nextbit < 64); } @override public chesssquare next() { chesssquare sq = chesssquare.values()[nextbit]; bits = bits & ~sq.bit; nextbit = long.numberoftrailingzeros(bits); return sq; } @override public void remove() { throw new unsupportedoperationexception(); } } @override public iterator<chesssquare> iterator() { return new chesssquares

Can I use Parameters of a method invoked within an array in Java -

this in main() method: movie[] list = new movie[6]; list[0] = new animated(.25, 700.000, "mulan", "barry cook", 1998, 15.000); list[1] = new animated(.23, 45.000, "tmnt", "steve barron", 1990, 12.000); list[2] = new documentary(12, 7.000, "nixon", "oliver stone", 1995, 50.000); list[3] = new documentary(10, 4.500, "jfk", "oliver stone", 1991, 35.000); list[4] = new drama(3.500, 8.25, "belly", "hype williams", 1998, 20.000); list[5] = new drama(4.500, 9.00, "42", "brian helgeland", 2013, 16.000); system.out.print(menu()); system.out.print("select , menu option 1-5: "); choice = input.nextint(); { switch(choice) { case 1: movielist(list); break; and i'm calling movielist(list) method exists within class outside main : public static void movielist(movie[] a) { system.out.printf("\n\n%-10s %-10s %-10s %-10s %-

python - Output length mismatch in nested loops? -

i got problem number of outputs loop. neighbours=[]#this array hold distance k-th neighbour in range(0, len(selection)-1):#208 values in selection n2 =[]#this array hold distance other 207 points k in range(0, len(selection)-1): d = {} if != k:#to remove same point being considered ra_diff = selection[i]['ra']-selection[k]['ra'] dec_diff= selection[i]['dec']-selection[k]['dec'] d=float(math.hypot(ra_diff , dec_diff))#finds distance n2.append(d) n2.sort() neighbours.append(n2[6])#passes 7th value array this part of code find k-nearest neighbour. selection has 208 values, nested loop should calculate distance points , find 7th closest point each point. after iteration neighbours array holds 207 values(i.e. len(neighbours)=207), there should 7th closest neighbour 208 values. can please point me problem is? this line: for in range(0

iphone - How is UITableViewCellSelectionStyleGray implemented? -

i want mimic style in code, more in setselected. does have idea how do assuming i'm using custom cell. all cell selection styles implemented setting selectedbackgroundview property of cell. system blue , white ones, these built-in views blue , grey gradients. setting cell selection style blue or grey tells cell use 1 of views selected background. you can still use styles custom cells, assuming you've added of cell content content view. you can create own view (typically stretchable image or custom drawing view) , set selected background view custom effects. when cell selected, tell of content view subviews (labels etc) become highlighted, if can. can control how looks setting highlightedtextcolor on labels. you can achieve without needing touch setselected . it's done base implementation.

shell - Case statement not working -

its part of program, output="$(./t1)" // output=5 echo $output // displays 5 if test $output -eq 5 echo "five" // if statement works , displays 'five' fi case $output in **// case not working , giving default value** 1) echo "one" ;; 2) echo "two" ;; 3) echo "three" ;; 4) echo "four";; 5) echo "five";; *) echo "wrong choice" ;; esac // output wrong choice though works proper in if statement is there mistake in bash script? please help. this works me: output=$(./t1) echo $output if test $output -eq 5; echo "five"; fi case $output in 1) echo "one" ;; 2) echo "two" ;; 3) echo "three" ;; 4) echo "four";; 5) echo "five";; *) echo "wrong choice" ;; esac when had " around $(./t1) result string, not numeric value. worked test , n

php - MySQL: How to pre-append text to data in an existing column? -

this question has answer here: how prepend string column value in mysql? 5 answers i have populated mysql table need pre-append text "new_" name field. (long story, needs done now.) i imagine can done update i'm not sure how add "new_" start of 'name' column. work in php, need in php read each record, extract 'name' field, add , update record? or can done in mysql? use query update table_name set `name` = concat('new_',`name`)

python - How to write inline latex code in IPython notebook -

this might painfully obvious how write latex script inline in ipython notebook file when parsed not start new line? the answer can found in helpful cookbook inline uses $...$ displayed used $$...$$

Unable to register A Custom angularjs filter -

i trying write own filter in angular. while trying register filter error, error: no module: customfiltermodule [break on error] throw error('no module: ' + name); angular.js (line 1090) error: no module: myapp [break on error] throw error('no module: ' + name); javascript: angular.module('customfiltermodule') .filter('customfilter', function() { return function(listing, param) { var out = []; // perform filtering logic return smaller array return out; }; }); var myapp = angular.module('myapp', ['customfiltermodule']); function appcontroller($scope) { // controller code } html: <div class="container" id="mainbody" ng-app="myapp"> <div id="listingslistbody" class="row" ng-controller="mycontroller"> ... <div class="sub-container"> <

c# - Log deleted files when button is clicked? Log all files (deleted and undeleted) -

i writing application delete file on test folder on 6 months, application works fine have tested it, wanted create log file keep track of name of deleted files audit purpose. but scirpt below record files (deleted , undeleted), need record date , time , name of deleted files. thank you script below: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using system.io; namespace delete_pdf_files { public partial class form1 : form { private string strlogtext; public form1() { initializecomponent(); } private void btncheck_click(object sender, eventargs e) { // check number of file in cps directory on s drive listbox1.items.clear(); string[] files = system.io.directory.getfiles(@"c:\test\"); // @"s:\cps papers\" this.listbox1.it

winforms - C# Get form names of project A from Project B -

i have 2 projects in 1 solution, project a , project b ( using vs2010 ultimate , c# windows application ). project b acts user management application project a . in project b have form contains chekcedlistbox control list project a forms names , texts (this form let system administrator grant users forms allowed view/edit based on security groups) code: private void getformnames() { foreach (assembly in appdomain.currentdomain.getassemblies()) { foreach (type t in a.gettypes()) { if (t.basetype == typeof(form)) { var emptyctor = t.getconstructor(type.emptytypes); if (emptyctor != null) { var f = (form)emptyctor.invoke(new object[] { }); string formtext = f.text; string formname = f.name; checkedlistbox1.items.add("" + formtext + &quo

jquery - loading handlebars template asynchronously -

i'm trying write function give me compiled handlebars template (i have templates in separate files) using ajax call template , compile use, need use promise can use it. function gettemplate(name){ $.get('/'+name+'.hbs').success(function(src){ var template = handlebars.compile(src); //can't return template here. }); } how do promises can like: $("a").click(function(e){ gettemplate('form').done(function(template){ $("body").append(template({ name: "my name" }) ); }); }); chovy, see have accepted answer might interested know gettemplate can, chaining .then() rather .success() , written in question : function gettemplate(name) { return $.get('/'+name+'.hbs').then(function(src) { return handlebars.compile(src); }); } or, adopting charlietfl's idea pass in data , return promise of composed fragment :

java - How variables are created inside a class when the class is not real? -

i have read class model creating objects , does not exist physically whereas objects real. creating variables inside class , manipulating them. how possible when class not exist physically? when memory created these variables? where memory created these variables? if mean static class variables, quaranteed initualized , static initialization code inside class quaranteed run, before class used. when, not specified iirc, , different jvms may @ different time. same thing global variables in languages have those. so reiterate: static stuff exists , initialized before first used. jvm implementation takes care of that. but there object: instance of class object, subclass of class class . addition: in fact, in java classes exist concretely, can serialized, transferred on network different jvm, deserialized there, objects of class created there , code executed. simple example of vanilla java applets running in browser. example slave nodes in jenkins/hudson ci system

android - App Crash Boot the Phone -

i totally confused why app crashing when boot phone. my androidmanifest.xml : <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.callmenew" android:versioncode="1" android:versionname="1.0" > <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.call_phone" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.read_phone_state"/> <uses-permission android:name="android.permission.use_sip" /> <uses-permission android:name="android.permission.vibrate" /> <uses-permission android:name="android.permission.access_wifi_state" /> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.recor