Posts

Showing posts from February, 2010

ruby - Rails calling Models in the Migration -

i have migration creates table, , need access model table create table. migration seems not recognized original table has been created, make sure put debugger in code , when model call, says user(table doesn't exist) though in mysql see being created. looks migrations can't see current state of database, ideas how around that? just more specific question: i'm trying use archivist create archive of current user table have class archivedheuristicreviewstable < activerecord::migration def self.up create_table "users" |t| t.string "name" ... end debugger archivist.update user end def self.down drop_table :users drop_table :archived_users end end the archivist, doesn't create archived_user table, when stopped @ debugger , did user, got user(table doesn't exist) . i tried archivist call in newer migration, make sure user creation done, still didn't recognize user table. any ideas?

metadata - "Metaaccess" of Objects in Java With Variables in the Identifiers -

i want access number of objects in java without write lot of code, example: int x; for(x=0;x<5;x++){ jlabelx = /*do something*/ } would this: when x=0 jlabel0 access, x=1 jlabel1 , on... is there way of doing this? or need specify cases the best way of doing not have variables called jlabel0 , jlabel1 etc in first place. instead, have array variable (or other collection): jlabel[] labels = new jlabel[5]; (int = 0; < labels.length; i++) { labels[i] = new jlabel(); // whatever you can @ fields reflection, time see variables x0 , x1 , x2 etc shudder - it's clear indication collection of kind better fit.

sql - return value of stored procedure based on different rules -

Image
i writing stored procedure values based on following tables. i filling apartment flats according nationality of buyers. the stored procedure has return next non-occupied flat based on following rules: if new entry comes, need suggest non-occupied flat next occupied-flat having same nationality of new person if no match found above condition, allocate first flat in floor no flats occupied if no match found above condition, allocate flat having at-least 2 empty flats on both sides if no match found above condition, allocate first flat empty according sort order note: each flat identified combination of floor & flat no sort order flat , floors while searching should 1 n sample input: name: randy nationality: brazil sample output : floor:1 flat no: 4 (w.r.t. attached image) the key create columns each of criteria, i.e. 1 column if next door flat owner has same nationality, column if floor empty. you can take criteria , place them wit

php - Parse Json string to Html elements -

this question has answer here: parse json in javascript? [duplicate] 16 answers access / process (nested) objects, arrays or json 15 answers i have json string : [{"row_id":"1","name":"amoghengineers","category":"dress","subcategory":"jeans","district":"7","location":"india","plan":"gold","productorservice":"product","email":"mymail@gmail.com","about":"goodone","phone":"98675433","registration_confirmed":"yes"}] . and need parse these data html field elements ,for eg: want set name input field $("#businessname").val(name) . how c

c++ - Iterating over list of structs -

i'm creating list of structs: struct task{ int task_id; bool is_done; char* buffer; int length; } task; list<task> tasklist; and trying iterate on tasks in order check is_done status: (std::list<task>::const_iterator iterator = tasklist.begin(), end = tasklist.end(); iterator != end; ++iterator) { if(iterator->is_done) { return 1; } else { return 2; } } where wrong? get: missing template argument before '->' token the iterator's operator-> dereferencing already. instead of if(*iterator->is_done==true) you need if(iterator->is_done==true) is equivalent to if((*iterator).is_done==true) which sidenote equivalent easier read if((*iterator).is_done) or if(iterator->is_done) . better, use std::any_of : #include <algorithm> .... if (any_of(begin(tasklist), end(tasklist), [](task const &t) { return t.is_done; })) {

.net - Resource management in decoupled applications -

i'm building decoupled application using unity, prism. problem worry resource management in services. easier explain in example: imagine w have interface idataretriever provides sort of data. implementation registered instance. implementation of interface based on anything: files (filedataretriever), sql server (sqlserverdataretriever), simple dictionary. concrete implementation use configured (possibly via configuration file, doesn't matter). once application finished working, depending on service implementation should release resources (e.g. close connections, close files etc) or not (e.g. when using dictionary), work decoupled abstractions don't know both things: 1. when resources should released 2. whether concrete implementation needs resource deallocation or not. i think of scenario when bootstrapper implement idisposable, , check each service idisposable implementation, , call dispose modules (which mean modules have implement idisposable well) doesn't

java - @PreDestroy method of a Spring singleton bean not called -

i have spring bean defined in beans.xml follows: <context:annotation-config /> [...] <bean id="mybackend" class="mycompany.backendbean" scope="singleton" /> inside bean 2 methods, must executed @ start , before termination of web application: public class backendbean implements ibackend { private static final logger logger = loggerfactory .getlogger(backendbean.class); @postconstruct public void init() { logger.debug("init"); } @predestroy public void destroy() { logger.debug("destroy"); } } when run server ( mvn jetty:run ), can see output of init method in console, conclude init method executed. when press ctrl-c , jetty starts shut down, don't see output of destroy method. what should change in order destroy method executed, when application terminated? for spring call @predestroy callback method when application shuts do

selenium - Javascript get the value from an h4 Tag -

i trying value lotus of h4 tag code below <a id="linksale" class="linkaccess" title="" href="/vp4/home/handlers/operationaccess.ashx?operationid=17285" onclick="javascript:prepareeventonlinksanchor(17285);"> <h4>lotus</h4> <p class="datesales">du <em><strong>mercredi&nbsp;1 mai</strong>&nbsp;9h</em> au <em><strong>dimanche&nbsp;5 mai</strong>&nbsp;6h</em> </p> <p class="baseline"></p> </a> to did follow : var h=document.getelementbyid("17285"); var i=h.getelementsbytagname("h4"); which returned following line : <h4>lotus</h4> what want value lotus converted text. document.getelementbyid("linksale").getelementsbytagname("h4")[0].innerhtml will work

java - Disposing Graphics2D drawing after it is drawn -

for game i'm working on need draw rectangle gets smaller , smaller. have figured out how draw rectangle smaller using swing timer this: timer = new timer(100, new actionlistener(){ public void actionperformed(actionevent e){ graphics2d g2d = (graphics2d) panel.getgraphics(); if(width > 64){ g2d.drawrect(x,y,width,height); x += 1; y += 1; width -= 1; height -= 1; } } }); timer.start(); the problem having wont remove rectangle drawn before wont it's shrinking more it's filling in. how remove drawn rectangle right after smaller rectangle have been drawn? you might start with:- change: graphics2d g2d = (graphics2d) panel.getgraphics(); to: repaint(); the graphics instance getgraphics() transient, window might repainted whenever jvm feels necessary. the overridden method might this. @override

java - No value specified for parameter 1 -

i using hiberante connect postgres database. trying insert record database. have values record in string array got csv file. dao code stringbuffer query=new stringbuffer("insert t_wonlist values("); for(int i=0;i<67;i++){ query.append(values[i]+","); } query.deletecharat(query.lastindexof(",")); query.append(");"); sessionfactory.getcurrentsession().createsqlquery(query.tostring()).executeupdate(); system.out.println("query executed"); sessionfactory.getcurrentsession().flush(); i using stringbuffer, can append values query using loop. but when execute query getting following exception org.postgresql.util.psqlexception: no value specified parameter 1. i sure number of parameters correct. can me. thanks you're approaching in bizarre , backwards manner. the immediate problem failure escape/quote ? in 1 of input strings, pgjdbc thinks i

exception - Java application randomly errors with: java.util.ConcurrentModificationException -

this question has answer here: can explain me on concurrentmodificationexception? 1 answer so i'm trying create simple gravity using lwjgl, application randomly crashes java.util.concurrentmodificationexception exception. strange thing is not happen @ same time. crashes instantly other times runs fine 10 minutes before crashing. main game class: public static arraylist<block> blocks; public game() { blocks = new arraylist<block>(); for(int = 0; < 40; i++) blocks.add(new blocktest(i, 21, new float[] {0.4f, 0.6f, 0.7f}, false, 0)); spawntimer.scheduleatfixedrate(new timertask() { public void run() { spawnblock(); } }, 1000, 1000); } public void update() { for(block b : blocks) b.update(); } block class: /** update block */ public void update() { if(hasgravity) {

PHP error handling with .htaccess & writing into php_error.log text file -

for php error handling aim of "only admin sees warnings, errors etc."; i applied steps below: i deleted error_reporting(-1); command index.php i added rows below .htaccess under public_html folder i created error_modes folder in public_html folder i created .htaccess file in error_modes folder i set permissions of error_modes folder 777 , writable. intentionally, wrote <?php 'should see error in log file' ?> in footer.inc.php page. please note didn't wrote ; character @ end. despite intentional php syntax error in footer.inc.php page, no php_error.log file created! and saw should see error in log file string printed in footer.inc.php page. php worked despite syntax error !? i added whole .htaccess code below. (this 1 under public_html ) fyi : don't have access php.ini , don't have pre-set .log file. php version 5.4. can please correct me? thanks. best regards. added commands public_html > .htaccess e

MySQL: INNER JOIN vs. separate queries in case of fixed amount of entries in one of the tables -

here question. option 1: select b.some_field inner join b on a.id = b.a_id ((a.field1 = '1' , a.field2 = '2') or (a.field1 = '2' , a.field2 = '1')) option 2: $id1 = select id a.field1 = '1' , a.field2 = '2' $id2 = select id a.field1 = '2' , a.field2 = '1' select b.some_field b b.a_id = '$id1' or b.a_id = '$id2' this of course pseudo code, $id1 , $id2 should contain values of a.id of corresponding rows. which on has better performance? the reason i'm asking know there 2 rows in fit condition, i'm afraid joining tables result in overhead of mysql going on huge table consist of each row in each row in b. way inner join behaves? i'll more specific: in case primary key of (field1, field2). mysql smart enough conclude where ((a.field1 = '1' , a.field2 = '2') or (a.field1 = '2' , a.field2 = '1')) won't yield more 2 rows first extract th

android - show alertdialog box for disabling gps when stop using the app -

i have application uses gps , in activity user takes action ,when pressing "get location" button ,it appears alertdialog , there user enables gps. but, when exit app or when exit activity want able disable app. i read must override onpause method nothing happens when press arrow or when press home button. gpstracker gps; protected locationmanager locationmanager; boolean isgpsenabled = true; boolean isnetworkenabled = true; @override public void onpause() { super.onpause(); gps = new gpstracker(mainactivity.this); try{ locationmanager = (locationmanager) .getsystemservice(location_service); // getting gps status isgpsenabled = locationmanager .isproviderenabled(locationmanager.gps_provider); // getting network status isnetworkenabled = locationmanager .isproviderenabled(locationmanager.network_provider); if (isgpsenabled && isnetworkenabled) { gps.showsettingsalertdisable();

java - Plot Experimental Data Distribution -

i'm working on clustering task , i've built dataset similarity matrix m, repeating n times clustering algorithm , chosing element m_{ij} the number of times elements , j have been on same cluster, divided n. now i'd have graphical way check results, wondering if there library that, given array of doubles ( aka values in upper triangular part of matrix ), plots data distribution , histogram ? doubles in [0,1] interval, , of around 0 , 1 . for plotting, best programming language know matlab . if have chance, suggest matlab . write results txt file , insert matlab, can play numbers , plottings no effort

if statement - Excel nesting error -

another question! i'm using excel 2013 , have had create if statement chooses students grade depending on mark number (obviously nesting needed) here if statement created =if(e2<=20,"n", if(or(e2>=21,e2<=25),4, if(or(e2>=26,e2<=32),"5c", if(or(e2>=33,e2<=38),"5b", if(or(e2>=39, e2<=44), "5a", if(or(e2>=45, e2<=53), "6c", if(or(e2>=54, e2<=61), "6b", if(or(e2>=62, e2<=71), "6a", if(or(e2>=72, e2<=87), "7c", if(or(e2>=88, e2<=103), "7b", if(or(e2>=104, e2<=120), "7a"))))))))))) the error recieve "the specified formula cannot entered because uses more levels of nesting allowed in current file format" question is, how shorte

numpy - Something wrong with my fft() in python -

i have function supposed plot amplitude spectrum of between 10mhz , 11.4mhz. function: cos(6.72*(10**7*t) + 3.2*sin(5*(10**5*t))) know plot supposed like, mine wrong. i'm pretty sure it's programming error, not math/theory error because i'm doing matlab example showing, feel python doing i'm not understanding. i'm supposed sample function 8192 times @ 10ns apart, multiply hamming window, , plot amplitude spectrum in db between 10mhz , 11.4mhz. carrier (10.7mhz) should around 55 db. second pair of sidebands greatest amplitude @ 60 db. then, fifth pair of sidebands 20 db point, around 40 db. can spot wrong code explains why mine doesn't show this? import numpy import scipy import scipy.fftpack import matplotlib import matplotlib.pyplot plt scipy import pi import pylab pylab import * import cmath import sys sys.setrecursionlimit(10000) samples = 8192 #defining test function t = scipy.linspace(0.01, 32/390625, samples, false) #sample samples times

javascript - Last callback not being called using async -

i cannot seem last callback (commented "optional callback") called send result browser. pointers doing wrong? using following modules: async, restify , postgresql node.js console.log('start'); var async = require('async'); var restify = require('restify'); var server = restify.createserver(); server.use(restify.bodyparser()); server.get('/user/creationdate/:username', function(req, res, next) { var username = req.params.username; var record; async.parallel([ function(callback){ getuserbyname(username, function(err, user) { if (err) return callback(err); record = user; }); } ], // optional callback function(err){ console.log('5. following record has been retrieved:' + record); res.send(record); }); next(); }); server.listen(8080, function () { console.log('%s listening @ %s', server.na

html - Same height divs? -

i have following: <div class="container"> <div class="sectiona"> </div> <div class="sectionb"> </div> </div> section has red background, section b has blue background. section has lots of text in it, making quite tall, section b not have text in it. how can make section , b same height parent? yes, can give childs same heights parent. work: <html> <head> </head> <body> <div class="container"> <div class="sectiona">lorem ipsum dolor sit amet. </div> <div class="sectionb">lorem ipsum dolor sit amet. </div> </div> </body> </html> the css: .container{height:200px;width:500px;overflow:hidden} .sectiona{position:relative;float:left;width:250px;background:blue;height:100%} .sectionb{position:relative;float:left;width:250px;background:red;height:100%}

Customize .NET Portable Class Library Profiles? -

i need add and/or modify profiles allow more classes , members shared in pcl (many of them built-in in framework, such thread.sleep). what's best way this? there tools that? ps: i'm not seeking anwser tell me no or stop. want have compile-once dlls may shared in different environment. no per-platform binary, no recompile, no ifdef. following got far: requirement: target environements: silverlight 5 , .net framework 4.5. purpose of pcls: shared infrastructure ria client , asp.net server (without wcf) what's lacking in default profiles: xpath, thread methods, dynamicmethod/ilgenerator pcl profiles: under reference assemblies\microsoft\framework.netportable : all assemblies stubs, "retargetable" attribute set. all assemblies have flags = 0x171: 0x001 signed, 0x100 retargetable, , 0x070 undefined in assemblynameflags (appears have no effect) all references between assemblies "retargetable" attribute well. all assemblies silverlig

x86 - Assembly, registers and return values -m32 / linux -

i'm trying make simple codes in assembly can understand more. start want make function takes parameter. i want add value parameter, example letter 'a', (has value 65 in ascii). want function return a, since eax holds 4 bytes , letter needs 1 byte, i'm trying use al part of eax register. the problem here function doesn't work when use it. 4 strange-looking characters return value. knows why? this how code looks like: .globl letterprinter # name: letterprinter # synopsis: prints character 'a' (or @ least, supposed to) # c-signature: int letterprinter(unsigned char *res); # registers: %edx: argument supposed value # %eax: return value(s) # letterprinter: # letterprinter pushl %ebp # start of movl %esp, %ebp # function movl 8(%ebp), %edx # first argument movl $65, %dl # value 

c - Plotting a segmented line with segments coloured based on a variable -

Image
i'm trying draw plot (in r or gnuplot) x axis represent single sample , y axis segmented represented different portions of time. each line segment (or box) coloured depending on third variable (yes, no, or unknown) sampleid y1 y1(answer) y2 y2(answer) y3 y3(answer) sample 1 0-50 yes 51-60 no 61-85 yes sample 2 0-40 yes 41-60 no 61-86 no sample 3 0-45 unknown 46-69 yes 70-85 unknown where colour yes=green, no=red; , unknown=grey can suggest solution? keep running in same problem, assigning colour based on third variable segment causes difficulty. some other forum users seem running in same problem yet haven't seen easy workaround. suggest doing multiple plots , overlaying them. wonder if there way of rethinking problem, or reformatting data might help? i'm not sure mean, best guess. (actually guess want flip x , y axes, should give start.) data: dd <- read.ta

multithreading - Order of TForm creation and destruction and threads -

i have thread calls functions of form update form. when task done, thread updates form results, using synchronize , works fine while program running. the problem happens when thread running , close program got access violation. caused thread updating form released. after rearranging order of form creation (calls application->createform ) worked fine because form holds thread code created before form updated. seems order of destruction reverse creation order. i added code in form destructor make sure thread terminated if form destroyed before form thread code. rearranging form creation order and/or code in form destructor solves problem. but have 3 questions: what order in created forms destroyed? reverse of creation order assume now? is there better way above task - update form gui items after thread done processing data. right thread using synchronize experienced threads may have better idea. 1 other idea had remove bunch of createform generated compiler , create t

ios - In app purchase, ID products -

i'm working on in-app purchases, if found tutorial , have question. in tutorial, buy button associate method : - (void)buybuttontapped:(id)sender { uibutton *buybutton = (uibutton *)sender; skproduct *product = _products[buybutton.tag]; nslog(@"buying %@...", product.productidentifier); [[rageiaphelper sharedinstance] buyproduct:product]; } but in app, don't want use table views show products; have create uibuttons customs images. i try code : -(void)buypackage1 { skproduct * productpackage1; nsstring * productid = @"com.razeware.inapprage.drummerrage"; //id of tutorial productpackage1.productidentifier = productid; [[rageiaphelper sharedinstance] buyproduct:productpackage1]; } but gives me : "assignment readonly property" and also, method create in-app purchase ? mean, taking code (from tutorial) , adapt interface contain uibuttons , not table view ? see, "assignment readonly property" indeed, `skproduct

Password - uppercase characters JavaScript -

excuse if stupid question. i'm doing web design subject @ uni , stuck. have validate password using javascript ensure has , uppsercase, lowercase, numerical character, , @ least 4 characters. this code have, it's giving me alerts haven't included characters, when have included them i'm still getting alert. appreciated. var y = document.forms["logindetails"]["password"].value; if (y.length < 4) { alert("your password needs minimum of 4 characters") } if (y.search[/a-z/i] < 1) { alert("your password needs lower case letter") } if (y.search[/a-z/i] < 1) { alert("your password needs uppser case letter") } if (y.search[/0-9/] < 1) { alert("your password needs number") return false; } your code had several errors comparision should <0 not <1 ( search returns negative value when regexp not found) /i in regexp (case insensitive - not appropriate when trying

html - Add a full width image above a Bootstrap navbar -

i trying insert image above navbar, not working me. here html: <div class="wrapper" /> <div class="navbar"> <div class="navbar-inner"> <div class="container"> <ul class="nav"> <li class="active"> <a class="brand" href="#">home</a> </li> <li><a href="#">about</a></li> <li><a href="#">portfolio</a></li> <li><a href="#">contact</a></li> </ul> </div> </div> </div> and css: .wrapper { background-image: url(../assets/bridge.jpg); background-repeat: no-repeat; background-size: 100% 100%; width: 100%; height: 250px; } anytime add div or content, pushed top of page. can add padding, when start resize screen breaks

ruby - undefined method when calling a method in a model of Rails -

i keep getting undefined method when call method model. class user < activerecord::base def update! request_info end def request_info return "hmmm" end end request_info inside of update! not defined i've tried making self.request_info doesn't work either there 2 ways call method in rails. class foo def self.bar puts 'class method' end def baz puts 'instance method' end end foo.bar # => "class method" foo.baz # => nomethoderror: undefined method ‘baz’ foo:class foo.new.baz # => instance method foo.new.bar # => nomethoderror: undefined method ‘bar’ #<foo:0x1e820> are doing same? have taken example here . take @ page details.

mobile - Is there a similar class as Rectangle in java me? -

so started programming mobile applications , when wanted use rectangle class couldn't it? should use instead of class? need because need use intersects , intersection methods. you "borrow" code java.awt.rectangle

php - How to check this form properly filled out in an easier way? -

i have questionnaire of 1 question offers 5 answer options. user may tick three, , give 3 rating. avoid misunderstanding, here html code: <table> <tr> <td><input type="checkbox" name="option_1"> option 1 (to determined)</td> <td> <select name=""> <option value="">as:</option> <option value="3">1st</option> <option value="2">2nd</option> <option value="1">3rd</option> </select> </td> </tr> <tr> <td><input type="checkbox" name="option_2"> option 2 (to determined)</td> <td> <select name=""> <option value="">as:</option> <option value=&quo

angularjs - Using grunt to concatenate all vendor javascript files? -

i'm using yeoman (v1.x) grunt (v0.4.2) build angular project. build task concatenates app/script js files, leaves of dependency files unconcatenated, built index.html makes these calls: <script src="components/angular-unstable/angular.js"></script> <script src="components/jquery/jquery.js"></script> <script src="components/angular-resource/angular-resource.js"></script> <script src="components/bootstrap/js/bootstrap-dropdown.js"></script> <script src="components/moment/moment.js"></script> <script src="components/underscore/underscore.js"></script> <!-- xxxxxbuild:js scripts/scripts.js --> <script src="scripts/274baf7d.scripts.js"></script> i of components project uses, i.e. angular.js , jquery.js , , forth, in scripts.js . easy reconfigure gruntfile so? or not done default practical reason? yes, easy con

python - How to get the stdout and stderr for subprocess.call? -

i'm using subprocess.call , , need output stdout , stderr. how can this? notice check_output() : note not use stdout=pipe or stderr=pipe function. pipes not being read in current process, child process may block if generates enough output pipe fill os pipe buffer. my call might produce lot of output, safe way output? something work: f = file('output.txt','w') g = file('err.txt','w') p = subprocess.popen(cmd, shell=true, stdout=f, stderr=g) f.close() g.close()

objective c - Delete objects on server when app is deleted from iOS -

searching solution seems there's no delegate method fires when app being deleted. my app uploads user profile data on server (name, image) , can delete manually calling function inside app linked "delete profile" button. but if user deletes app, without deleting profile first, data on server forever , available other user's view, opposed should expected. what should best way rid of server data user deletes app? 1) make app push enabled. send "background" pushes time time, once week. run own push server - there java , python code around, other kinds too. when see token bounces, know app has been deleted. mark account stale. @ later time, if user has not done account, can either delete or mothball it. the downside approach need user's permission send remote notifications. 2) require user re-log account once every 3 months. if don't log in, can above - mark, mothball, delete.

Managed C++ dll in C#: Can only reference parameterless constructors -

i'm trying import 3rd party dll linked managed c++ c# in vs2010. far understand should possible. dll loads fine through add reference, cannot access in namespace though content of entire dll visible in object browser there exception, though: if make classes public in dll (i have source code), can access classes' parameterless constructors, that's it. i've tried sorts of solutions, including enclosing in extern "c++" doesn't bit of difference. what doing wrong? note c++ project not have dllmain file. the classes declared in c++ project: #ifndef _point_h #define _point_h ***usings*** namespace ns { public class __declspec(dllexport) point { private: double* pstart_; int n_; public : point() : pstart_(0), n_(0) {} point(double x, double y) : pstart_(new double[2]), n_(2) { pstart_[0] = x; pstart_[1] = y; } methods etc... } }

error with using jQuery-Mobile-Listview-Pagination-Plugin -

error using jquery-mobile-listview-pagination-plugin i used jquery-mobile-listview-pagination-plugin , had error in js referenceerror: _getajaxcall not defined [break on error] var ajaxcallback = _getajaxcall(); my index.html code : <html> <head> <title>makanak</title> <meta charset="utf-8"/> <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum- scale=1.0 width=device-width, user-scalable=no'/> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile- 1.3.1.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> <script type="text/javascript" src="jquery.mobile.listomatic.js"></script> <script> $(document).on("pageinit&quo

vb.net - changing the way of coding so that MS Excel is not to be needed to installed on server in asp.net -

i have started deveop website using asp.net. i need fetch data excel display client. i hosting site on somee.com can freely host it. but on server of somee.com excel not installed. i have written code website display data from excel. dim xlapp new microsoft.office.interop.excel.application() dim xlworkbook microsoft.office.interop.excel.workbook = xlapp.workbooks.open(fileuploadpath & sender.text) dim xlworksheet microsoft.office.interop.excel._worksheet = xlworkbook.sheets(sheetname) dim xlrange microsoft.office.interop.excel.range = xlworksheet.usedrange dim rowcount integer = xlrange.rows.count dim colcount integer = xlrange.columns.count dim tbl new datatable() integer = 1 rowcount tbl.rows.add() next integer = 1 colcount tbl.columns.add() next if rowcount > 1 or colcount > 1 integer = 1 rowcount j integer = 1 colcount tbl.rows(i - 1)(j - 1) = xlrange.value2(

php - Counting rows in PDO -

this function counts songs specified album using pdo. i tried looking @ what's wrong nothing. searched here , bing, nothing. function artist_count_songs($id) { global $db; $count = $db->prepare("select count(`song_id`) `songs` `album_id` = :id"); $count = $count->execute(array(':id' => $id)); echo $count; } is there i'm missing? tried rowcolumn still nothing database structure set sql_mode="no_auto_value_on_zero"; set time_zone = "+00:00"; create table if not exists `songs` ( `song_id` int(11) not null auto_increment, `album_id` int(11) not null, `name` varchar(60) collate utf8_unicode_ci not null, `download_url` varchar(1024) collate utf8_unicode_ci not null, primary key (`song_id`) ) engine=myisam default charset=utf8 collate=utf8_unicode_ci auto_increment=3 ; insert `songs` (`song_id`, `album_id`, `name`, `download_url`) values (1, 1, 'بحبك اه', 'downloads/tamerhosny

statistics - The "formula" argument in R elrm() function did not read a specific data -

there wrong argument "tryout." kept showing me "tryout" not found. wrong code? data <- data.frame(event=c(0,1), x =c(0,1), tryout <- c(100,100)) m <-elrm(event/tryout ~ x, interest = ~ x, iter = 1000, burnin = 0, data = data, r = 2) result <- m$coef any great.

GitHub: how to remove a file from git history (especially that of the GitHub repository)? -

i have github repository contains big files want permanently remove history. have cloned github has nice page can used remove such big files ( https://help.github.com/articles/remove-sensitive-data ). so, cloned github repository, followed instructions page, , sure enough size of local repository smaller. so, there, thought next force push github repository using: git push --force --all i checked sha-1 values of github repository against of local clone , match. there, thought clone 'new' github repository , check size, thinking same of original clone, but... it's! after investigation, (closed) pull requests in github repository reference of big files deleted. so, files still around. (for know, there may other things in github still refer some/all of big files.) so, what need github repository small local repository? (assuming can @ done!) i mean, whole idea wanting 'clean up' github repository people want/need clone end small clone while right it&

Bind several classes into one .dll file in C# -

a beginner's question. c#. let's have 3 classes in 1 project named employee, department, address. reason, have .dll file (let's name test.dll) have 3 classes included can call other project using syntax "test.employee emp1 = new test.employee();" idea. possible? if yes, how should that? have create class library project so? know nothing class library project. may need further that. if answer no, how add references classes other solutions? thanks. create class library project. give proper namespace write library classes, compile dll then add reference dll in other project want use in add using statement include reference in code files. pretty straightforward

vb.net - VB programmers. I have a problemas with form navigation -

i have few forms in program , have navigation well. next , buttons. have next buttons coded so: private sub nextbutton_click(byval sender system.object, byval e system.eventargs) handles nextbutton.click ' closes current screen , opens next me.visible = false form4.showdialog() end sub and buttons so: private sub backbutton_click(byval sender system.object, byval e system.eventargs) handles backbutton.click ' closes current screen , opens previous screen me.visible = false form2.showdialog() end sub as can tell form3. so. go forward fine, hit program doesnt want run. what doing wrong? when showing form using 'showdialog' in vb, have evaluate response , dismiss form. setting visible false isn't enough. see code here: http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2 you may want show form, not showdialog it, , there's samples here: http://msdn.microsoft.com/en-u

objective c - uibutton setframe not working no auto layaout enabled -

i have uibutton want change position depending on device code: [self.notification setframe:cgrectmake(12, 495, 17, 18)]; does not work @ all! no auto layout enabled. thoughts? any appreciated. the problem button moving, self.notification invisible; have set hidden yes. moving, cannot see move, because cannot see @ all. perhaps not button think is!

php - more sophisticated adding value into an array -

i wonder, there elegant way add element in array, in situation don't know beforehand, whether want create new index or use existing one? $array[$k] = $foo; // overwrites existing index, never creates 1 $array[] = $foo; // creates new one, never overwrites array_push(...); // creates new index $array[null] = $foo // sadly, null casted empty string it nice this: if($key === null) $array[] = $foo; else $array[$key] = $foo; but fit in 1 expression $array[!isset($key) || $key === null? count($array) : $key ] = $foo; update: improved isset()

android - How to enable button after using spinner -

i creating program has mainmenubutton button (created in oncreate) disabled default. user first has check few boxes , select spinner before mainmenubutton button becomes enabled. currently, can't button enable after using spinner. i've tried both @override public void onclick(view v) { switch(v.getid()) { case r.id.main_menu_button: openmainmenu(); break; case r.id.building_spinner: button mainmenubutton=(button)findviewbyid(r.id.main_menu_button); mainmenubutton.setenabled(true); break; } } and public void onitemselected(adapterview<?> parent, view view, int position, long id) { view mainmenubutton=(view)findviewbyid(r.id.main_menu_button); mainmenubutton.setenabled(true); } but no avail. i've tried replacing view button , didn't enable mainmenubutton either. supposed enable button after on spinner has been selected? also,

Deleting 3d dynamic array C++ -

i make 3d dynamic array using code //layer = 2 //levelsize.x = 100 //levelsize.y = 100 level_array = new int**[layer]; for(int = 0; < layer; ++i) { level_array[i] = new int*[(int)levelsize.x]; for(int j = 0; j < levelsize.x; ++j) level_array[i][j] = new int[(int)levelsize.y]; } but when want delete it, program crashes for(int = 0; != levelsize.x; ++i) { for(int j = 0; j != levelsize.y; ++j) { delete[] level_array[i][j]; } delete[] level_array[i]; } delete[] level_array; i don't know wrong in code of deleting array. please me check code, thanks you allocate memory array dimensions [layer][levelsize.x][levelsize.y] , while deleting operate array dimensions [levelsize.x][levelsize.y][somenting] . for(int = 0; != layer; ++i) // ^^^^^ not levelsize.x { for(int j = 0; j != levelsize.x; ++j) // ^^^^^^^^^^^ not levelsi