Posts

Showing posts from May, 2013

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - How to handle NullReferenceException in a foreach? -

foreach (string s in myfield.getchilds()) { if (s == null) //handle null else //handle normal value } when run program nullreferenceexception because getchilds may return null. how can make program continue anyway , handle exception? can't handle outside of foreach, can't explain why because take time (and sure guys busy :p). ideas? i tryed way: foreach (string s in myfield.getchilds() ?? new arraylist(1)) { if (s == null) //handle null else //handle normal value } but not work, program jump @ end of foreach want enter foreach instead! one way (though not best way) is: foreach (string s in myfield.getchilds() ?? new string[] { null }) or foreach (string s in myfield.getchilds() ?? new arraylist { null }) the reason new arraylist(1) doesn't work creates list has capacity hold 1 element, still empty. new string[] { null } creates string array single element null, appear want.

Extjs: Reuse the same grid in TabPanel -

in extjs application have grid , tabs line on it. content of grid depends on selected tab. tabs has jan-feb-mar-... values. clicking of tab reload grid's store question: possible avoid duplicating of 12 grid components in favor have 1 shared instance? thanks disclaimer: searching @ sencha's forum, google, stackoverflow not successful :( it is, require more effort worth. create prototype component, can create new instances quickly.

indexing - SQlite Index on 2 number fields? -

i have table access 2 int fields time want index help. there no writes ever. int fields not unique. what optimal index? table myinta myintb sometextvalue the queries this: select sometextvalue mytable myinta=1 , myintb=3 you add index on (myinta, myintb) . create index your_index_name on mytable (myinta, myintb); note: might preferable make pair of columns primary key if pair of columns (when considered together) contains distinct values , there isn't obvious choice primary key. for example, if table contains data this: myinta myintb 1 1 1 2 2 1 2 2 here both myinta , myintb when considered separately not unique neither of these columns individually used primary key. however, pair (myinta, myintb) is unique, pair of columns used primary key.

sharepoint 2010 - Deploying wsp from MSI installer -

i deploy sharepoint 2010 solution package (wsp) using msi (or other user friendly form of installer). i know can create custom action , deploy using sharepoint object model, don't think that's way go. what way this? there upcoming project on it, read here: http://sharepointinstaller.codeplex.com/wikipage?title=specificationv2&referringtitle=home currently, best way use msi customaction. instead of object model, use powershell script deploy wsp. cleaner code. http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/12/02/adding-and-deploying-solutions-with-powershell-in-sharepoint-2010.aspx

c# - How can I make the background color of a node in a TreeView goes all the way out to the right edge? -

how can make background color of node in treeview goes way out right edge? background i have treeview nodes have children gray. leaf nodes have icon descriptive text. it's easy fix. unfortunately it'll require pretty code since you'll have re-template treeviewitem. treeviewitem's template looks this <controltemplate targettype="{x:type treeviewitem}"> <grid> <grid.columndefinitions> <!-- expand/collapse togglebutton --> <columndefinition minwidth="19" width="auto"/> <!-- treeviewitem --> <columndefinition width="auto"/> <!-- children --> <columndefinition width="*"/> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition height="auto"/> <rowdefinition/> </grid.rowdefinitions&

css - Nested Div hover question -

i have 3 html div this: <div id="maindiv"> <div id="nesteddiv1"></div> <div id="nesteddiv2"></div> </div> i want when hover on maindiv or nesteddiv1 , set color 1 maindiv , color 2 nesteddiv2 , when hover on nesteddiv2 change backgroundcolor of nesteddiv2 , maindiv. i prefer css, know javascript way. thanks mazdak there no way, in css, target element using selector includes 1 of descendents. while first half trivial achieve, second half impossible. use javascript if matters much.

Magento - Select some customer infos -

for purpose of module began realize, want make select query gives me address, name , surname of 1 or more clients. i bit lost in database magento, help! you can echo out each select magento getselect() method. for 1 client echo mage::getmodel('customer/customer')->load('id')->getselect(); or whole collection echo mage::getmodel('customer/customer')->getcollection()->getselect();

objective c - How to play video from ePub by using iPhone sdk? -

i have epub file me contain video in it. able unzip epub file & added xcode project shown file in application. not able play video epub file. how can play video? take @ this blog.

java - Calculate the number of times to divide by two -

greetings. i have java method consider expensive, , i'm trying replace calls mathematical expression. problem is, suck @ math. mean really suck. the following should explain pattern i'm trying exploit. f(x) -> y f(x*2) -> f(x)+1 that is, whenever double value x, value y 1 greater x/2. here example output: f(5) -> 6 f(10) -> 7 f(20) -> 8 f(40) -> 9 f(80) -> 10 f(160) -> 11 f(320) -> 12 my current approach brute force. i'm looping on x , test how many times can halve before reach 5, , add 6. works , faster call original method. looking more "elegant" or potentially cheaper solution. accepted answer goes 1 manages me without pointing out how stupid :) (the title sucks, because don't know i'm looking for) have considered looking @ divide five, find power of 2 have, , add 6 power? the general approach "given y find out power of x is" use logarithms . calculator try dividing log of 64

winforms - how to reference the parent form from the WPF control -

i using elementhost host wpf user control within windows form. want know how reference parent form within wpf control. why not create relationship programmatically? i.e. when add wpf user control element host, set tag property of user control element host instance. colin e.

c# - Multiple .cs files and access to Form -

i'm trying write first program in c# without use of tutorial. ensure adopt start coding practices, want create each class in different .cs file. however, i'm running troubles when trying access elements of program in such .cs file. for example, have form1.cs label , start button. when clicking on start button, text should appear in label. so: in form1.cs have: namespace testprogram { public partial class form1 : form { public form1() { initializecomponent(); } private void startbutton_click(object sender, eventargs e) { writetolabel message = new writetolabel(); message.welcomemessage(); } } } and in separate writetolabel.cs file: namespace testprogram { public class writetolabel { public void welcomemessage() { form1 myform = new form1(); //myform.. --> myform doesn't have 'outputlabel'? out

mysql - ON DUPLICATE KEY UPDATE ... with WHERE or subselection? -

i bit concerned 1 of mysql queries... following query receives variable $db_id... if row primary key exists query performs update. $this->db->query(" insert modules_text ( module_id, module_content, module_index ) values ( '{$db_id}', '{$content['text']}', '{$index}' ) on duplicate key update module_content = '{$content['text']}', module_index = '{$index}' "); now thing concerns me... there no relation if affect

Reading apache connection timeout from PHP -

i'm having trouble , searched solution in $_server , $_session variables, couldn't find it. however, in phpinfo() found timeouts connection: 300 - keep-alive: 15 . asuming searching (the number of seconds of inactivity before apache closes connection), there other way of reading it? thanks. see apache_response_headers function, , accompanying comments. this works me: <?php flush(); $apache_headers = apache_response_headers(); //echo '<pre>' . print_r($apache_headers, true) . '</pre>'; preg_match('/timeout=(\d+)/', $apache_headers['keep-alive'], $matches); echo $matches[1]; ?>

http - Sending data to servlet over httpo using java DefaultHttpClient -

i sending binary data ([byte[]) (using java defaulthttpclient) servlet running on apache tomcat server. question need worry machine endianness before sending data server. defaulthttpclient automatically take care of converting data network byte order ? please help. it's using java on both ends, , http on wire, don't have worry endian issues. have encode byte array, of course.

PHP class: Global variable as property in class -

i have global variable outside class = $mynumber; how declare property in myclass ? every method in class, do: class myclass() { private function foo() { $privatenumber = $globals['mynumber']; } } want this class myclass() { //what goes here? var $classnumber = ???//the global $mynumber; private function foo() { $privatenumber = $this->classnumber; } } edit: want create variable based on global $mynumber but modified before using in methods something like: var $classnumber = global $mynumber + 100; you don't want doing this, it's going nightmare debug, seems possible. key part assign reference in constructor. $globals = array( 'mynumber' => 1 ); class foo { protected $glob; public function __construct() { global $globals; $this->glob =& $globals; } public function getglob() { return $this->glob['mynumber'];

.net - How to prevent untrusted string parameter in C# -

for security reasons, don't want specific method receive non-programmer or non-compiler time strings, how this? readonly string ok_str = "some text"; string bad_str = "another text"; public void setsecurestr(string str) { //use string security purpose } //somewhere in code setsecurestr(ok_str); //accepted setsecurestr(ok_str + "programmer passed staticlly!"); //accepted (if not possible implement, forget it) setsecurestr(bad_str); //throw exception, bad_str modifiable setsecurestr(ok_str + untrustedvar); //throw exception, concatenation modifiable setsecurestr(string.format("{0}", ok_str)); //throw exception, not const it may better whitelist against things inside ability control, such enums or local constants (or local whitelist configuration data if list isn't fixed ahead of time). as rough check, check whether interned , since literals interned automatically via ldstr ; note can explicitly intern too, isn'

android - editText is not losing focus -

the edittext not losing focus in app when click out of it, has orange border time , black line cursor.. did linearlayout according surrounding edittext: stop edittext gaining focus @ activity startup doesn't focus on start of app.. this code: final edittext et = (edittext)findviewbyid(r.id.edittext01); final inputmethodmanager imm = (inputmethodmanager) getsystemservice( input_method_service); et.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { imm.showsoftinput(et, inputmethodmanager.show_implicit); } }); et.setonfocuschangelistener(new view.onfocuschangelistener() { public void onfocuschange(view v, boolean hasfocus) { if(hasfocus) { imm.showsoftinput(et, inputmethodmanager.show_implicit); } else { imm.hidesoftinputfromwindow(et.getwindowtoken(), 0); } } }); but, doesn't seem calling onfocuschange when click anywhere outside edittext! it's simple. can put following

mysql - Why there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT clause? -

why there can 1 timestamp column current_timestamp in default or on update clause? create table `foo` ( `productid` int(10) unsigned not null, `addeddate` timestamp not null default current_timestamp, `updateddate` timestamp not null default current_timestamp on update current_timestamp ) engine=innodb; the error results: error code : 1293 incorrect table definition; there can 1 timestamp column current_timestamp in default or on update clause this limitation, due historical, code legacy reasons, has been lifted in recent versions of mysql: changes in mysql 5.6.5 (2012-04-10, milestone 8) previously, @ 1 timestamp column per table automatically initialized or updated current date , time. restriction has been lifted. timestamp column definition can have combination of default current_timestamp , on update current_timestamp clauses. in addition, these clauses can used datetime column definitions. more information, see automati

objective c - How can we plot charts dynamically in iPhone SDK? -

in iphone app, need plot charts dynamically based on data comes database. how can make charts , display them? what should done? please , suggest. thanks if chart should simple enough can try google chart api . chart fetched via web. or can go core plot see stackoverflow post

python - Automatic class decoration (or validation) upon derivation -

have base class derive multiple subclasses. each subclass defines class constants, , wish enforce limitations on them. example: class base(object): # define these in sub-class, , make sure (nom % denom == 0) nominator = none denominator = none class subclass_good(base): nominator = 6 denominator = 3 class subclass_bad(base): nominator = 7 denominator = 5 i want able enforce rule (nom % denom == 0). class decorator: def nom_denom_validator(cls): assert(cls.nominator % cls.denominator == 0) return cls # , decorate each subclass, e.g.: @nom_denom_validator class subclass_another(base): nominator = 9 denominator = 12 but don't fact need decorate each subclass (i have plenty). i'm interested whether can done manipulation on base class directly. any advice? ok, funny. thinking while, after posting question - when choosing tags, , adding "metaclass" there - did realize may have answer myself. so, submi

Why does: string st = "" + 12; work in c# without conversion? -

this super dumb, i've googled , checked references , cannot find answer... why can int or float etc added part of string without converstion not on it's own? is: while work fine: string st = "" + 12; this doesn't (of course): string st = 12; where magic here? know works want know why works , how control how conversion done? in first statement, left operand + string, , such + becomes concatenation operator. compiler finds overload operator takes string , arbitrary value operands. converts both operands strings (using tostring() ) joins them. the second statement not work because there's no implicit cast int string . you can control how conversion done using parentheses change order of operations (semi-effective) or writing code handle conversions pre-emptively.

javascript - Changing the Font and font Size in a textarea field -

using following code sample: <html> <body> <script language = "javascript"> maxl=240; var bname = navigator.appname; function talimit(taobj) { if (taobj.value.length==maxl) return false; return true; } function tacount(taobj,cnt) { objcnt=createobject(cnt); objval=taobj.value; if (objval.length>maxl) objval=objval.substring(0,maxl); if (objcnt) { if(bname == "netscape"){ objcnt.textcontent=maxl-objval.length;} else{objcnt.innertext=maxl-objval.length;} } return true; } function createobject(objid) { if (document.getelementbyid) return document.getelementbyid(objid); else if (document.layers) return eval("document." + objid); else if (document.all) return eval("document.all." + objid); else return eval("document." + objid); } </script> <font face="arial" font size="2"> maximum number of characters text box 240.</font><br> <textarea onkeypre

sql server 2008 express - SQL data retrieve - C# -

how retrieve data table within loop or something. means want retrieve row row @ time. sequence of rows may differ. example, 1st time want 5rd row,then 2nd, 9...so on. i searched through internet. got 2 answers. use several sqlconnection objects. reader= sqlcommand.executereader(); while(reader.read()){ reader["column name"].tostring(); } if got problem, please me thank you. sounds should correct data layer return values in order going process them . easiest , fastest! :) as alternative i'd suggest load result datatable: datatable table = new datatable(); using ( sqlcommand command = new sqlcommand() ) { // todo: set command here using (sqldataadapter adapter = new sqldataadapter(command)) { adapter.fill(table); } } // use datatable this... if ( table.rows.count >= 5 ) { datarow firstrow = table.rows[0]; // #1 row datarow fifthrow = table.rows[4]; // #5

jQuery custom validation: phone number starting with 6 -

i have form in have input phone number , other fields. i'm validating form jquery validate. to validate phone number field do: rules: { phone: { required: true, minlength: 9, number:true },.. but need check phone starts 6. how can that? you can add custom validator jquery.validator.addmethod("phonestartingwith6", function(phone_number, element) { phone_number = phone_number.replace(/\s+/g, ""); return this.optional(element) || phone_number.match(/^6\d{8,}$/); }, "phone number should start 6"); and use this: rules: { phone: { required: true, minlength: 9, phoneending6: true },.. you need edit regex inside phone_number.match suit requirements.

Getting IP Cam video stream on Android (MJEPG) -

i doing andar project in group of 3. i'm person who's in charge of video streaming android phone. got ourselves d-link dcs-920 ip camera , found out uses mjpeg codec live video stream , webserver uses jview view live stream. far know mjpg not supported file type android os i've came out idea, instead of using imageview, use webview stream video. i've implemented simple concept , works! problem is, refresh rate terrible. video image (eg: http://192.168.1.10/image.jpg ) view on webview , implement timer control refresh rate (supposed set 30fps, refresh every 33ms) can go 500ms interval, lower interval notice not smoother,sometimes image wont load , connection unstable (eg: dropped). i'm refreshing @ rate faster can receive? on over webserver jview has no problem! trying find source code jview have no hope. anyway here's code i've written package org.example.test; import java.util.timer; import java.util.timertask; import android.app.activity; import

tfs2010 - TFS 2010: Gated Check-In On Main Branch; Rolling Builds on Dev Branch? -

i migrated vss tfs 2010 , i've been absolutely loving it, there's haven't yet been able working way think should. goals i'd know when change development breaks build. if find out after-the-fact, it's no big deal. since lot of check-ins happen throughout day, don't want wait on build finish, should asynchronous. with our main branch, i'd ensure time merge happens it, make sure it's not going break build. want immediate feedback on this. wait time fine, since won't merging main often. current setup my solution under folder called main. i've made branch off of called development. workspace i'm working in tied top-level, includes both main , development branches. tried adjusting workspace point development, in case problem. didn't seem fix issue, set way had -- both main , development. within workspace's build definitions, have 2 definitions defined -- 1 main branch , development. the first definition building main b

css - IE8 ul menu styling problem -

Image
i have menu using ul, usual works finr in ffx not in ie. i've tried few things can't results. have ideas or pointers? please see attached code , image. if closely can see bullet points(black) on left hand side. in firefox lovely menu displayed....correctly! :) merry xmas!!! l i can't find code here, can upload @ pastebin.com? #menu ul { margin: 0 auto; font-weight:bold; list-style:none; } this code makes me not seeing dot in ie!

.net - Detecting Chrome browser with AJAX -

i use sys.browser.name borwser detection, chrome detected safari. a quick google search turned page: http://davidwalsh.name/detecting-google-chrome-javascript basically, read full user-agent , find string 'chrome': var is_chrome = navigator.useragent.tolowercase().indexof('chrome') > -1;

c# - IoC with AOP (PostSharp) in MonoDroid -

i'm working on monodroid app, , there isn't di solution yet (at least know of). i've gotten postsharp work on monodroid , , i'm using location intercept aspect way inject dependencies fields/properties without using service locator (outside of aspect anyway). here's i'm working far: https://github.com/mgroves/monodroidstockportfolio/blob/develop/monostockportfolio/framework/iocattribute.cs it's rough, , needs refactoring, idea basic structure. however, i'm not convinced approach best way. how go using di/ioc in monodroid app, or without postsharp? it's more "classic container" rather aop, , monodroid isn't platform i've tested on (it's been tested on mono, monotouch, silverlight, windows mobile , winphone7 though), tinyioc should work if fits bill: http://hg.grumpydev.com/tinyioc/wiki/home

sql server - SQL Update query is causing two rows in a trigger -

i use sql server 2005 , have below question: on table a , have trigger tracks insert/update/delete it. tracked records inserted in audit table ( aaudit ). when run update on a , seeing 2 rows in audit table each update, not expect. here trigger have defined: alter trigger [atrigger] on [dbo].[a] insert, update, delete insert [dbo].[aaudit] ([businessdate], [datatypeid], [bookid], [version], [delflag], [auditdate], [extstatus]) select [businessdate], [datatypeid], [bookid], [version], 'n', getdate(), 0 inserted insert [dbo].[aaudit] ([businessdate], [datatypeid], [bookid], [version], [delflag], [auditdate], [extstatus]) select [businessdate], [datatypeid], [bookid], [version], 'y', getdate(), 0 deleted why above trigger resulting in 1 row delflag = 'y' , 1 row delfalg = 'n' in audit table? thanks taking @ question. vikram in order separate 3 operations insert, update, delete, need additional checks: alter trigger [atrigger] on

iPhone making a map like in Fire Emblem -

i want make rpg engage foes utilizing map/grid. i'm trying figure out how done in objective-c... also, not want use opengl; no tilemaps. :p that game looks it's using opengl es. but, achieve somehting similar combination of isometric projection maps , a* pathfinding (and yes, lots , lots of code). here's links research on subjects. beyond that, there's not definitive answer because there's many ways of doing this. isometric projection a* pathfinding beginners

javascript - Access denied to .js file on pre-production but works on development -

xmlhttp.send() in .js file not return document has return , ends erroraccess denied .js file itself. development on 32-bit windows server 2003 , iis6 pre-prod on 64-bit windows server 2008 r2, iis7 are sure have enabled iis serve static content? had issue, , drove me nuts until figured out. in "turn windows features on or off", go "internet information services > world wide web services > common http features > static content" (for windows 7; imagine you'll find in same place on 2008 r2). i don't know how help, see microsoft's documentation . see my similar answer asp.net question .

linq - C# : How to get running combination from two List<String> based on a master list -

dear , previous question how moving combination 2 list<string> in c#? i'm having masterlist , 2 childlist below list<string> masterlist = new list<string> { "a", "b", "c", "d", "e" }; list<string> listone = new list<string> { "a", "b", "c" }; list<string> listtwo = new list<string> { "b", "d" }; i need running combination above list i'm using like(previous question's answer(thanks danny chen)) list<string> result = new list<string>(); result = listone.selectmany((a, indexa) => listtwo .where((b, indexb) => listtwo .contains(a) ? !b.equals(a) && indexb > indexa : !b.equals(a)).select(b => string.format("{0}-{1}", a, b))).tolist(); s

what is the difference between dataform webpart and normal list webpart in sharepoint server? -

we can directly create list in sharepoint ui (not sharepoint designer) or can convert list webpart datafrom webpart using sharepoint designer.what difference makes? when convert dataform webpart, rendering mode converted xslt. xslt can edited in sharepoint designer or webpart properties change rendering of items. moreover, type of webpart changed listviewwebpart dataformwebpart . the benefit of having rendering control , comes disadvantages. ex, functionalities of listviewwebpart sorting, filtering, export excel unavailable/limited in functionality because of xsl limitations.

Does upgrading jQuery UI 1.7.2 to 1.8.7 result in a performance improvement? -

my site using dialogs , buttons jquery ui. in general things working fine, time time users facing light performance issues; system not responsive should in opinion. upgrading jquery 1.4.2 1.4.4 did job, because there lots of find() / filter() calls in code. should expect performance benefits upgrading jquery ui? there couple things think respect upgrading library. how difficult going to so. many times, if minor release upgrade, you're not going see api changes or of nature. should smooth process perform upgrade. in case, don't see reason why wouldn't perform upgrade. in case of going more major release, need consider api changes cause upgrade new version of library take longer. may not simple idea of "drop in new library , you're go." said, typically try keep libraries up-to-date possible. yeah, may more work now, but, in long run, easier upgrade library on continual basis once every 5 years. as type of performance improvements you'

osx - Mac Mouse Coordinates != Window Frame? -

Image
here's issue. can explain enough. desktop 2x2 monitors of size (2048,1152). i'm trying use ancillary device generate mouse clicks. mouse click supposed on coordinate (1600,1407)-ish (on "pan button"), assuming (0,0) top-left of entire desktop area. moves mouse correct position, when perform cgrectcontainspoint() ) gives me no result. the rectangle(frame) given pop-up window has origin of (1558,-406)? math correct cgrectcontainspoint() , window's frame should contain point. (even more can see mouse cursor on window.) why? because child window? (center of desktop in center of image, each window different background color.) i have tried using following: nsrect pframe = [_popupwindow frame]; nspoint porigin = pframe.origin; nspoint correctedorigin = [[_popupwindow parentwindow] convertbasetoscreen:porigin]; pframe.origin = correctedorigin; but gives me: ... rect {{1488, -1529}, {439, 306}}, point {1556.17, 1314.76}, inrect 0 as result, st

virtualization - WPF Virtualizing Stack Panel - Look ahead? -

i wondering if there way control wpf virtualizingstackpanel ahead items. meaning - can see when list loads 10 items visible 20 items being instantiated. assume 10 items ahead of stackpanel, , wondering if can control this. in addition - know of way improve performance of virtualizingstackpanel via parallelism? want instantiate items in parallel, of course since ui thread fail - maybe had made similar before?... thanx guys! gili

Doctrine + ZF + phpunit -

i have zf 1.11 integrated doctrine 1.2 + mysql 5. created phpunit's tests in few files. every test create db , populate - using zend_db - make actions using doctrine's models , drop db using zend_db. put them in directory called "tests". , when go directory "tests" , write phpunit command of them return errors "sqlstate[42s02]: base table or view not found: 1146 table 'here_db_name.here_table_name' doesn't exist". - exists, checked! funny when run every test separately absolutly ok. so, question is: what's going on? sorry, can't provide code. this tricky without code making wild guess here if every test creates , populates db might experiencing sort of "race-condition" because each test starts cleaning database , setting again.

python - Maintaining environment state between subprocess.Popen commands? -

i'm writing deployment engine our system, each project specifies custom deployment instructions. the nodes running on ec2. one of projects depends on source version of 3rd party application. specifically: cd /tmp wget s3://.../tools/x264_20_12_2010.zip unzip x264_20_12_2010.zip cd x264_20_12_2010 ./configure make checkinstall --pkgname=x264 --pkgversion "2:0.head" --backup=no --deldoc=yes --fstrans=no --default currently i'm doing boto's shellcommand (which uses subprocess.popen internally), looks this: def deploy(): shellcommand("apt-get remove ffmpeg x264 libx264-dev") shellcommand("apt-get update") shellcommand("apt-get install -y build-essential checkinstall yasm texi2html libfuse-dev fuse-utils libcurl4-openssl-dev libxml2-dev mime-support libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libvpx-dev libx11-dev libx

comparison - CUDA how to compare two 2D arrays? -

is there efficient algorithm compare 2 2d arrays in cuda fast possible? result need number of array fields equal. thanks in advance help! if want number of equal elements between 2 arrays, try reduce operation. there example of on nvidia's site: reduction . normal sum reductions find sum of elements in array a . want sum of expression a == b elements. should articles on cuda reduction implementations.

external - In Javascript, is it possible to pass a variable into <script> "src" parameter? -

is possible in javascript pass variable through src parameter? ie. <script type="text/javascript" src="http://domain.com/twitter.js?handle=aplusk" />` i'd twitter.js , see if "handle" passed before doing need , returning response originating page calling twitter.js . i had created function in twitter.js did following: function gethandle() { var vars = [], hash, username; var hashes = window.location.href.slice(window.location.href.indexof('?') + 1).split('&'); for(var = 0; < hashes.length; i++) { hash = hashes[i].split('='); if (hash[0] == 'handle') username = hash[1]; } return username; } the problem, , makes sense, window.location.href not going work on file i'm calling <script src="" /> thanks! i can see 2 solutions here. first: can process parameters on server twitter.js hosted, dynamically change js file. example, file is: var

ruby - Adding a method to a Rails ActiveRecord class -

in plain ruby, works fine: class testsuper def foo puts "in testsuper.foo" end end class testclass < testsuper def foo super puts "in testclass.bar" end end class testclass def bar puts "in testclass.bar, second definition" puts "calling foo:" foo end end t = testclass.new t.foo t.bar i can call foo() , bar() on testclass instance , expect: in testsuper.foo in testclass.bar in testclass.bar, second definition calling foo: in testsuper.foo in testclass.bar however, when try similar in rails migration, errors: #### my_model.rb #### puts "in my_model.rb" class mymodel has_many :foo end #### my_migration.rb #### puts "in my_migration.rb" class mymodel def bar foo.each{ |f| f.baz } end end class mymigration < activerecord::migration def self.up mymodel.find(1).bar end def self.down # not applicable end end the first problem mymodel.fin

MS Access SQL: Troubles combining UNION ALL with a LEFT JOIN -

i have created query in ms access simulate full outer join , combine results looks following: select nz(estimates.employee_id, actuals.employee_id) employee_id , nz(estimates.a_date, actuals.a_date) a_date , estimates.estimated_hours , actuals.actual_hours (select * estimates left join actuals on estimates.employee_id = actuals.employee_id , estimates.a_date = actuals.a_date union select * estimates right join actuals on estimates.employee_id = actuals.employee_id , estimates.a_date = actuals.a_date estimates.employee_id null or estimates.a_date null) qfulljoinestimatesactuals i have saved query object (let's call qestimatesandactuals ). objective left join qestimatesandactuals table. following: select * qjoinedtable left join (select * labor_rates) rates on qjoinedtable.employee_id = rates.employee_id , qjoinedtable.a_date between rates.begin_date , rates.end_date ms access accepts syn

php - Datamapper ORM/ CodeIgniter - using and displaying join tables -

i've got "steps" table, "id" , text of step named "step". have "customers" table "id" , other customer info. finally, have "customers_steps" join table "customer_id" , "step_id". goal have list of steps, , show ones completed. i'm stuck... to make sure i'm not missing anything, in "customer" model, have var $has_many = array ('step'); in "step" model, have var $has_many = array('customer'); right now, i'm looping steps, looping through customer's steps see if match... it's lot of code, , know there has faster way, , i'm missing it: $c = new customer(); $c->get_by_id(1); $c->step->get(); $s = new step(); $s->get(); foreach($s $step) { foreach($c $customer) { if($customer->step->id == $step->id) { $match = true; } } if($match) { echo "match - " . $

windows phone 7 - Caliburn.Micro(.WP7) and Bing Maps Crashing -

i have app i'm upgrading beta bits - , map screen crashing. try bottom of - started brand new - blank "win phone application". referenced caliburn.micro (just built new code last night) version: caliburnmicro_1296ea635677 (from codeplex) referenced microsoft.phone.controls.map.dll and in mainpage added <grid> <maps:map /> </grid> and add bootstrapper app.xaml <wp7:phonebootstrapper x:name="bootstrapper" /> when page runs in phone emulator - main page renders , see map of world. if click anywhere on page - unhandled exception of "the parameter incorrect" if remove from app.xaml - map works correctly. what think? thanks advice? i have found answer. the key here - had setup , wroking beta templates - , stopped working when moved winphone rtm templates in vs2010. caliburn work on behalf, "added" rtm templates - conflicting each other. in end problem has/had nothing bing maps contro

java - Postgresql UUID supported by Hibernate? -

i can't hibernate working java.util.uuid postgresql. here mapping using javax.persistence.* annotations: private uuid itemuuid; @column(name="item_uuid",columndefinition="uuid not null") public uuid getitemuuid() { return itemuuid; } public void setitemuuid(uuid itemuuid) { this.itemuuid = itemuuid; } when persisting transient object sqlgrammarexception: column "item_uuid" of type uuid expression of type bytea @ character 149 postgresql version 8.4.4 jdbc driver - 8.4.4-702 (also tried 9.0 - same thing) hibernate version 3.6, main configuration properties: <property name="hibernate.dialect">org.hibernate.dialect.postgresqldialect</property> <property name="hibernate.connection.driver_class">org.postgresql.driver</property> <property name="hibernate.connection.url">jdbc:postgresql://192.168.1.1/db_test</property> this can solved adding following annota

css - Vertically Scrolling a <DIV> -

i have few nested , want allow deepest scroll vertically. in css have tried adding: overflow-x: hidden; /* horizontal */ overflow-y: auto; /* vertical */ to class assigning not seem it. changing overflow-y: yes; not work either. how 1 accomplish this. want scroll because gets populated mysql data other div's present selectable criteria create query , run it. thoughts appreciated. example: <div id="content"> <div id="slidingdivkeynotepresentations"> <!-- content here --> </div> </div> my css: #content { position: absolute; top: 0; left: 21%; margin: 26% 31% 1% 21%; /* cater mac ie5 */ /*\*/ margin: 0; /* put rest */ /*\*/ overflow: auto; /* no need mac ie5 see */ overflow-x: hidden; /* horizontal */ overflow-y: yes; /* vertical */ } #slidingdivkeynotepresentations { display: none; height: 600px; width: 600px; background-image: url('images

javascript - What is the equivalent of IE's removeNode -

ie's removenode http://msdn.microsoft.com/en-us/library/ms536708(vs.85).aspx helps me decide whether remove childnodes or not. i know whether same exists firefox, opera, chrome , safari. if not, how can achieve it? didn't want just copy code over, give read: http://www.sitepoint.com/forums//showthread.php?p=947385 edit (but i, pst, have no shame -- code above link ;-) if ( window.node ) node.prototype.removenode = function( removechildren ) { var self = this; if ( boolean( removechildren ) ) { return this.parentnode.removechild( self ); } else { var range = document.createrange(); range.selectnodecontents( self ); return this.parentnode.replacechild( range.extractcontents(), self ); } }

c# - viewmodel problem, "does not contain definition" -

i error 'object' not contain definition 'images' , no extension method 'images' accepting first argument of type 'object' found (are missing using directive or assembly reference?) inside index.aspx <div class="wrapcarousel"> <div class="carousel"> <% foreach (var image in model.images){ %> <div class="placeimages"> <img width="150px" height="150px" src="../img/<%=image.tnimg%>" alt="<%=image.name%>" /> <div class="imagetext"> <%=image.name%> </div> </div> <% } %> this homecontroller.cs: public actionresult index() { viewdata["noofplaces"] = noofplaces(); imageviewmodel imageviewmodel = new imageviewmodel(); imageviewmodel.images = getimages(); return view("index", imageviewmodel);

c# - How does the StringBuilder decide how large its capacity should be? -

i know stringbuilder object allocates more memory when use sb.append(..) when sb @ capacity. how capacity increase? stringbuilder sb = new stringbuilder(5); sb.append("0123456789"); now capacity of sb , why? multiplier? just clarity. asking capacity , not length. thanks! the capacity doubles each time apart special cases: if doubling not enough capacity further increased exact amount required. there upper limit - 0x7fffffff. you can see algorithm using .net reflector or downloading reference source. i can't post source code official .net implementation here's code mono implementation: // try double buffer, if doesn't work, set length capacity if (size > capacity) { // first time string appended, set _cached_str // , _str it. allows optimizations. // below, take account. if ((object) _cached_str == (object) _str && capacity < constdefaultcapacity) capacity = constdefaultcapacity; ca

objective c - inject programming code into iphone app -

i saw in article can run javascript in uiwebview: http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview it great if inject business logic app based on few parameters have or able customize on fly via web downloading updated code become part of app. has done or possibility? i advise avoid doing it. app downloads code rejected on app store. from app store review guidelines: 2.7 apps download code in way or form rejected

crystal reports - Sub total each cross tab group with grand total in end? -

Image
i have result of query in form empid profit orderid companyname ------ ------ ------- -------------- 1 500 $ 1 acme company 1 200 $ 1 evolve corp. 2 400 $ 1 acme company 2 100 $ 1 evolve corp. 3 500 $ 1 acme company 3 500 $ 1 evolve corp. now desired report format is empid orderid acme's profit evolve's profit ----- ------ ------------- --------------- 1 1 700 $ 700 $ total ---- ----- ------ 700$ 700$ 2 1 500 $ 500 $ total ---- ----- ------ 500$ 500$ 3 3 1000 $ 1000 $ total ---- ----- ------ 1000$

On android first I am capturing cookie from webview, then removing the session cookie , then again setting the cookie -

cookiemanager cookiemanager = cookiemanager.getinstance(); string cookie = cookiemanager.getcookie(url); cookiemanager.removesessioncookie(); cookiemanager.setacceptcookie(true); cookiemanager.setcookie( url, cookiestring); removing cookie works, how set cookie onto webview , access logged in page again thanks in advance you must use cookiesyncmanager. inside activity call: cookiemanager.setcookie(url, cookiestring); cookiesyncmanager.createinstance(this).sync();

python - better way of handling nested list -

my_list = [ [1,2,3,4,5,6], [1,3,4],[34,56,56,56]] item in my_list: var1,var2,var3,var4,var5,var6 = none if len(item) ==1: var1 = item[0] if len(item) == 2: var1 = item[0] var2 = item[1] if len(item) == 3: var1 = item[0] var2 = item[1] var3 = item[2] if len(item) == 4: var1 = item[0] var2 = item[1] var3 = item[2] var4 = item[3] fun(var1,var2,var3,var4,var5,var6) i have function def fun(var1, var2 = none, var3 = none, var4 = none, var5=none, var6= none) depending upon values in inner list. passing function. hope made clear. thanks see calls , function definitions in python documentation , specifically: if syntax *expression appears in function call, expression must evaluate sequence. elements sequence treated if additional positional arguments.... if syntax **expression appears in function call, expression must evaluate m

Method for streaming AAC+ audio in Python? -

i wish play aac+ shoutcast stream in python. have tried bass_aac, extension bass audio library claims able handle aac+ unsuccessfully. i'm willing write binding external library if necessary. suggestions? using gstreamer via gst-python solution. gst can handle whole audio pipeline http streaming speaker output. i suggest using gst-launch feel of api gst-launch playbin2 uri=http://stream0.freshair.org.uk:3066/; you can use souphttpsrc or other plugins enable receiving metadata or more advanced output. note: ; in shoutcast url forces audio stream without metadata. useful localise issues relating shoutcast/icecast , not more general audio streaming,

.NET - Timer Elapsed Event Overlap -

is there way detect elapsed events of timer overlapping? example, create timer 200ms interval between elapsed events executed code @ event taking more 200ms. result, elapsed event executed before last 1 finished. there way prevent happening such event not invoked before last 1 finished? if want timer events happen on 200ms mark , skip 1 (rather postpone them) if previous still running use locking code. if use method monitor.tryenter return boolean telling if has got lock (and if thread in locked code). enable skip on , wait next run time if want (or write out debug messages complaining taking long or something). whether solution depends on timer wanting do. method others have suggested of starting timer next event once previous 1 finishes more sufficient job.

How do I get an audio file sample rate using sox? -

i sample-rate of given audio file using sox. couldn't find commandline that. just use: soxi <filename> or sox --i <filename> to produce output such as: input file : 'final.flac' channels : 4 sample rate : 44100 precision : 16-bit duration : 00:00:11.48 = 506179 samples = 860.849 cdda sectors file size : 2.44m bit rate : 1.70m sample encoding: 16-bit flac comment : 'comment=processed sox' the latter 1 in case you're using win32 version doesn't include soxi, default. grab sample rate only, use: soxi -r <filename> or sox --i -r <filename> which return sample rate alone.

python - AppEngine: Step-by-Step Debugging -

while working appengine locally (i.e. using dev_appserver.py), there anyway step-by-step debugging? old fashion use logging.info() or similar functions show values of variables in code , decide error is. to expand little bit on codeape's answer's first suggestion: because dev_appserver.py mucks stdin, stdout, , stderr, little more work needed set "code breakpoint". trick me: import sys attr in ('stdin', 'stdout', 'stderr'): setattr(sys, attr, getattr(sys, '__%s__' % attr)) import pdb pdb.set_trace() you'll have run dev_appserver.py command line rather via gui app engine launcher. when pdb.set_trace() line executed, dropped pdb debugger @ point.

php - Codeigniter - matching user entered password to hashed password stored in DB always returns false. Please help -

i have controller setup join_model , login_model a user registers , after have passed validation , captcha etc , have clicked submit set setup. my setup controller loads join_model , create() method, takes post data , gets ready send db. when password entered in signup form get's hashed, salted etc. after have if statement checks whether user passed checklogin method in login_model true. method in setup controller , called loginvalidated. if true user re-directed member area (dash). when test keep getting sent failed page. changed if state (!this->loginvalidated()) , de-directed account area meaning passwords must not match. i wondering if have quick through code see if spot i'm going wrong? <?php class setup extends controller { public function index() { $this->load->model('join_model'); $this->join_model->create(); if ($this->loginvalidated()) { //if user credentials passed validation redi

domain driven design - wcf wrapper around ddd project -

i have 2 questions - : 1) have provide wcf wrapper around ddd project. , below design correct ? mvc -> servicelayer(wcf) -> app -> domain -> infra or app service act wcf service. 2) know have expose dto's in service layer. so, ever service method's expose in domain services , app services, have create same name method service in service layer , call domain service , app service service layer. it's hard answer kind of question since depends needs , requirements. for point of view there not "a best solution" solution fit requirement. anyway in general doing correct have make sure fit needs: sometime obsessed following best practice risk add many layer done 2 :-) the thing can can't expose dto way transfer objects (from high point of view compared protocol) doesn’t object exposing. create poco objects instead , expose them in case need "assembler" layer used service layer create poco objects against "dom

Magento rewrite headaches -

just need bit of advice. have finish building site, have turned on web server rewrites in backend rid of index.php but when go frontend keeps giving me 404 errors i cant seem figure out ... there else need do? cheers enable mod rewrite logging , regenerate indexes

lucene - Extract terms from query for highlighting -

i'm extracting terms query calling extractterms() on query object result of queryparser.parse() . hashtable, each item present as: key - term:term value - term:term why key , value same? , more why term value duplicated , separated colon? do highlighters insert tags or else? want not text fragments highlight source text (it's big enough). try terms , offsets insert tags hand. worry if right solution. it because .net 2.0 doesnt have equivalent java's hashset . conversion .net uses hashtables same value in key/value. colon see result of term.tostring() , term fieldname + term text, field name "term". to highlight entire document using highlighter contrib, use nullfragmenter

multithreading - Auto file updater in C#? -

in c# m creating application based on thread, read text file computer(actually remote computer) selected user. if user makes changes in original file application should display modified file(whole). successfully doing but, thread using don't know how , place continuous read original file background. application gets hangs code public partial class formfileupdate : form { // delegate enables asynchronous calls setting text property on richtextbox control. delegate void updatetextcallback(object text); // thread used demonstrate both thread-safe , unsafe ways call windows forms control. private thread autoreadthread = null; public formfileupdate() { initializecomponent(); //creating thread this.autoreadthread = new thread(new parameterizedthreadstart(updatetext)); } private void opentoolstripbutton_click(object sender, eventargs e) { openfiledialog fileopen = new openfiledialog(); fileopen