Posts

Showing posts from January, 2010

html - jqTouch css and a href link -

i trying call link page points part of page. this code using this: <a href="#product"><img src="dress1.jpg" alt="pic1"></img></a> the problem when remove css stylesheet links page, in other words: <link type="text/css" rel="stylesheet" media="screen" href="jqtouch/jqtouch.css"> <link type="text/css" rel="stylesheet" media="screen" href="themes/jqt/theme.css"> it works above links, doesn't work. instead change address (by adding #product) , doesn't display image requested in i'm not sure wrong. thanks. c. depending on revision of jqtouch using, need add animation class link slide/flip/disolve in order cause transition 1 psuedo page next. <a href="#product" class="slide"><img src="dress1.jpg" alt="pic1"/></a>

vba - How do I keep RecipientTime when executing MailItem.Move in an Outlook macro? -

in outlook 2003 macro; there way move message between folders without changing receivedtime-header? i use method mailitem.move . automatically sets receivedtime property current time, isn't want. i tried moving mailitem inbox deleted items folder, , seems have kept receivedtime without problem... you may want try using mailitem.copy function , moving resulting mailitem object, said i'm not seeing same problem... hope helps...

java - encryption program -

i need idea creatin encryption program can 1 help!? need create program in java or c++ need create logic encryption prog should automatically encrypt document n should decrypt if givien conditions such password fulfilled ! plz ! i agree fielding. in case want homework, think it's ok use xor encryption: java sample code: public string xorenc(int enckey, string toenc) { /* usage: str = xorenc(integer_key,string_to_encrypt); created matthew shaffer (matt-shaffer.com) */ int t=0; string s1=""; string tog=""; if(enckey>0) { while(t < toenc.length()) { int a=toenc.charat(t); int c=a ^ enckey; char d=(char)c; tog=tog+d; t++; } } return tog; } public string xorencstr(string enckey, string toenc) { /* usage: str = xorenc(string_key,string_to_encrypt); created matthew shaffer (matt-shaffer.com) */ ...

sql - insert query now causing other queries to no longer work -

i ran query on sql server database: begin transaction; insert [db].[a].[table1] ( [isdeleted], [itemid], [regionid], [deskid], [lastupdated], [lastupdatedby]) select [isdeleted], [itemid], [regionid], 11, [lastupdated], [lastupdatedby] [db].[a].[table1] deskid = 12; update [db].[a].[table1] set deskid = 3 deskid = 12; commit transaction; there records should have changed said (o rows affected). i went a: select * [db].[a].[table1] and spinning "executing query" minutes no end in site. does see wrong first query cause type of lock issue. also, in state, how out of it? is first script still executing update statement? if expected selecting rows not yet committed. if not , apparently idle don't think can have run whole of first script. @ rate seems transaction still open , needs rolled or committed. you can confirm running select * sys.dm_os_waiting_tasks , looking @ blocking_session_id or if on sql2000 need use exec sp_who2 is in man...

c# - What's the difference between the inner workings of Java's JVM and .NET's CLR? -

what's difference between inner workings of java's jvm , .net's clr? perhaps starting point be, same thing in respective environments (java > jvm > machine code) (c# > clr > il). update: several people have alluded points trying cover: garbage collection boxing/unboxing jit debugging generics/templates please feel free suggest other topics differentiate two. @george mauer - sounds interesting: already posted once here series of interviews c# chief language designer anders hejlsberg. already posted once here series of interviews c# chief language designer anders hejlsberg. though talking differences between c# , java dive differences between virtual machines well.

Is there a bit-equivalent of sizeof() in C? -

sizeof() doesn't work when applied bitfields: # cat p.c #include<stdio.h> int main( int argc, char **argv ) { struct { unsigned int bitfield : 3; } s; fprintf( stdout, "size=%d\n", sizeof(s.bitfield) ); } # gcc p.c -o p p.c: in function ‘main’: p.c:5: error: ‘sizeof’ applied bit-field ...obviously, since can't return floating point partial size or something. however, brought interesting question. is there equivalent, in c, tell number of bits in variable/type? ideally, work regular types well, char , int , in addition bitfields. update: if there's no language equivalent of sizeof() bitfields, efficient way of calculating - @ runtime! imagine have loops depend on this, , don't want them break if change size of bitfield - , no fair cheating , making bitfield size , loop length macro. ;-) you cannot determine size of bit-fields in c. can, however, find out size in bits of other types using value of char_bit...

My first Lisp macro; is it leaky? -

i've been working through practical common lisp , exercise decided write macro determine if number multiple of number: (defmacro multp (value factor) `(= (rem ,value ,factor) 0)) so : (multp 40 10) evaluates true whilst (multp 40 13) not the question macro leak in way? "good" lisp? there existing function/macro have used? siebel gives extensive rundown (for simple cases anyway) of possible sources of leaks, , there aren't of here. both value , factor evaluated once , in order, , rem doesn't have side effects. this not lisp though, because there's no reason use macro in case. function (defun multp (value factor) (zerop (rem value factor))) is identical practical purposes. (note use of zerop . think makes things clearer in case, in cases need highlight, value you're testing might still meaningful if it's other zero, (= ... 0) might better)

events - Android OnClickListener - identify a button -

