Posts

Showing posts from May, 2015

java - ArrayList and array: Why do they have different max lengths? -

according these questions so: list max size array max length the max length of array integer.max_value - 5 , whereas max size of list integer.max_value when @ arraylist , wrapper around array. how can wrapper allow length longer of array under hood?

jquery - functions does not run -

i want know problem in code : i want div fade in but id don't know why doesn't run want. hope me. <!doctype html> <html> <head> <title> site </title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"> </script> <script type="text/javascript"> $(document) .ready (function() { $("#frame").fadein(3000); }); </script> <style type="text/css" media="all"> * {margin:0 auto; padding:0;} body {background:#333;} #myframe {width:500px; height:300px; background:#006699;font:50px tahoma; text-align:center; color:#fff; line-height:100px;} </style> </head> <body> <div id="myframe"> site . <br /> site. </div> </body> </html> css: #myframe{ ... d

c# - Getting data from an xml file based on array from another query from another xml file -

i have xml file table student , below structure. <?xml version="1.0" encoding="utf-8"?> <studentmodules> <student student_id="001"> <module id="m001" /> <module id="m002" /> <module id="m003" /> <module id="m004" /> </student> <student student_id="002"> <module id="m005"/> <module id="m006" /> <module id="m007"/> <module id="m008" /> </student> then have file modules , below structure <?xml version="1.0" encoding="utf-8"?> <moduleschedule> <moduletimetable module_id="m001" modulename="module name 1"> <slot day="monday" time="09:30"/> <slot day="tuesday" time="14:30"/> <slot day="fridayday" time=

how to compile and run android application using a batch file and not IDE? -

how can compile , run android application using batch file , not other ide? possible do? , if possible, can teach me how make batch file? don't have idea it, know how run id using eclipse ide. thank you. from android doc , i'll add debug mode: debug mode for immediate application testing , debugging, can build application in debug mode , install on emulator. in debug mode, build tools automatically sign application debug key , optimize package zipalign. to build in debug mode: open command-line , navigate root of project directory. use ant compile project in debug mode: ant debug creates debug .apk file inside project bin/ directory, named -debug.apk. file signed debug key , has been aligned zipalign. each time change source file or resource, must run ant again in order package latest version of application. to install , run application on emulator, see following section running on emulator. how run befor

javascript - Load items with ajax in div's -