hey. have activity: public class mtest extends activity { button b1; button b2; public void oncreate(bundle savedinstancestate) { ... b1 = (button) findviewbyid(r.id.b1); b2 = (button) findviewbyid(r.id.b2); b1.setonclicklistener(myhandler); b2.setonclicklistener(myhandler); ... } view.onclicklistener myhandler = new view.onclicklistener() { public void onclick(view v) { // question starts here!!! // if b1 // if b2 // question ends here!!! } } } how check button has been clicked? you learn way it, in easy way, is: public class mtest extends activity { button b1; button b2; public void oncreate(bundle savedinstancestate) { ... b1 = (button) findviewbyid(r.id.b1); b2 = (button) findviewbyid(r.id.b2); b1.setonclicklistener(myhandler1); b2.setonclicklistener(myhandler2); ... } view.onclicklistener myhandler1 = new view.onclicklistener() { public void onclick(view v) ...

c++ - Guidelines to improve your code -

what guidelines follow improve general quality of code? many people have rules how write c++ code (supposedly) make harder make mistakes. i've seen people insist every if statement followed brace block ( {...} ). i'm interested in guidelines other people follow, , reasons behind them. i'm interested in guidelines think rubbish, commonly held. can suggest few? to ball rolling, i'll mention few start with: always use braces after every if / else statement (mentioned above). rationale behind it's not easy tell if single statement 1 statement, or preprocessor macro expands more 1 statement, code break: // top of file: #define statement dosomething(); dosomethingelse // in implementation: if (somecondition) dosomething(); but if use braces work expected. use preprocessor macros conditional compilation only. preprocessor macros can cause sorts of hell, since don't allow c++ scoping rules. i've run aground many times...

How to set up a Subversion (SVN) server on GNU/Linux - Ubuntu -

i have laptop running ubuntu act subversion server. both myself commit locally, , others remotely. steps required working? please include steps to: get , configure apache, , necessary modules (i know there other ways create svn server, apache-specific) configure secure way of accessing server (ssh/https) configure set of authorised users (as in, must authorised commit, free browse) validate setup initial commit (a "hello world" of sorts) these steps can involve mixture of command line or gui application instructions. if can, please note instructions specific particular distribution or version, , users' choice of particular tool can used instead (say, nano instead of vi ). steps i've taken make laptop subversion server. credit must go alephzarro directions here . have working svn server (which has been tested locally). specific setup: kubuntu 8.04 hardy heron requirements follow guide: apt-get package manager program text editor (i u...

c++ - What is wrong with using inline functions? -

while convenient use inline functions @ situations, are there drawbacks inline functions? conclusion : apparently, there nothing wrong using inline functions. but worth noting following points! overuse of inlining can make programs slower. depending on function's size, inlining can cause code size increase or decrease. inlining small accessor function decrease code size while inlining large function can dramatically increase code size. on modern processors smaller code runs faster due better use of instruction cache. - google guidelines the speed benefits of inline functions tend diminish function grows in size. @ point overhead of function call becomes small compared execution of function body, , benefit lost - source there few situations inline function may not work: for function returning values; if return statement exists. for function not returning values; if loop, switch or goto statement exists. if function recursive. -source the __inline keyword cau...

c++ - Resetting detection of source file changes -

sometimes have work on code moves computer clock forward. in case .cpp or .h files latest modification date set future time. later on, when clock fixed, , compile sources, system rebuilds of project because of latest modification dates in future. each subsequent recompile has same problem. solution know are: a) find file has future time , re-save it. method not ideal because project big , takes time windows advanced search find files changed. b) delete whole project , re-check out svn. does know how can around problem? is there perhaps setting in visual studio allow me tell compiler use archive bit instead of last modification date detect source file changes? or perhaps there recursive modification date reset tool can used in situation? if problem, i'd ways avoid mucking system time. isolating code under unit tests, or virtual machine, or something. however, because love powershell : get-childitem -r . | ? { $_.lastwritetime -gt ([datetime]::no...

c++ - Rollover safe timer (tick) comparisons -

i have counter in hardware can observe timing considerations. counts miliseconds , stored in 16 bit unsigned value. how safely check if timer value has passed time , safely handle inevitable rollover: //this bit contrived, illustrates i'm trying const uint16_t print_interval = 5000; // milliseconds static uint16_t last_print_time; if(ms_timer() - last_print_time > print_interval) { printf("fault!\n"); last_print_time = ms_timer(); } this code fail when ms_timer overflows 0. you don't need here. original code listed in question work fine, assuming ms_timer() returns value of type uint16_t. (also assuming timer doesn't overflow twice between checks...) to convince case, try following test: uint16_t t1 = 0xfff0; uint16_t t2 = 0x0010; uint16_t dt = t2 - t1; dt equal 0x20 .

What is the best code template facility for Emacs? -

particularly, best snippets package out there? features: easy define new snippets (plain text, custom input defaults) simple navigation between predefined positions in snippet multiple insertion of same custom input accepts selected text custom input cross-platform (windows, linux) dynamically evaluated expressions (embedded code) written in concise programming language (perl, python, ruby preferred) nicely coexists others packages in emacs example of code template, simple for loop in c: for (int = 0; < %n%; ++i) { _ } it lot of typing such common code. want invoke code template or snippet inserts boilerplate code me. additionally stops (on tab or other keystroke) @ %n% (my input replaces it) , final position of cursor _ . textmate's snippets closest match not cross-platform solution , not emacs. the second closest thing yasnippet ( screencast shows main capabilities). interferes hippie-expand package in setup , embedded language emacsli...

c++ - Making portable code -

with fuss opensource projects, how come there still not strong standard enables make portable code (i mean in c/c++ not java or c# ) kind of making it's own soup. there third party libs apache portable runtime . yes, there no standard libraries qt , boost can make life easier when cross-platform development.

Reasons not to build your own bug tracking system -

several times i've been faced plans team wants build own bug tracking system - not product, internal tool. the arguments i've heard in favous along lines of : wanting 'eat our own dog food' in terms of internally built web framework needing highly specialised report, or ability tweak feature in allegedly unique way believing isn't difficult build bug tracking system what arguments might use support buying existing bug tracking system? in particular, features sound easy turn out hard implement, or difficult , important overlooked? first, @ these ohloh metrics: trac: 44 kloc, 10 person years, $577,003 bugzilla: 54 kloc, 13 person years, $714,437 redmine: 171 kloc, 44 person years, $2,400,723 mantis: 182 kloc, 47 person years, $2,562,978 what learn these numbers? learn building yet bug tracker great way waste resources! so here reasons build own internal bug tracking system: you need neutralize bozocoders decade or two. yo...

c# - Is there any way to get rid of the long list of usings at the top of my .cs files? -

as more , more namespaces in solution, list of using statements @ top of files grows longer , longer. case in unit tests each component might called need include using interface, ioc container, , concrete type. with upward of 17 lines of usings in integration test files getting downright messy. know if theres way define macro base using statements? other solutions? some people enjoy hiding usings in #region . otherwise, think you're out of luck. unless want put namespace on referents.

python : tracking change in class to save it at the end -

class a(object): def __init__(self): self.db = create_db_object() def change_db_a(self): self.db.change_something() self.db.save() def change_db_b(self): self.db.change_anotherthing() self.db.save() i getting object database, changing in multiple function , saving back. slow because hits database on every function call. there deconstructor can save database object don't have save every function call , not waste time. don't rely on __del__ method saving object. details, see blog post . you can use use context management protocol defining __enter__ , __exit__ methods: class a(object): def __enter__(self): print 'enter' # create database object here (or in __init__) pass def __exit__(self, exc_type, exc_val, exc_tb): print 'exit' # save database object here # other methods then use with statement when create object: with a() ...

regex - Regular expression that rejects all input? -

is possible construct regular expression rejects input strings? probably this: [^\w\w] \w - word character (letter, digit, etc) \w - opposite of \w [^\w\w] - should fail, because character should belong 1 of character classes - \w or \w another snippets: $.^ $ - assert position @ end of string ^ - assert position @ start of line . - char (?#it's comment inside of empty regex) empty lookahead/behind should work: (?<!)

javascript - Which versions of IE use standard event model? -

i've googled can't find satisfactory answer. versions of internet explorer, if any, implement w3c dom level 2 event model? ie 9 should first ie version add w3c event model in addition proprietary model according wikipedia . further reading: ieblog: dom level 3 events support in ie9 (march, 2010) robert nyman: internet explorer 8 – fix event handling, or don’t release it (november 2008)

computer science - Good text on order analysis -

as self-taught computer programmer, i'm @ loss estimate o() value particular operation. yeah, know off top of head of important ones, major sorts , searches, don't know how calculate 1 when new comes along, unless it's blindingly obvious. there web site or text explains how that? heck, don't know computer scientists call it, can't google it. if want learn topic, need standard theory/algorithms textbook. don't know of website can teach complexity analysis ("complexity" or "time complexity" how call o() values; might want google "analysis of algorithms" or "introduction algorithms" or such). but before -- free option. there slides course given erik demaine , charles leiserson in mit, free , great. try read them , see if works you. here . now, textbooks: the classical choice textbook cormen et al's book introduction algorithms (there might cheap version available buy here , remember seeing free (po...

java - Accessing a bean with a dot(.) in its ID -

in flow definition, trying access bean has dot in id (example: <evaluate expression="bus.myservicefacade.someaction()" /> however, not work. swf tries find bean "bus" instead. initially, got on using helper bean load required bean, solution inelegant , uncomfortable. use of alias'es out of question since beans part of large system , cannot tamper them. in nutshell, none of solution allowed me refernce bean directly using original name. possible in current swf release? i able using both bean accessor ( @ ) symbol , single-quotes around name of bean. using example: #{@'bus.myservicefacade'.someaction()}

.net - How to Convert ISO 8601 Duration to TimeSpan in VB.Net? -

is there standard library method converts string has duration in standard iso 8601 duration (also used in xsd duration type) format .net timespan object? for example, p0dt1h0m0s represents duration of 1 hour, converted new timespan(0,1,0,0,0). a reverse converter exist works follows: xml.xmlconvert.tostring(new timespan(0,1,0,0,0)) above expression return p0dt1h0m0s. this convert xs:duration timespan: system.xml.xmlconvert.totimespan("p0dt1h0m0s") see http://msdn.microsoft.com/en-us/library/system.xml.xmlconvert.totimespan.aspx

ruby - How do I get logout to work on RubyCAS-Server? -

i have installed , setup rubycas-server , rubycas-client on machine. login works when try logout error message rubycas-server: camping problem! casserver::controllers::logout.get activerecord::statementinvalid mysql::error: unknown column 'username' in 'where clause': select * `casserver_pgt` (username = 'lgs') : i using version 0.6 of gem. looking @ migrations in rubycas-server looks there shouldn't username column in table @ all. does know why happening , can it? seems there's bug in 0.6 version of gem (possibly coinciding change made finders in rails 2.1) detailed in bug ticket . in meantime, try installing source tree .

PHP connect via SSH tunnel to LDAP in other network -

i'm developing website school. in school authenticate users via ldap, there idea same via school-site. on site working perfectly, during developing need test if such solution works, of not. in order not commit changes want test site on local computer, connecting ldap want use ssh tunnel. in school network have 1 server through witch connecting inside of our school network. it's address phoenix.lo5.bielsko.pl . inside network have ldap server opened 389 , 636 ports. it's address auth.lo5 . don't have access auth.lo5 via ssh, can connect ldap entries. so, i've tried run ssh tunnel running: ssh -l 636:auth.lo5:636 hfaua@phoenix.lo5.bielsko.pl then, i've set in /etc/hosts auth.lo5 pointing 127.0.0.1 . i'm connecting ldap in php in such way: ldap_connect('ldaps://auth.lo5', 636); but i'm getting error can't contact ldap server . think, problem might on phoenix.lo5.bielsko.pl in ssh daemon config or in arguments passed ldap_connect(...

3d - Perspective projection - how do I project points which are behind 'camera'? -

i'm writing own software rasterizer in java, , ran trouble it... take @ sample image, please: image this sample draw simple square grid on plane. works fine until move camera close enough points move behind it. after that, they're no longer projected correctly, can see (vertical lines - points should behind camera projected on top of screen). my transformation matrices , vectors same ones directx using (perspectivefovlh projection, lookatlh camera). i'm using following transformation method project 3d point: 3d vector transformed created. vector multiplied viewprojection matrix. after that, point transformed screen using following method: // 'vector' input vector in projection space // projection screen double vx = vector.x / vector.z; double vy = vector.y / vector.z; //translate //surfacew width , surfaceh height of rendering window. vx = (( vx + 1.0f) / 2.0f) * surfacew; vy = ((-vy + 1.0f) / 2.0f) * surfaceh; return new vector3(vx, vy,...

Android, how to not destroy the activity when I rotate the device? -

i have app works in portrait mode, , have made changes in manifest file every activity orientation portrait. when rotate device, activity recreates again. how not destroy activity? for api 12 , below : add android:configchanges="orientation" add "screensize" if targeting api 13 or above because whenever orientation changes screen size, otherwise new devices continue destroy activity. see egg's answer below more information on using "screensize" android:configchanges="orientation|screensize" to activity in androidmanifest.xml. way activity wont restarted automatically. see the documentation more infos

Calling PHP functions within HEREDOC strings -

in php, heredoc string declarations useful outputting block of html. can have parse in variables prefixing them $, more complicated syntax (like $var[2][3]), have put expression inside {} braces. in php 5, is possible make function calls within {} braces inside heredoc string, have go through bit of work. function name has stored in variable, , have call dynamically-named function. example: $fn = 'testfunction'; function testfunction() { return 'ok'; } $string = <<< heredoc plain text , function: {$fn()} heredoc; as can see, bit more messy just: $string = <<< heredoc plain text , function: {testfunction()} heredoc; there other ways besides first code example, such breaking out of heredoc call function, or reversing issue , doing like: ?> <!-- directly output html , breaking php function --> plain text , function: <?php print testfunction(); ?> the latter has disadvantage output directly put output stream (unless i...

C# - Deleting a file permanently -

i've been out of c# game while since started iphone stuff, how can delete file (so not stored in memory) , isn't recoverable. if can't delete forever can scramble random data unable opened still exists? it's possible overwrite file previous content cannot recovered. has done drive make sure correct block overwritten... c# interacts filesystem, not physical blocks, won't provide security. the actual way ask drive securely erase varies interface (atapi vs sata, vs usb mass-storage vs scsi vs firewire), , c# doesn't provide simple way of commanding @ level.

Print Drupal admin links in blocks broken out by sections -

the drupal's main admin page contains many links grouped different purposes. by default there following sections: content management, site building, site configuration, user management, reports now i'm using rootcandy admin theme , want move these annoying links sliding panel collapsed default. so question is: how split these links blocks? i'd "content management", "site building", "site configuration", "user management", "reports" blocks contaning related links. thanks! use menu block module. once enabled, go block administration page. each block want create, click add menu block tab. of default options suit use case: set parent item -> menu navigation , parent item -> item menu want create.

linux - old rsync and spaces in filenames -

source directory determined so: show=${pwd##*/} src=wells@server.com:"/mnt/bigfish/video/tv/${show}/" so comes out like: wells@server.com:/mnt/bigfish/video/tv/the name of show spaces/ then trying run rsync so: rsync -avz -e ssh "${src}" . but tells me ""/mnt/bigfish/video/tv/the" not directory, ""/mnt/bigfish/video/tv/name" not directory, etc, many space-delimited words in name of source directory. how can rectify egregiously annoying issue? update i'm running on os 10.6, , ended string-replacing spaces escaped spaces so: src=wells@kittenfactory.com:"/mnt/bigfish/video/tv/${show// /\ }/" from rsync manual : -s, --protect-args option sends filenames , options remote rsync without allowing remote shell interpret them. means spaces not split in names, , non-wildcard special characters not translated (such ~,...

javascript - Microsoft JScript runtime error: 'this._postBackSettings.async' is null or not an object -

i have report on asp page , every time change filter , click view report, error: microsoft jscript runtime error: 'this._postbacksettings.async' null or not object i tried change enablepartialrendering="true" enablepartialrendering="false" people can't login on site i discovered solution problem. i use telerik radscriptmanager , radajaxmanager (which built upon respective asp.net framework objects). discovered issues when implemented jquery ui animations hide buttons--animations executed "onclientclick" of button. to solve problem, handled onrequeststart , onresponseend client events , executed applicable hide , show animations onrequeststart , onresponseend, respectively. i know not uses telerik, concept might key, , applies other ajax frameworks: when performing client-side changes on ajaxified elements (especially changes animations occur during ajax request processing), make changes in framework's requeststart/r...

iphone - Can I implement something similar to iOS "Folders"? -

i going make visually similar ios4 folders it's not folders @ ))) for example, have 4 labels on screen - see sketch. screen splits, if user click on label. other lebels going down , can see text between splited views. if user click once more - view "normal" state before. , on. questions are: is confront iphone hig , app can rejected? what easiest way implement this? thanks ) alt text http://a.imageshack.us/img196/1306/sketch1.gif your app can always rejected, no reason @ all. this seems less folders , more outline collapsable items (or code folding in programming editor). plenty of outliner apps in store no reason should able (but read first line of answer again! no promises!). lots of ways implement this. here's random quick one: if use uitableview , have uitableviewdatasource implementing class has items marked hidden/vislble. numberofrowsinsection method return number of visible rows , tableview:cellforrowatindexpath: have skip...

security - Hiding a password in a python script (insecure obfuscation only) -

i have got python script creating odbc connection. odbc connection generated connection string. in connection string have include username , password connection. is there easy way obscure password in file (just nobody can read password when i'm editing file) ? base64 encoding in standard library , stop shoulder surfers: >>> import base64 >>> print base64.b64encode("password") cgfzc3dvcmq= >>> print base64.b64decode("cgfzc3dvcmq=") password

javascript - Problem with switch -

i have code: var str = $("#datepicker").datepicker("getdate"); var datestr = str.tostring().split(" "); switch(datestr[1]) { case "jan": var datestrmon = "Яну"; break; case "feb": var datestrmon = "Фев"; break; case "mar": var datestrmon = "Мар"; break; case "apr": var datestrmon = "Апр"; break; case "may": var datestrmon = "Май"; break; case "jun": var datestrmon = "Юни"; break; case "july": var datestrmon = "Юли"; break; case "aug": var datestrmon = "Авг"; break; case "sep": var datestrmon = "Сеп"; break; case "oct": var dates...

java - How to find the distance between the two most widely separated nodes -

i'm working through previous years acm programming competition problems trying better @ solving graph problems. the 1 i'm working on i'm given arbitrary number of undirected graph nodes, neighbors , distances edges connecting nodes. need distance between 2 farthest nodes eachother (the weight distance, not # of nodes away). now, have dijkstra's algorithm in form of: // dijkstra's single-source algorithm private int cheapest(double[] distances, boolean[] visited) { int best = -1; (int = 0; < size(); i++) { if (!visited[i] && ((best < 0) || (distances[i] < distances[best]))) { best = i; } } return best; } // dijkstra's continued public double[] distancesfrom(int source) { double[] result = new double[size()]; java.util.arrays.fill(result, double.positive_infinity); result[source] = 0; // 0 distance ...

signal processing - An implementation of the fast Fourier transform (FFT) in C# -

where can find free, quick, , reliable implementation of fft in c#? that can used in product? or there restrictions? aforge.net free (open-source) library fast fourier transform support. (see sources/imaging/ compleximage.cs usage, sources/math/ fouriertransform.cs implemenation)

subclipse - Modified directory structure in project, now SVN won't allow me to commit. -

i using svn repository hold revisions project. half way through (having commited several times) changed directory structure of project, , renamed files. now when try , commit tells me path old file (that renamed, , moved) not found. person working on project, changes make working copy changes. using subclipse manage project. how can commit modified project? when renamed , moved things around, did use subversion commands rename , move, or did change things around on local filesystem? normally subversion expects told you're moving things around, otherwise has no way of knowing did.

untagged - Worst technobabble you've ever heard -

following egregious pop culture perversion of programming , outlandishly insane technobabble have ever heard, either in fiction or real life? extra points unfortunates real life stories beat hollywood. note: feel free sketch out necessary such gibberish work. an engineer @ sgi told me customer called in complain "circle mode" on external cdrom not working. said "tell me more circle mode". said, "well, there's switch on line , circle. works in line mode, not in circle mode." engineer told "just leave in line mode, circle mode hasn't been implemented yet."

model view controller - Should new web applications follow the MVC or MVP pattern? -

note not asking choose (mvc or mvp), rather if 1 of 2 should used web application. i realize might work convert older application current design mvc or mvp pattern. however, new app? appears these popular architecture patterns, should 1 of these chosen? if not, other patterns there? if not familiar mvc and/or mvp, question check out "what mvp , mvc , difference?" . has many answers, including links various websites break down each one. mvp / mvc works in web applications because http verb + url combination way determine action take. there reasons not use it, such if team has lot of experience framework, recommend mvp / mvc framework. application finished quicker higher quality.

android emulator - Problem while creating table with sqLite -

i created 1 demo in android regarding database. while executing facing problem. can 1 please me. here code developed. package com.android; import android.app.activity; import android.database.cursor; import android.database.sqlite.*; import android.os.bundle; import android.util.log; import android.widget.textview; public class databasework extends activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); string my_database_name="trademarket"; string my_database_table="shares"; string data="database"; sqlitedatabase mydb=null; try{ mydb=this.openorcreatedatabase(my_database_name,mode_private, null); mydb.execsql("create table if not exist" + my_database_table + "(lastname varchar,firstname varchar,country varchar,age int(3));"); /* code insert data in databse*/ mydb.execsql("in...

assemblies - How to determine if an assembly is in use? -

how can tell if assembly in use process? here's answer in powershell if ( get-process | ? { $_.modules | ? {$_.modulename -eq "assemblyname.dll" } }) { "in use" }

bit manipulation - Retain Data from 27 bit to 19 bit conversion -

i have access control solution 27 bit format 13 bits facility code , 14 bits badge id. conversely, need convert 8 bits facility code , 16 bits badge id. what largest number can convert on 27 bit side same result using 8 bit facility code size? meaning, if have 13 bits facility code, how many bits can chop off still same result , 8 bit size? if facility code never greater 255, can chop off 5 significant bits (i.e. keep 8 least significant ones), without losing information.

What's the strangest corner case you've seen in C# or .NET? -

i collect few corner cases , brain teasers , hear more. page covers c# language bits , bobs, find core .net things interesting too. example, here's 1 isn't on page, find incredible: string x = new string(new char[0]); string y = new string(new char[0]); console.writeline(object.referenceequals(x, y)); i'd expect print false - after all, "new" (with reference type) always creates new object, doesn't it? specs both c# , cli indicate should. well, not in particular case. prints true, , has done on every version of framework i've tested with. (i haven't tried on mono, admittedly...) just clear, example of kind of thing i'm looking - wasn't particularly looking discussion/explanation of oddity. (it's not same normal string interning; in particular, string interning doesn't happen when constructor called.) asking similar odd behaviour. any other gems lurking out there? i think showed 1 before, fun here - took debugging...

unit testing - What is the code-coverage percentage on your project? -

what % code-coverage on project? i'm curious reasons why. is dev team happy it? if not, stands in way increasing it? stuart halloway 1 projects aim 100% (or else build breaks!). @ level? we @ painful 25% aspire 80-90% new code. have legacy code have decided leave alone evaporates (we actively re-writing). we run @ 85% code coverage, falling below not break build. think using code coverage important metric dangerous practice. because covered in test not mean coverage good. try use guidance areas weakly covered, not hard fact.

installer - WiX script with only Welcome and Completed screens -

i need wix 3 script display display 2 dialogs: welcome & completed. thats no need eula, folder selection etc. appreciated. all need add in wix script, give welcomedlg before installation , show installation progress, exit dialog. don't forget add wixuiextension.dll references. <ui id="userinterface"> <property id="wixui_installdir" value="targetdir" /> <property id="wixui_mode" value="custom" /> <textstyle id="wixui_font_normal" facename="tahoma" size="8" /> <textstyle id="wixui_font_bigger" facename="tahoma" size="9" bold="yes" /> <textstyle id="wixui_font_title" facename="tahoma" size="9" bold="yes" /> <property id="defaultuifont" value="wixui_font_normal" /> <dialogref id="progressdlg" /> <dialogref id=...

sql server - How to update a record without changing rowversion -

if table has rowversion column in , make update row, value of rowversion column increases. know design , purpose of rowversion columns, there way make such update operation have no effect on rowversion value? edit: tracking of updates on columns required, there operations avoid being perceived new versions. no. see msdn . "every time row rowversion column modified or inserted, incremented database rowversion value inserted in rowversion column."

ruby on rails - Could I improve this method with duck typing? -

hopefully haven't misunderstood meaning of "duck typing", i've read, means should write code based on how object responds methods rather type/class is. here's code: def convert_hash(hash) if hash.keys.all? { |k| k.is_a?(integer) } return hash elsif hash.keys.all? { |k| k.is_a?(property) } new_hash = {} hash.each_pair {|k,v| new_hash[k.id] = v} return new_hash else raise "custom attribute keys should id's or property objects" end end what want make sure end hash keys integer representing id of activerecord object. don't particularly enjoy having iterate through hash keys twice all? determine if need grab id's out. of course, i'll accept other suggestions improve code :) how write method should depend on whether expect exception thrown during course of normal program execution. if want readable exception message because end-user might see it, throwing 1 manually makes sense. otherwise, i...

ruby on rails - select_tag multiple and partials -

i'm having problem pesky select_tags, can them show data fine on new when comes edit, don't show up, here code have @ moment. think need use include? don't know put it. this have @ moment new <% @data = code.find(:all, :conditions => "section = 'location'") %> <%= select_tag "candidate[code_ids][]", options_for_select(@data.map{|d| ["#{d.value}",d.id]}), :multiple => true %> and edit <% @data = code.find(:all, :conditions => "section = 'location'") %> <%= select_tag "candidate[code_ids][]", options_for_select(@data.map{|d| ["#{d.value}",d.id]},@found), :multiple => true %> in controller have grabs of codes related candidate. @results = candidate.all :joins => "left join candidates_codes on candidates.id = candidates_codes.candidate_id", :conditions => ["candidates.id = ?", params[:id]], :select =...

php - $c = mysql_num_rows(mysql_query($q)); -

i wondering if this $c = mysql_num_rows(mysql_query("select * action_6_weekly code='$code'")); is considered valid php? or need following? $r = mysql_query("select * action_6_weekly code='$code'"); $c = mysql_num_rows($r); this doing: if($entry == '9') $c = mysql_num_rows(mysql_query("select * action_6_5pts code='$code'")) or die ('mysql error: '.mysql_error().' in '.__file__.' on '.__line__.'.'); elseif($entry == 'a') $c = mysql_num_rows(mysql_query("select * action_6_10pts code='$code'")) or die ('mysql error: '.mysql_error().' in '.__file__.' on '.__line__.'.'); else $c = mysql_num_rows(mysql_query("select * action_6_weekly code='$code'")) or die ('mysql error: '.mysql_error().' in '.__file__.' on '.__line__.'.'); if($c > 0) $waiting_for_reply = fa...

winapi - Reading Values from Windows Resource (.res) Files -

all. know if there way read out values in compiled resource (*.res) file. familiar reading resources executable, , i'm wondering if there similar way read out resources resource file. in advance! the windows functionality dealing res files deals them exclusively embedded resources. typically application ship localized resources contained in resource dlls. loadlibraryex takes flags load_library_as_datafile used prevent dlls dllmain being called. the you're going microsoft wrt loading res files directly this msdn page if manipulation of resources want beginupdateresource updateresource, endupdateresource api can use inject (or modify) version resource in existing dll.

Mandatory cloneable interface in Java -

i'm having small problem in java. have interface called modifiable. objects implementing interface modifiable. i have modifycommand class (with command pattern) receive 2 modifiable objects (to swap them in list further on - that's not question, designed solution already). the modifycommand class starts making clones of modifiable objects. logically, made modifiable interface extends cloneable. interface defines clone() method implementing classes must redefine. then, in modifycommand, can : firstmodifiableobject.clone(). logic classes implementing modifiable have redefine clone method object, cloneable (that's want do). the thing is, when define classes implements modifiable , want override clone(), won't let me, stating clone() method object class hides 1 modifiable. what should do? i'm under impression "i'm doing wrong"... thanks, guillaume. edit : think forget clone() thing. either a) assume object passed modifiable object (impl...

javascript - What is the best practice to not to override other bound functions to window.onresize? -

how dig javascript, find myself asking much. example have window.onresize event handler , if say: window.onresize = resize; function resize() { console.log("resize event detected!"); } wouldn't kill other functions connected same event , log message in console? if think there should notifier tells me window resize event - or workaround maybe - without overriding other functions bound same event. or totally confused usage? you can save old onresize function , call either before or after custom resize function. example should work this: var oldresize = window.onresize; function resize() { console.log("resize event detected!"); if (typeof oldresize === 'function') { oldresize(); } } window.onresize = resize; this method can have issues if there several onresize functions. save old onresize function part of closure , call old 1 after function. function addresizeevent(func) { var oldresize = window.onres...

rotation - iPhone navigation bar height remains short in portrait orientation -

my app's root view controller supports orientation user can navigate view controller supports landscape orientation. the basic problem regardless of device's actual physical orientation, when user pops root view controller, navigation bar has height appropriate landscape mode. figure out how navigation bar appear height of 44 (portrait height) instead of 32 (landscape height). although navigation bar not set proper height, root view controller's uitableview offset correctly (44 pixels top of screen). inside second view controller's -viewwillappear: perform standard rotational transform: if (deviceorientation == uideviceorientationportrait) { uiscreen *screen = [uiscreen mainscreen]; cgfloat screenwidth = screen.bounds.size.width; cgfloat screenheight = screen.bounds.size.height; uiview *navview = [[self navigationcontroller] view]; navview.bounds = cgrectmake(0, 0, screenheight, screenwidth); navview.transform = cgaffinetransformidentity...

php - Can anyone show me a good source to learn web services? -

i don't know thing web services, except used allow application share functions. where & how start? does book on web services work me if use php programming language? does know irc channel help? does know of directory tutorials beginner? is complicated? does take long time learn? i've used 2 books in past focus on web services , php. professional web apis php if want started using 3rd party apis (like amazon, google, ebay, etc.). has tons of example php code started. pro php xml , web services want if you're interested in implementing web services of own using php.

database - Mysql assigning default causes error -

i trying run below query create table in mysql , getting error. create table newtable ( version_id int(11) auto_increment not null, test_id int(11) default version_id, primary key(version_id) ); error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near 'version_id not null, primary key(version_id), unique key(test_id) )' @ line 1 i getting above error. i think problem setting test_id default version_id, because works otherwise. thank you bala -- update here wanted do, when create new row, want use version_id key. when update, want use value of existing record key. note test_id not primary key. i don't think can use "variables" defaults. have constants. if want effect, in stored procedure / trigger "before insert" such if trial_id not supplied gets assigned same value version_id... here's a tutorial might toward end. i think trigger li...

version control - git-svn: how do I create a new svn branch via git? -

i have git repository tracks svn repository. cloned using --stdlayout . i created new local branch via git checkout -b foobar now want branch end in …/branches/foobar in svn repository. how go that? (snipped lots of investigative text. see question history if care) i know question has been answered while ago, after reading it, might adding examples of specific git svn branch command , relate typical workflow. like kch answered, use git svn branch . here full example, (note -n dry-run test): git svn branch -n -m "branch authentication bug" auth_bug if goes well, server replies answer this: copying https://scm-server.com/svn/portal/trunk @ r8914 https://scm-server.com/svn/portal/branches/auth_bug ... and without -n switch server adds like: found possible branch point: https://scm-server.com/svn/portal/trunk => https://scm-server.com/portal/branches/auth_bug , 8914 found branch parent: (refs/remotes/auth_bug) d731b1f...

c# - Create 1bpp mask from image -

how create 1 bit per pixel mask image using gdi in c#? image trying create mask held in system.drawing.graphics object. i have seen examples use get/setpixel in loop, slow. method interests me 1 uses bitblits, this . can't work in c#, appreciated. try this: using system.drawing; using system.drawing.imaging; using system.runtime.interopservices; ... public static bitmap bitmapto1bpp(bitmap img) { int w = img.width; int h = img.height; bitmap bmp = new bitmap(w, h, pixelformat.format1bppindexed); bitmapdata data = bmp.lockbits(new rectangle(0, 0, w, h), imagelockmode.readwrite, pixelformat.format1bppindexed); (int y = 0; y < h; y++) { byte[] scan = new byte[(w + 7) / 8]; (int x = 0; x < w; x++) { color c = img.getpixel(x, y); if (c.getbrightness() >= 0.5) scan[x / 8] |= (byte)(0x80 >> (x % 8)); } marshal.copy(scan, 0, (intptr)((int)data.scan0 + data.stride * y), ...

c++ - When would I use uncaught_exception? -

what use case uncaught_exception? herb sutter seems give advice here . doesn't know of use , says cases appears useful don't work.

Simple C# regex question -

question : what's simplest way how test if given regex matches whole string ? an example: e.g. given regex re = new regex("."); want test if given input string has 1 character using regex re . how do ? in other words : i'm looking method of class regex works similar method matches() in class matcher in java ("attempts match entire region against pattern."). edit: question not getting length of string . question how match whole strings regular exprestions. example used here demonstration purposes (normally check length property recognise 1 character strings). if allowed change regular expression should surround ^( ... )$ . can @ runtime follows: string newre = new regex("^(" + re.tostring() + ")$"); the parentheses here necessary prevent creating regular expression ^a|ab$ not want. regular expression matches string starting a or string ending in ab . if don't want change regular expression can ch...

asp.net - How to write all the data in session to string[] also how to write the data in string [] to session -

i using asp.net . need copy session data (both session variables , session request variables) string [] . how can this? also need reverse condition. how can using serialization concepts serialization , deserialization should trick. you can here tutorial on serialization.

iphone - IBOutlet, use of member properties or not? memory leak? -

i have noticed memory usage of program wrote, keep increasing on time. xcode's instruments shows no memory leak, yet can see heap stack growing on time.. upon investigation, lot of memory usage come iboutlet ui objects. interface build interface builder. typical usage like: header: @interface helpviewcontroller : uiviewcontroller <uiwebviewdelegate> { iboutlet uiwebview *webview; iboutlet uibaritem *backbutton; iboutlet uibaritem *forwardbutton; nsstring *url; iboutlet uiactivityindicatorview *spin; } @property (nonatomic, retain) nsstring *url; and usage : - (void)webviewdidstartload:(uiwebview *)mwebview { backbutton.enabled = (webview.cangoback); forwardbutton.enabled = (webview.cangoforward); [spin startanimating]; } - (void)webviewdidfinishload:(uiwebview *)webview { backbutton.enabled = (webview.cangoback); forwardbutton.enabled = (webview.cangoforward); [spin stopanimating]; } looking @ heap st...

c# - Using related functions in one class -

i have class 2 related functions (methods): public class class1 { public void subscribetolistofevents() { // .... } public void unsubscribefromlistofevents() { // .... } } what's best practice use related functions in 1 class ? do know of implementations of related functions 1 function ? ? in situations ? if so, can hyou give me example? any available options of code above appreciated. if functions belong class, logically, fine way. a class should cohesive , methods operation should have mirror operation defined (subscribe/unsubscribe, add/remove etc...). you have named them well, descriptive of - how name merged one? better leave them separate, way self documenting , not confuse users of class.

asp.net - Translate a url to a route -

i feel i'm re-inventing wheel here, need find way of taking url catchall,and redirecting route. the reason because need things adding session cookies urls, , pass them on relevant action. what's best way of implementing this? thanks in advance help! you can try changing master page @ runtime. it's not beautiful solution though. theming support

osx - Delete line ending with a newline character in text file -

i need delete same line in large number of text files. have been trying use sed, cannot delete newline character @ end. following deletes line, not newline: sed -i -e 's/version:1//' *.txt i have tried using following delete newline also, not work: sed -i -e 's/version:1\n//' *.txt is there anyway specify newline in sed substitute command or there other command line tool can use achieve goal? thank you you can use sed command: sed -i -e '/version:1/d' for this. the following transcript gives example: pax> echo 'hello > goodbye > hello again' | sed '/oo/d' hello hello again you should check whether want match whole lines with, example: sed -i -e '/^version:1$/d' since, stands, delete lines following: version:10 conversion:1

performancecounter - What is the performance hit of Performance Counters -

when considering using performance counters companies' .net based site, wondering how big overhead of using them. do want have site continuously update it's counters or better off when measure? the performance impact negligible in updating. microsoft's intent write performance counters. it's monitoring of (or capturing of) performance counters cause degradation of performance. so, when use perfmon capture data. in effect, performance counter objects have effect of "doing when measure."

Draw the variable diagram for a C# linkedlist -

i'm facing real problem in understanding how draw variable diagram linked list in book i'm reading not giving enough info i post example: the insert: public void insert(object newitem, object after) { node current = new node(); node newnode = new node(newitem); current = find(after); newnode.link = current.link; current.link = newnode; } private node findprevious(object n) { node current = header; while(!(current.link == null) && (current.link.element != n)) current = current.link; return current; } public void remove(object n) { node p = findprevious(n); if (!(p.link == null)) p.link = p.link.link; } i've searched net more info each time found different info can please are trying draw out on paper homework? if so, link property of each node has reference next node in linked list. draw it, have series of boxes in row represent node classes. in each node, have 2 properties, item , lin...

How does openrasta work out the action for a page? -

i have 2 routes configured: resourcespace.has.resourcesoftype() .aturi("/patient") .and .aturi("/patient/cardid/{cardid}") .handledby() .asjsondatacontract() .and .renderedbyaspx("~/views/patient.aspx"); resourcespace.has.resourcesoftype() .aturi("/product") .and .aturi("/product/tagvalue/{tagvalue}") .handledby() .asjsondatacontract() .and .renderedbyaspx("~/views/product.aspx"); when using code using (scope(xhtml.form(resource).id("addpatientform").method("post"))) { for patient translate action to action="/patient" and product action="/product/tagvalue" what doing wrong? can h...