i'm using following javascript load items in a few div's: <script> $.ajax({ url: 'load.php?type=diva', cache: false, success: function(data){ $('#diva').html(data); } }); $.ajax({ url: 'load.php?type=divb', cache: false, success: function(data){ $('#divb').html(data); } }); </script> html: <div id="diva"> <!-- load diva item here --> </div> <div id="divb"> <!-- load divb item here --> </div> i'm looking (and think) there's better way this. similar this: 1 function div's, automatically loads items in (multiply) div's: function loaditem(<div id>) { $.ajax({ url: 'load.php?type=<div id>', cache: false, success: function(data){ $('<div id>').html(data);

algorithm - Permutation of all the characters when few characters are always together -

i trying obtain permutation of characters in string lets 'kiran'. can use : perms('kiran') this returns permutation of character in string factorial(5)=120. now, looking obtain, permutation of string when characters 'ira' together. the answer factorial(3) = 6. i write module returns permutation of characters, 'ira' together. any idea how programmatically obtain in matlab? thanks x={'k','ira','n'} %one permutation per row y=x(perms(1:numel(x))) %concatinate rows y=arrayfun(@(x)[y{x,:}],1:size(y,1),'uniformoutput',false)

c++ cli - Unable to use dynamic_cast with generics -

i have generic class client has single type parameter. type parameter reference type derived base . declare class below: generic <class t> t : base, gcnew() public ref class client { t val; void setval(base ^bval){ val = dynamic_cast<t>(bval); // error c2682: cannot use 'dynamic_cast' convert 'base ^' 't' } }; why compile error when using dynamic_cast convert base 1 of derived classes? expecting cast compile fail @ runtime (by returning nullptr ) in case argument of incorrect type. try dynamic_cast <t^> . pointers have cast other pointers, handles other handles, , forth.

for loop - Understanding how to multiply specific values in tuples in Python -

i no expert no means , not claim exercise have been having hardest time with. having issues understanding how call out values in 1 tuple , multiply them. keep on getting following output. def cost( ablock ): cost = portfolio[1]*portfolio[2] print(cost) output comes out >>> function cost @ 0x0594ad68 i unclear why want me use "ablock" parameter... where start program? blocks of stock. block of stock number of attributes, including purchase date, purchase price, number of shares, , ticker symbol. can record these pieces of information in tuple each block of stock , number of simple operations on blocks. let's dream have following portfolio. purchase date purchase price shares symbol current price 25 jan 2001 43.50 25 cat 92.45 25 jan 2001 42.80 50 dd 51.19 25 jan 2001 42.10 75 ek 34.87 25 jan 2001 37.58 100 gm 37.58 we can rep

Storing each sentence in an array from a document in java? -

i want split every sentence document , store each sentence in different arrays. each array element word of sentences. cant far this. int count =0,len=0; string sentence[]; string words[][]; sentence = name.split("\\."); count = sentence.length; system.out.print("total sentence: " ); system.out.println(count); int h; words = new string[count][]; (h = 0; h < count; h++) { string tmp[] = sentence[h].split(" "); words[h] = tmp; len = len + words[h].length; system.out.println("total words: " ); system.out.print(len); temp = sentence[h].split(delimiter); for(int = 0; < temp.length; i++) { system.out.print(len); system.out.println(temp[i]); len++; } } i can't understand code, here's how achieve stated intention 3 lines: string document; // read somewhere list<list<string>> words = new arraylist<>(); (string sentence : document.

node.js - Mongoose query for embedded mongodb documents -

here's schema: var videonode = new mongoose.schema({ title: string, uid: string, v_url:string, t1:number, t2:number, f_url:string, fullvideo: boolean, parentmap: string, creator: string, description_note: string, bookmarks: [ bookmark ], threads: [ string ], annotations: [ annotation ], cons: [string], justadded: boolean, position: { top: number, left: number } }); var annotation = new mongoose.schema({ starttime : date, dateadded : date, text : string, type_icon : string, author : string, messages : [message], voters : [string], annotation_type : string, stime_inseconds : number }); i'm trying query "annotations" user "logged in". here's query: socket.on('annotations:read', function (data, callback) { console.log(

ubuntu - Upgrading Mongodb when config instances use the same binary as data instances -

i'm upgrade sharded mongodb environment 2.0.7 2.2.9, want upgrade 2.4.9 apparently need via 2.2. release notes 2.2 state config servers should have binaries upgraded first, shards. have config instances using same mongo binary data instances. there 3 shards each 3 replicas, , 1 replica out of each shard functions config instance. since share binary can't upgrade config instances independent of of data instances. would upgrading data instances before of config instances cause problems, assuming i've disabled balancer? should change config instances use different copy of binary? if so, what's best way go existing production setup running on ubuntu 12? should remove 3 data instances replica sets, upgrade config instances, start data instances again, updating them well, in right order? last option bit hairy primaries, have step them down before removing them replica sets. last option occur again when have next upgrade, i'm not fan. i resolved issue by

How to fetch data from mongodb and show using node.js -

following code fetch data collection , show on index page, not giving results. node code - var app = require('express')(); var mongoose = require('mongoose'); var dburi = 'mongodb://localhost/test'; mongoose.connect(dburi); var testschema = new mongoose.schema({ name: string, rollnum: string }); var test = mongoose.model('test', testschema); app.get('/', function(req, res){ test.find({},function(err, docs){ res.send('index',{docs:docs}); }); //res.send('test'); }); app.listen(3001); however check , have collection in db - query fire - db.testinfo.find() output - { "_id": objectid("123456..78"), "name": "test", "rollnum": "xxxx" } after hitting url - http://127.0.0.1:3001/ this output getting - { "docs": [] } however expecting result of name, rollnum. please let me know doing

java - Having problems with arrays (involving user multiple inputs)? -

int number = keyboard.nextint(); string [][] myarray = new string[number][1] (int = 0; < x; i++) { system.out.println("enter food name: "); myarray[i][0] = keyboard.nextline(); (int j = 0; j < 1; j++) { system.out.println("enter type of food: "); myarray[i][j] = keyboard.nextline(); } } here code ask. want print out these outputs when run program: enter food name: (where user type or input) enter type of food: (where user type or input) (my problem prints out instead first loop:) enter food name: enter type of food: (where user type or input) with no way of entering food item. after first loop, program normal output want, how change code first loop take in user input "enter food name: "? thanks in advance. edit: sorry not seeing question beforehand 1 not loop if enter empty string before next input, loop not work. there fix this? edit: got work. everyone. you might try code below (this allo

c# - How do i filter and remove lines that don't contain the specifc word/s? -

this method now: private void wordsfilter(list<string> newtext) { (int = 0; < newtext.count; i++) { (int x = 0; x < wordslist.words.length; x++) { linetopost = scrolllabel._lines[i]; if (!linetopost.contains(wordslist.words[x])) { newtext.remove(linetopost); } } } } newtext list , worldslist.words string[] i loop on lines in newtext , loop on words , want check way: first line in newtext loop on words if none of of words exist in line remove current line , next line after it. example in newtext if line in index 0 : hello , line in index 1 is: created @ 12/3/2002 remove index 0 , index 1 index 2 empty space empty line not remove it. then index 3 loop on words if nonoe of words exist in line in index 3 remove index 3 , index 4 . and on... how can ? here working example . try didnt change logic of code : using system; using system.collections.gener

list - Python code for sum with condition -

the task following: sum list elements indexes , multiply result last list's elemet. have oneliner solution code in python. array = [-37,-36,-19,-99,29,20,3,-7,-64,84,36,62,26,-76,55,-24,84,49,-65,41] print sum(i in array if array.index(i) % 2 == 0)*array[-1] if array != [] else 0 my result -1476 ( calculation is: 41*(-37-19+29+3-64+36+26+55+84-65) ) the right result 1968. i can't figure out why code not working correctly in particular case. there repeated element 84 in list, array.index not work expected be. also, code has quadratic complexity not required. to fix code minimum amount of edit, this: array = [-37,-36,-19,-99,29,20,3,-7,-64,84,36,62,26,-76,55,-24,84,49,-65,41] print sum(array[i] in range(len(array)) if % 2 == 0)*array[-1] if array != [] else 0

python - Scipy's Optimize Curve Fit Limits -

Image
is there way can provide limits scipy's optimize curve fit? my example: def optimized_formula(x, m_1, m_2, y_1, y_2, ratio_2): return (log(x[0]) * m_1 + m_2)*((1 - x[1]/max_age)*(1-ratio_2)) + ((log(x[1]) * y_1 + y_2)*(x[1]/max_age)*ratio_2) popt, pcov = optimize.curve_fit(optimized_formula, usage_and_age, prices) x[0] age , max_age constant. in mind, x[0] approaches maximum, x[1]/max_age approaches 1. is possible provide constraint/limit whereby x[1]/max_age > 0.3 , x[1]/max_age < 0.7 , other constraints such m_1 < 0, m_2 > 0, , on. as suggested in answer, use lmfit these kind of problems. therefore, add example on how use in case interested in topic, too. let's have dataset follows: xdata = np.array([177.,180.,183.,187.,189.,190.,196.,197.,201.,202.,203.,204.,206.,218.,225.,231.,234., 252.,262.,266.,267.,268.,277.,286.,303.]) ydata = np.array([0.81,0.74,0.78,0.75,0.77,0.81,0.73,0.76,0.71,0.74,0.81,0.71,0.74,0.7

AngularJS toggle divs visibility through button -

i have multiple sets of 2 divs , button each per page. 2 divs contains alternating content button should handle switching visibility. can't seem think of angular solution can extensible multiple separate instances in page (my mind keeps wanting done in jquery). i have created jsfiddel example here. you see 2 divs p_table class <span class="trigger">a</span> . trigger should alternate 2 p_table inside parent div p_container . the key how doing ng-class, can ng-show/ng-hide. both implementations require no javascript, controller scope. ng-class: choose class based on variable, toggles on trigger click. <div class="p_container"> <p class="p_table" ng-class="{hidden:!show,chaldean:show}">this actual content</p> <p class="p_table" ng-class="{hidden:show,chaldean:!show}">this transliterated content</p> <span class="trigger" ng-click="show=!s

android - IQ Custom provider not recognized -

i using asmack openfire . after lot of research found openfire doesn't support message archiving , installed plugin openarchive . now archiving works fine , messages stored fine. now in client side tried sending iq stanza retrieve archived chats . first added iq provider below: pm.addiqprovider("list", "urn:xmpp:archive", new listiqprovider()); then used: final iq iq = new iq() { @override public string getchildelementxml() { return "<list xmlns='urn:xmpp:archive' with='test@customopenfire.com'><set xmlns='http://jabber.org/protocol/rsm'><max xmlns='http://jabber.org/protocol/rsm'>30</max></set> </list>"; } }; iq.settype(iq.type.get); iq.setpacketid("987654321"); xmppconnection.sendpacket(iq); it worked fine , received response. <iq id="987654321" to="admin@customopenfire.com/smack" type="result&quo

javascript - When mouseleave inside the slideffect time the text stays -

my intention when hover on #portfolioitem1 div text slides , when leave text goes away again. code works if hover on div , move away instantly(eg 0.3 sec) when slidedown effect working. then text not go away , stays there. , have hover on again , remove mous after 0.3 seconds work. anyone idea? javascript $('#text').hide(); $('#portfolioitem1').hover(function (){ $(this).css('background-color', '#e95850'); $('#text').slidedown(300); }); $('#portfolioitem1').mouseleave(function (){ $(this).css('background-color', '#999999'); $('#text').hide(); }); html <div id="portfolioitem1"><div id="text">vgregvre</div></div> try this: $('#text').hide(); $('#portfolioitem1') .hover(function() { $(this).css('background-color', '#e95850'); $('#text').slidedown(300); }, function() { $(this

javascript - How to get Google results into our webpage without SAME ORIGIN POLICY -

we have own form in our webpage. want show google( www.google.com/scholar ) results our webpage. tried jquery, ajax html framing (iframe, frameset) and of these have sameorigin issues. we tried using new tab , found has same problem here . these solutions seem work http://www.google.com/custom , no other google websites. is there alternative so? google prevents doing this. set server side code scrape results blocked google. if suits needs can create form submits search page , opens in new tab so: <form action="http://scholar.google.co.uk/scholar" method="get" target="_blank"> <input type="text" name="q"> <input type="submit" value="search"> </form> live example here: http://jsfiddle.net/v8qg8/ update: i mentioned google block scraping of services, found third party library that. not sure on google's opinion on though. http://www.icir.org/christian/sc

javascript - If I type "hello" into a text box, how can I make an alert appear by pressing a button? -

i create code make when type "hello" text box can press button below , alert pop-up appear. want add more of these different words well. should add code make work? <!doctype html> <html> <head> <title>thisthat</title> <style> body { background-color: #333333; } .input, .output { border: 0; padding: 8px; font-size: 14px; } .output { background-color: #ff0000; } p { font-size: 18px; } </style> </head> <body> <center><h3>thisthat</h3></center> <center><p> if </p></center> <center><input placeholder="this..." class="input"></center> <center><p>then</p></center> <center><button class="output">that...</button></center> </body> </html> yes, javascript. there great online resources learning h

javascript - Canvas: Draw Lines on top of Filled Rectangle -

i have function here that's supposed draw square , plus sign in middle, reverse colors if mouse on it. works fine if mouse not on top, once filled, plus sign disappears. assume it's being covered up. function drawadd(cx, cy, btnw, btnh, mouse) { var getid = document.getelementbyid("canvas_1"); var color = "black"; var px = cx + btnw/2; var py = cy + btnh/2; if (getid.getcontext) { var ctx = getid.getcontext("2d"); ctx.clearrect(cx, cy, btnw, btnh); ctx.linewidth = "10"; ctx.fillstyle = "black"; if(mouse) { ctx.fillrect(cx, cy, btnw, btnh); color = "white"; } else { ctx.strokerect(cx, cy, btnw, btnh); } ctx.beginpath(); ctx.linewidth = "20"; ctx.fillstyle = color; ctx.moveto(px - 40, py); ctx.lineto(px + 40, py); ct

Matlab onCleanup function not executed -

i ran following issue in matlab r2013a, reason not understand not call oncleanup function when in function timer (including timerfcn) defined. i add 2 minimal examples showing problem: first working version cleanup routine called expected: function mytest(time) t = timer(); myclean = oncleanup(@() disp('function ended')); pause(time); end and buggy version in cleanup not called (neither when function ends or when ctrl+c pressed) function mytest2(time) t = timer(); t.timerfcn = @(o,s)disp(' ... waiting time'); myclean = oncleanup(@() disp('function ends')); pause(time); end i not find hints in documentation why timer or more specific definition of timerfcn change execution of cleanup code? ouch - nasty. it's not bug, it's not you'd expect documentation, , it's not you'd want. fortunately it's pretty easy work around. firstly, what's happening? well, oncleanup returns oncleanup object. objec

php - Magento Sitemap Causing Error -

all sudden in admin side when go submit sitemap shows white screen. here's error logs show. php fatal error: call member function getid() on non-object in /home/investor/public_html/yourvaporizers.com/app/code/core/mage/adminhtml/controllers/sitemapcontroller.php on line 99 php fatal error: call member function getcollection() on non-object in /home/investor/public_html/yourvaporizers.com/includes/src/mage_adminhtml_block_sitemap_grid.php on line 47 not coder have no clue how fix this. update - should of added whole error code. stack trace: 0 /home/investor/public_html/yourvaporizers.com/includes/src/__default.php(63823): pdostatement->execute(array) 1 /home/investor/public_html/yourvaporizers.com/includes/src/varien_db_statement_pdo_mysql.php (110): zend_db_statement_pdo->_execute(array) 2 /home/investor/public_html/yourvaporizers.com/includes/src/__default.php(63411): varien_db_statement_pdo_mysql->_execute(array) 3 /home/investor/public_html/yourva

sql - combining two stored procedure to one stored procedure getting error -

i have stored procedure this: alter procedure [dbo].[ibs_podiumsummerycount] @locid integer = null begin set nocount on; select sum(status_receved) receved, sum(status_parked) parked, sum(status_requested) requested, sum(status_requestedinprocess) requestinprocess (select case when (status = 0 ) 1 else 0 end status_receved, case when (status = 2) 1 else 0 end status_parked, case when (status = 3) 1 else 0 end status_requested, case when (status = 4) 1 else 0 end status_requestedinprocess transaction_tbl locid = @locid , dtime >= getdate()-1 , status in (0,2,3,4)) a; select l1.starttime, convert(varchar, getdate(), 108) time location_tbl l1 l1.locid = @locid end i have 1 more stored procedure this: select dbo.podiumsummerytime( convert(decimal(10,1), avg(c

regex - Ruby regular expression groups -

i trying match strings might represent ranges somewhere in document can't quite figure out 1 thing groups... have far: /(^-?[0-9]+)(\.\.+)(-?[0-9]+$)/ which matches 1..10, -20...20, -01234567890...-999999999, etc. however, want second group ($2) have value if middle 3 digits instead of two. want like: =~ -01234567890...-999999999 $1 = -01234567890 $2 = ... $3 = -999999999 =~ 1..10 $1 = 1 $2 = (empty because 2 dots instead of 3) $3 = 10 any way specify this, make group if it's value? you can use: (^-?[0-9]+)(?:(?:[.]{,2})|([.]{,3}))(-?[0-9]+$) which put result in second group if 3 . . explanation: ?: - non-capturing group. | - or note (?:[.]{,2}) non-capturing while ([.]{,3}) capture group.

Maven repository: connection timeout -

it became unable download artifact http://repo.aduno-software.com repository (connection timed out). issues lasts couple weeks. is there substitution repo , may knows whom complain server's out of service condition ? i've tried out lots of different maven repositories can not cover project's dependencies while mentioned 1 does. note this work around kind of hacky , might work if data available other repos. here came (maven docs explains of these settings): 1. find settings xml under maven directory. on windows, in there under conf\settings.xml 2. add mirrors settings file: <mirrors> <!-- mirror | specifies repository mirror site use instead of given repository. repository | mirror serves has id matches mirrorof element of mirror. ids used | inheritance , direct lookup purposes, , must unique across set of mirrors. | <mirror> <id>mirrorid</id> <mirrorof>repositoryid</mirrorof> <name>human read

How I can register a provider for the custom XMPP IQs with aSmack on Android -

anyone can me say, or how register provider custom iq, using asmack on android, people talk register provider, don't know how that. me about, this. can send , receive simple packet, it's work fine, problem when have send custom iq packet have subpackets. just register provider in smack. process described here: http://www.igniterealtime.org/builds/smack/docs/latest/documentation/providers.html

angular ui - AngularJS nested views -

hi there don't know how show example navbar , real content route. stateprovider looks this: .state('panel', { abstract: true, views: { // child views defined here (absolutely named) 'navbar': { templateurl: 'packages/admin/app/partials/panel/navbar.html' } } }) .state('panel.dashboard', { url: '/dashboard', templateurl: 'packages/admin/app/partials/panel/index.html', controller: 'adminctrl' }); my main html file looks this: <body> <div ui-view="navbar"></div> <div class="container"> <div ui-view></div> </div> <!-- /container --> </body> and after going route /dashboard see navbar.html content generated in *ui-view="navbar" don't see index.html' main ui-view . how manage ? i'm not sure why you're trying

javascript - Django class-based views with ajax? -

i'm trying make dialog when user clicks button, keep getting error. code have. for note, i'm using django-braces catch ajax calls. view: class userregistration(braces.ajaxresponsemixin, createview): form_class = userregistrationform template_name = "registration_form.html" def get_ajax(self, request, *args, **kwargs): context = self.get_context_data(**kwargs) rendered = render_to_string(self.template_name, context_instance=context) return httpresponse(rendered) javascript: $("#signup").on("click", function(){ $("body").append("<div id='dialog' title='register'></div>"); $( "#dialog" ).dialog({ height: 'auto', width: 'auto', modal: true, autoopen: false }); $.ajax({ url: '/signup/', data: {}, type: 'get', success: function(data){

java - not able to connect through socket -

i trying connect 2 computers using socket connection. tried code on same computer entering own ip address. works. it's not working in between 2 computer @ home. similar code did worked on college computers. server side code import java.io.ioexception; import java.net.serversocket; import java.net.socket; public class testserver { public static void main(string[] args) { serversocket listener = null; try { listener = new serversocket(7689); socket other = listener.accept(); system.out.println("connected"); } catch (ioexception e) { e.printstacktrace(); } } } this client side code import java.io.ioexception; import java.net.socket; import java.net.unknownhostexception; import java.util.scanner; public class testclient { public static void main(string[] args) { scanner sc = ne

code generation - Is there a F# type provider for DacPac file -

i wonder if there f# generative type provider can bound dacpac file behave dbmlfile type provider except visual studio database project output. what trying achieve use f# type providers dal code generation tool c# project. guess can achieve syncing dacpac database , using sqldataconnection type provider achieve same result great if need database eliminated.

javascript - Get the length of an element inside of an array -

i trying find length of elements inside of array. var test = ["hi", "bye"]; how can length of test[0] ( "hi" ) or test[1] ( "bye" )? in main code, have stored value inside array. value has been stored "svars alternativ_4" in array[0]. tried length doing array[0].length giving me wrong length. giving me 20 , if remove value same.. why? like this: test[0].length //for "hi" test[1].length //for "bye"

java - android sqlite delete database in package -

i used following code string destdir = "/data/data/" + getpackagename() + "/databases/"; string destpath = destdir + "jobs"; file f = new file(destpath); if (!f.exists()) { //---make sure directory exists--- file directory = new file(destdir); directory.mkdirs(); //---copy db assets folder // databases folder--- try { copydb(getbasecontext().getassets().open("jobs"), new fileoutputstream(destpath)); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } public void copydb(inputstream inputstream, outputstream outputstream) throws ioexception { //---copy 1k bytes @ time--- byte[] buffer = new byte[1024]; int length; while ((length = inputstream.read(buffer)) > 0) { outputstream.write(buffer, 0, length);

vb.net - Graphic Tic Tac Toe in Visual Basic -

Image
i'm working on program visual basic class supposed create game of tic-tac-toe played 1 human , computer. here instructions: create 2 views (one gui view , other text view using console). use 2 controllers (one user clicks on gui , other user uses numbers 1-9 on keyboard. use 1 model. use module keep state of game in 2d array. logic applied model in module (for example, module allowed change 2d array). the grid drawn graphically (not using labels, buttons, etc) here of questions i'm having far: i know how create gui view, have no idea how use console create text view? not quite sure how 2d array supposed work in situation (i've declared follows, not sure go there). module module1 dim game(2, 2) string end module i've drawn part of grid, having trouble doing rest. need 1 more vertical line , 1 more horizontal line, , needs divided correctly. here's have drawing far: private sub form1_paint(byval sender object, byval e system.windows.forms.

sorting - Sort python list based on length, and then based on content -

i need sort list based on element's length, , based on contents. example, input [[1,2,3,4],[1,2,3],[2,3,4]] , need [[1,2,3,4],[2,3,4],[1,2,3]] : [1,2,3,4] has largest elements, , [2,3,4] bigger [1,2,3] in first element. input [[2,3,5],[1,2,3],[2,3,4]] , [[2,3,5],[2,3,4],[1,2,3]] should returned comparing element element when length of element same. i sort list length of element, how can resort after that? >>> = [[1,2,3,4],[1,2,3],[2,3,4]] >>> sorted(a, key=len, reverse=true) [[1, 2, 3, 4], [1, 2, 3], [2, 3, 4]] don't. sort once. key=lambda a: (-len(a), a)

mysql - PHP File Upload not working with $_FILES variable it is always undefined -

ok have page user uploads file looks this: upload.php: <form enctype="multipart/form-data" action="upload_file.php" method="post"> choose file upload: <input name="uploaded" type="file" /><br /> <input type="submit" value="upload file" /> </form> upload_file.php: <?php $target = "upload/"; $target = $target . basename( $_files['uploaded']['name']) ; $ok=1; $uploaded_type= $_files['uploaded']['type']; $uploaded_size= $_files['uploaded']['size']; //this our size condition if ($uploaded_size > 350000) { echo "your file large.<br>"; $ok=0; } //this our limit file type condition if ($uploaded_type =="text/php") { echo "no php files<br>"; $ok=0; } //here check $ok not set 0 error if ($ok=

regular language - Finding the DFA -

create dfa such l subscript 4 = {0,1}* - {0,01}* , list first 5 strings in lexicographic order. i'm having trouble deducing l subscript 4 implies, language of strings length 4? also, when subtract 2 languages, choose string "1" subtracted empty string, meaning can choose first {0,1}* of length 1 subtracted {0,01}* of length 0? the language {0,01}* set of strings before each 1 there should 1 0. example 00010001 in language 10000 or 0001111 not. {0,1}* on other hand, strings alphabet {0,1}. subtracting these results language @ least has 1 one , 1's come before 0. example 1111000 in l_4 000000 or 011111 not.

ruby on rails - Do I need to restart NginX after reconfigure for passenger to work -

i updated nginx configuration. in config i've added new server different environment rails application. i've reloaded configuration ( sbin/nginx -s reload ) , deployed application right folder nothing seems happen, nginx throws 404 not found.. is there more need do? do need restart nginx or passenger example? turns out don't need restart. passenger isn't able restart (as far i've found out) , nginx needs reload.

ios - Core Data Not Saving To Table View -

Image
so first time working core data, , far hasn't been best experience. application far consists of 2 uitableview controllers , single viewcontroller. app asks user enter name of list on uialert , saves core data, , name of list put first tableview. user clicks on name of list , pushes them contents on list, empty because hasn't been populated yet. user populates tableview, pushes single view controller enter info , hit save. problem doesn't save when hit save, goes last uitableview controller , nothing there. thats first problem, second pass data between views when user clicks on list pushes second uitableview controller , says name of list @ top. i'm getting confused core data stuff , relationships if me out appreciate it. i'll include code , data model. data model first views .m (view lists lists) - (nsmanagedobjectcontext *)managedobjectcontext { nsmanagedobjectcontext *context = nil; id delegate = [[uiapplication sharedapplication] delegate];