Posts

Showing posts from May, 2014

.net - Anyone using the Entity Framework *Well*? -

has shipped entity framework project o/r mapping conceptual classes quite different tables in datastore? i mean collapse junction (m:m) tables other entities form conceptual classes exist in business domain organized multiple tables in datastore. examples see on msdn have little use of inheritance, collapsing junction tables other entities, or collapsing lookup tables entities. i'd love hear of or see examples of below support crud operations typically expect on business object.: vehicle table , color table. color can appear in many vehicles (1:m). form conceptual class usedcar has property color. doctor, doctorpatients, , patients tables (form many many). doctors have many patients, patients can have many doctors (m:m). map out 2 conceptual classes doctor (which has patients collection) , patients (which has doctors collection). anyone seen/done csdl , ssdl in entity framework? csdl no if doesn't actaully map anything! i attempted use entity framewo...

python - Optimal extraction of columns from numpy matrix -

say have numpy matrix so: [[ x1, x2, x3, ... ], [ y1, y2, y3, ... ], [ z1, z2, z3, ... ], [ 1, 1, 1, ... ]] from want extract list of lists so: [[x1, y1, z1], [x2, y2, z2], [x3, y3, z3], ... ] what optimal way of doing this? at moment have: tpoints = [pt[:3].tolist() pt in numpy.asarray(tptmat.t)] and call tolist() taking disproportionate amount of time, approximately third of time spent in time consuming function of program. ncalls tottime percall cumtime percall filename:lineno(function) 14422540 69.777 0.000 69.777 0.000 {method 'tolist' of 'numpy.ndarray' objects} 20 64.258 3.213 178.057 8.903 trans.py:152(_apply) ... why not remove last row before transpose? m[:3].t.tolist() # ^^^^^^^^^ optional micro-benchmark shows method faster yours 61%, , if don't convert list of list 45 times faster, 100×4 matrix. $ python2.5 -m timeit -s 'import numpy; m = numpy.matrix([[5]*100,[6]...

Copy files on Windows Command Line with Progress -

does know of windows commmand-line ( available on xp pro or later default ) copy file while showing progress. not care if progress indicator in terminal or gui window. this intended used during batch file scripting used copy command /z switch copying on network drives, works copying between local drives. on xp home edition

html - Use iframe as a link? -

i using iframe , in iframe loading dynamic image. want use image link respective article. news site. i have used many stuffs like: <a href="whatever.."><iframe src="dynamic url"></iframe></a> does work ie not safari , ff. and some tweets div.iframe-link { position: relative; } a.iframe-link1 { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } code: <div class="iframe-link"> <iframe src="file" width="90px" height="60px" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowtransparency="true" noscaling="true"> </iframe> <a href="url" target="_top" class="iframe-link1"></a> </div> worked in ff , safari not in ie7,8. so can suggest do.. any appreciated. the iframe loading dynamic address ...

c# - Could not find file ..\bin\Debug\content.dat -

i have added file content.dat in visual studio project @ same location there form1.cs when try read or write file getting error could not find file '...\bin\debug\content.dat'. why trying search in bin\debug? need put file can read/write later need create installer this, reference path distub again? presumably it's because you're running in bin\debug - that's application being launched. one option set build action file "content" copy output directory along executable. edit: hans pointed out, should set "copy output directory" property "copy always" or "copy if newer".

Wrap an Oracle schema update in a transaction -

i've got program periodically updates database schema. sometimes, 1 of ddl statements might fail , if does, want roll changes. wrap update in transaction so: begin tran; create table (pkey int not null identity, newfieldkey int null, constraint pk_a primary key (pkey)); create index a_2 on (newfieldkey); create table b (pkey int not null identity, constraint pk_b primary key (pkey)); alter table add constraint fk_b_a foreign key (newfieldkey) references b (pkey); commit tran; as we're executing, if 1 of statements fail, rollback instead of commit. works great on sql server, doesn't have desired effect on oracle. oracle seems implicit commit after each ddl statement: http://www.orafaq.com/wiki/sql_faq#what_are_the_difference_between_ddl.2c_dml_and_dcl_commands.3f http://infolab.stanford.edu/~ullman/fcdb/oracle/or-nonstandard.html#transactions is there any way turn off implicit commit? you can not turn off. easy work around designing scripts dro...

drupal filterable/sortable table from existing data -

i have existing database holds information upcoming meetings in organization. able display information in datatable type of format upon can filter , sort information (possibly jquery sort). can point me kind of tutorial give me idea of how this? assume can cck , views, i'm not sure involved. thanks views handle data manipulation (like filtering , sorting) might want do; , views 3 can utilize backend datasource (previously, needed use drupal's database). if want robust , not one-time import, views way go. the trick going learning views api , writing module. api documentation stored in advanced help module; in addition that, you'll need learn how views 3 handles third-party datasources. there isn't documentation yet (views 3 still in alpha) if @ apache solr views (which uses solr backend) , extendr (which uses flickr views backend) can parse how they're doing it. extendr more geared proof-of-concept, might easier parse.

silverlight - Getting at the Listbox's ItemContainer when data binding -

is there way @ itemcontaner of selected item in listbox? in silverlight 2.0 beta 1 could, container hidden in beta 2 of silverlight 2.0. i'm trying resize listbox item when unselected specific size , when selected variable size. want relative position of selected item animations. growing variable size , getting relative pasition why need listbox item. i should clarify i'm not adding items listbox explicitly. using data binding in xaml , datatemplates. have trouble accessing itemcontainer of selected item's datatemplate. there way obtain panel containing item's uielement , mapping of items uielements. have inherit listbox (this works itemscontrol) , override preparecontainerforitemoverride: protected override void preparecontainerforitemoverride(dependencyobject element, object item) { base.preparecontainerforitemoverride(element, item); var el = element frameworkelement; if (el != null) { // here e...

sql server - SQL Error OLE.INTEROP -

i'm getting error whenever load management studio or open folder in server explorer, etc. additionally, if try create new database updating , not finish. have attached screenshot of error. please let me know can fix because it's aggravating. error screen http://frickinsweet.com/databaseerror.gif from msdn forum http://forums.microsoft.com/msdn/showpost.aspx?postid=120476&siteid=1

Is it possible to embed and use a portable executable in a .net DLL? -

the easiest way think of question think of single, simple unix command (albeit, windows) , need progmatic access run it. i have single command-line based executable performs unit of work. want call executable .net process library, can other executable. however, dawned on me there potential dll become useless or break unintended updates executable or non-existant executable. is possible run executable process object in .net framework, external executable file? no, can't execute directly. unpack temporary directory , execute there.

php - File downloads incomplete over slow connection -

i have 15mb file on website (apache webserver) downloads fine on reasonable speed connections, incomplete on slower connections (28kbytes/sec, example). size of incomplete file random, 2 13 mb. have verified behavior in both safari , firefox, on connection negligible latency. neither browser indicates user file incomplete, size smaller 15mb. have tried downloading via direct link , via php download script proper headers: same results. has else experienced kind of issue? if use php script sending file run phps script limit on large downloads. see php.ini max_execution_time. so don't want read file php , echo browser. instead redirect browser file.

eclipse - Cannot be resolved or is not a field (Notepad exercises from android dev website) -

i'm running through notepad exercises on android dev website, working on exercise (found here ). i came end of tutorial , found had several errors in main 2 java files regarding r file relations, such setcontentview(r.layout.notes_list); , menu.add(0, insert_id,0, r.string.menu_insert); i've tried cleaning , re-genning r.java no avail. these occur in solution exercise think deliberate mistakes, or eclipse, can't seem fix them, great thanks! do have layout notes_list.xml in layout folder? have string name of menu_insert in strings.xml? might issue, because think don't give in tutorial... have them in solution : <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <listview android:id="@+id/android:list" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <textview android:id="@+id/android:empty" android:layout_width=...

git hooks bash -- getting the commit message -

i writing git hook, run on commit main branch. need parse , text in the commit message. how reference commit message in bash script? also know how run hook on commits main branch. developers can quash there local commits , commit main branch when have fixed bug or something. please , thank you. the answer depends on you're trying commit message. there 3 hooks asking about: prepare-commit-msg run after default message prepared, before user edits it. first argument name of file commit message. (the second argument indicates message came from.) commit-msg run after commit message edited/finalized, before commit takes place. if want fail commit if user's commit message bad, or modify message, want this, , single argument name of file commit message. post-commit run after commit. has no arguments, can of course message git log -n 1 head (probably --format=format:%s%n%b or such). if want in message, , notify based on it, should use this. all of material...

iphone - How to make image Disappear on touching it? -

i working on apllication iphone in xcode 3.1. i want similar 2 images disappear when touched 1 after other. i have succeed in displaying 2 images on iphone simulator on touching 'play' button. now want when 2 same images 'touched' 1 after another,they should disappear. expect code in objective c. you can this, using simple animations view should disappear, later can cast context inside uiview animations delegate , start second animation. aview.alpha = 1.0; [uiview beginanimations:nil context:@"context1"]; [uiview setanimationduration: 1.0]; [uiview setanimationcurve: uiviewanimationcurveeaseout]; [uiview setanimationbeginsfromcurrentstate:yes]; aview.alpha = 0.0; [uiview commitanimations]; this id delegate method should implement: -animationdidstop:(nsstring *)animationid finished:(nsnumber *)finished context:(void *)context

vba - word: DoCmd.SetWarnings FALSE -

i getting object required on error on this anyone know whats going on ? private sub commandbutton1_click() docmd.setwarnings false module1.transfershipper end sub docmd not exist in word object model. if provide more context might find other options trying do.

performance - How most popular media rich websites implement their media library? -

i'm wondering how popular media rich websites implement media library. store media files in database? kind of database use? employ other mechanism boost performance? thanks response. you asking difficult question answer. i recommend introductory read check out youtube architecture on high scalability . youtube real-life example of how media-centric website works. surprising may be, serving actual media files not bottleneck. harder part getting media meta-data synched, generating thumbnails, etc. media files can hosted cluster, or cdn in case of extremely popular video. read link more in-depth info.

c - How can I get an error stream over a socket in Java? -

i'm writing work around java bug: http://bugs.sun.com/view_bug.do?bug_id=5049299 basically, i've got light weight c server runs on same machine java server. i'm adding feature c server when can request fork/run new process via socket , pass stdin/stdout/stderr. on java side, i've created mimics behavior of processbuilder , runtime.exec() , on socket. the problem arises stderr . java sockets don't have error stream, i'm @ bit of loss how over. i've come 2 potential solutions: create second socket (probably c server java server) in send stderr over. interleave output of process stderr of process , parse them apart in java separate streams both solutions have inherent problems, i'd love hear feedback has. bonus: give me easy, guaranteed solution java bug doesn't involve me doing of , i'll best friend forever. to solve this, took advantage of fact 2 servers running on same machine. merely wrote stderr file read in oth...

osx - "Beautifying" an OS X disk image -

when downloaded skype, noticed that, in place of normal "disk image" icon, there custom icon, , when double clicked on icon, window used colorful image background, prompting me drag skype icon applications folder. how can applications? thanks, jason let me add other answers jwz's howto on setting view options on .dmg files. simplest 1 got work no problems. also, change icon default .dmg icon: in finder, open inspector window (^i) file icon want use, click on icon @ top (it blue border) , copy clipboard (^c). then open inspector .dmg, click on icon , press ^v paste (you can change icon file this). for kind of thing, can @ open-source programs , see similar result. example here relevant source files building pretty dmg files in: adium miro

jquery next by class fade out -

<div id="formheadtop"> <input class="checkbox" type="checkbox" /></div><div class="formbody"></div> <div id="formheadtop"> <input class="checkbox" type="checkbox" /></div><div class="formbody"></div> <div id="formheadtop"><input class="checkbox" type="checkbox" /></div><div class="formbody"></div> $(function() { $('input:checkbox').live('click', function () { if ( $(this).attr('checked') == true ) { $(this).nextall('.formbody:first').fadein(); } else { $('.formbody').fadeout(); }; }); the code doesn't work. want fade out next div.formbody. first we'll need change id="formheadtop" class="formheadtop" , since id s must unique. can use code fade in , out div s: jquery $(document).ready(...

php - Why the remote validation doesn't work? -

i follow demo http://jquery.bassistance.de/validate/demo/marketo/ , met problems achieve same remote validation function. here html used. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/2000/rec-xhtml1-200000126/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>subscription signup | marketo</title> <!--http://jquery.bassistance.de/validate/demo/marketo/--> <link rel="stylesheet" type="text/css" media="screen" href="css/stylesheet.css" /> <script type="text/javascript" src="js/jquery/jquery-1.4.2.js" ></script> <script type="text/javascript" src="js/jquery/jquery.validate.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#profileform...

sql server - Text Qualifier in flat file connection -

i have business scenario source files (text files) comes load sql database used flat file connection manager normal process. my requirement as, getting source files qualifier (") used text qualifier property in connection manager. for same set of files getting without text qualifiers in files there ssis packages failing. here need information on ssis package handle files if text qualifier exists in source data need eliminate while loading if text qualifier not exist in source load data normal process could implement both scenarios in same package. thanks prav you pre-process files using powershell. there's article here talking how implement file wide replace. of course if you're comfortable writing vb.net implement same thing in scripting task in package.

javascript - What is console.log in jQuery? -

possible duplicate: what console.log used in jquery? what console.log ? used in jquery? jquery , console.log unrelated entities, although useful when used together. if use browser's built-in dev tools, console.log log information object being passed log function. if console not active, logging not work, , may break script. check console exists before logging: if (window.console) console.log('foo'); the shortcut form of might seen instead: window.console&&console.log('foo'); there other useful debugging functions well, such debug , dir , error . firebug's wiki lists available functions in console api .

class - java package cycle detection: how to find the specific classes involved? -

what tool recommend detect java package cyclic dependencies , knowing goal list explicitly specific classes involved in detected 'across-packages cycle' ? i know classycle , jdepend , both fail list classes involved in cyclic package dependency. metrics has interesting graphical representation of cycles, again limited packages, , quite difficult read sometime. i getting tired a: " have package cycle dependency between 3 packages you have xxx classes in each good luck finding right classes , break cycle " do know tool takes step explain why cycle detected (i.e. 'list involved classes') ? riiight... time proclaim results: @l7010.de thank effort. vote (when have enough rep), 'cap' answer... cap dead in water , no longer compatible eclipse 3.4. rest commercial , freeware @daniel6651 thank but, said, freeware (sorry not have mentioned in first place) @izb frequent user of findbugs (using latest 1.3.5 right now), 1 click...

c++ - Does pop_back() really invalidate *all* iterators on an std::vector? -

std::vector<int> ints; // ... fill ints random values for(std::vector<int>::iterator = ints.begin(); != ints.end(); ) { if(*it < 10) { *it = ints.back(); ints.pop_back(); continue; } it++; } this code not working because when pop_back() called, it invalidated. don't find doc talking invalidation of iterators in std::vector::pop_back() . do have links that? the call pop_back() removes last element in vector , iterator element invalidated. pop_back() call not invalidate iterators items before last element, reallocation that. josuttis' "c++ standard library reference": inserting or removing elements invalidates references, pointers, , iterators refer following element. if insertion causes reallocation, invalidates references, iterators, , pointers.

asp.net - AJAX for Visual Studio 2010 -

i download ajaxcontroltookit.binary4 file codeplex there installer install ajax 4 visual studio 2010. give me links these things need, please extract file location, c:\ajax open vs 2010 open toolbox (go view --> toolbox if can't see it) right click inside toolbox, add new tab, ajax controls toolkit open new tab created, right click inside it, click choose components click browse, , select .dll file c:\ajax

c++ - Does every Linux distro ship with gcc/g++ 4.* these days? -

i'm considering dumping boost dependency... atm thing need shared_ptr<> , , can std::tr1 , available in gcc suite 4.* afaik, of distros package v 4.+ nowadays.

c++ - Reading data from a log file as a separate application is writing to it -

i monitor log file being written application. want process file line line as, or shortly after, written. have not found way of detecting file has been extended after reaching eof. the code needs work on mac , pc, , can in language, though familiar c++ , perl. does have suggestion best way it? in perl, file::tail module need.

database - ID-ing Deadlocks in a Thread using Firebird -

developer looking best method identify deadlock on specific transaction inside specific thread. getting deadlock errors these general in fb 2.0 deadlocks happening , leading breakdowns in db connection between client , db. we send live ( once second) data db. we open thread pool of around 30 threads , use them ingest data ( 1-2 kb each second). sometimes db can take use next thread in pool keep stream current possible. on occasion produces deadlock in addition reaching max thread count , breaking connection. so need opinions on if best method ingest amount of data every second. have 100 on these clients hitting db @ same time. average transactions 1.5 1.8 million per day. i don't know of specific way identify particular thread or statement. i've had deal fb deadlocks many times. have 2 theads trying update same row in table doing in separate transactions. the best solution i've found design things threads never have update row other thread ...

wxhaskell - Keep track of the program variables in Haskell like imperative programs -

i'm having hard time finding out how make change every time user interacts program. it's hard explain here's example (haskell + wxhaskell): simulate :: int -> frame () -> io () simulate qnr window = fdata <- readfile "qarchive" case (split (listtake (split fdata '\n') qnr 0) '#') of (qst:a:b:c:coralt:answer:x) -> -- gui controls initialization (buttons,text,etc...) nextbutton <- button window [text := "next question ->", on command := set infofield [text := "next question"], position := pt 185 155] return () main :: io () main = start gui gui :: io () gui = window <- frame [text := "question program", clientsize := sz 640 480] headertext <- statictext window [text := "title text", fontsize := 20, position := pt 5 5] simulate 0 window return () i want widgets change when "next question" button pressed. want change these widgets values read file. how...

objective c - Xcode/LLDB: How to get information about an exception that was just thrown? -

ok, imagine breakpoint in objc_exception_throw has triggered. i'm sitting @ debugger prompt, , want more information exception object. find it? the exception object passed in first argument objc_exception_throw . lldb provides $arg1 .. $argn variables refer arguments in correct calling convention, making simple print exception details: (lldb) po $arg1 (lldb) po [$arg1 name] (lldb) po [$arg1 reason] make sure select objc_exception_throw frame in call stack before executing these commands. see "advanced debugging , address sanitizer" in wwdc15 session videos see performed on stage. outdated information if you're on gdb, syntax refer first argument depends on calling conventions of architecture you're running on. if you're debugging on actual ios device, pointer object in register r0 . print or send messages it, use following simple syntax: (gdb) po $r0 (gdb) po [$r0 name] (gdb) po [$r0 reason] on iphone simulator, function argument...

How can I convert a Python datetime object to UTC? -

i have python datetime object convert utc. planning output in rfc 2822 format put in http header, not sure if matters question. found information on site converting time objects, , looks simpler way, time want use datetime objects, because using timedeltas adjust them: i tried this: from datetime import datetime, timedelta = datetime.now() fiveminuteslater = datetime.now() + timedelta(minutes=5) fiveminuteslaterutc = ??? nothing in time or datetime module looks me. seems may able passing datetime object through 3 or 4 functions, wondering if there simpler way. i prefer not use third-party modules, may if reasonable choice. from datetime import datetime, timedelta datetime.utcnow() + timedelta(minutes=5)

c# - Expose my program to other programs -

i'm messing idea of writing small program mirror output of video capture device. if buy video capture device can use 1 program @ time because device gets locked. instead of buying second capture card id write program accept input capture device , expose output other applications. capture device----->program---->flash media encoder i've never done type of thing before. device driver related? can make program capture device other programs without digging in device driver dev? if point me in right direction great. can make program capture device other programs without digging in device driver dev? -no, i'm afraid not. you'd need that, write driver or capture source of own. make interface serve image multiple apps (what great idea!) need standardised, , you'd need other companies or developers use interface. again great idea you'd need agree on feature set - , each developer want new or different. (if talking particular/specific other...

python - Making text bold with django -

i have send make text bold in between plain text , send template view. this: i save string <b>textplaintext</b> in variable , return template. "<b>" tags not interpreted. how can make text bold in django view? making text bold shouldn't done in view. indeed, view should not take care of formatting (which role of templates). can however, adding variable rendering context, , depending on value, make text bold or not in template. for example : in view : #... is_important = true if else false extra_context.update({'is_important': is_important}) #... in template : ... {% if is_important %}<bold>{{ text_to_render }}</bold>{% else %}{{ text_to_render }}{% endif %} ... but more generally , deciding if text bold or not, not formatting, rather styling , should not made in template (so shouldn't use < bold> markup). suggest : ... <span {% if is_important %}class="is-important"{% endif %}>...

What is the best way to go in the long term: C, Objective C, or C++? -

one thing i've been meaning c++ programming not sure if should go c++ (which have basic console programming knowledge) or should c or objective c? i'm looking @ long term ease of coding such editors, compilers, etc quickest set , running. to go along that, software suggest working suggested language? [edit] some people mentioned hard suggest when not known doing. don't have specific program in mind @ moment, i'm looking @ starting 1 of these 3 languages either long-term investment , work or jumping point else. i can speak of c , c++. learning either wouldn't hurt, if reason legacy code in c , c++. pure c option operating systems, driver development, or embedded development environments. other uses include times when performance critical-- want "close" internals of machine possible. never hurts know c because these applications of don't seem going away anytime soon. c "lingua franca" lot of *nix applications. if want contr...

How to write an RSS feed with Java? -

i'm using java, , need generate simple, standards-compliant rss feed. how can go this? i recommend using rome : // feed header syndfeed feed = new syndfeedimpl(); feed.setfeedtype("rss_2.0"); feed.settitle("sample feed"); feed.setlink("http://example.com/"); // feed entries list entries = new arraylist(); feed.setentries(entries); syndentry entry = new syndentryimpl(); entry.settitle("entry #1"); entry.setlink("http://example.com/post/1"); syndcontent description = new syndcontentimpl(); description.settype("text/plain"); description.setvalue("there text in here."); entry.setdescription(description); entries.add(entry); // write feed xml stringwriter writer = new stringwriter(); new syndfeedoutput().output(feed, writer); system.out.println(writer.tostring());

mysql - Undefinable problem with my Zend Framework based site -

lately had reinstall development site on ubuntu machine since system crashed after os update. 4 days later site still not running should. whenever action has in action on database, stops working. for example when registring new user, following error: [sun jul 25 20:07:20 2010] [error] [client 127.0.0.1] php notice: trying property of non-object in /var/www/nrka2/application/bootstrap/bootstrap.php on line 169, referer: http://nrka2/user/register [sun jul 25 20:07:20 2010] [error] [client 127.0.0.1] php stack trace:, referer: http://nrka2/user/register [sun jul 25 20:07:20 2010] [error] [client 127.0.0.1] php 1. {main}() /var/www/nrka2/public/index.php:0, referer: http://nrka2/user/register [sun jul 25 20:07:20 2010] [error] [client 127.0.0.1] php 2. require() /var/www/nrka2/public/index.php:2, referer: http://nrka2/user/register [sun jul 25 20:07:20 2010] [error] [client 127.0.0.1] php 3. zend_application->bootstrap() /var/www/nrka2/application/application.php:23, re...

java - Unit testing a JAX-RS Web Service? -

i'm looking ways create automated tests jax-rs (java api restful web services) based web service. i need way send inputs , verify expected responses. i'd prefer via junit, i'm not sure how can achieved. what approach use test web-services? update: entzik pointed out, decoupling web service business logic allows me unit test business logic. however, want test correct http status codes etc. jersey comes great restful client api makes writing unit tests easy. see unit tests in examples ship jersey. use approach test rest support in apache camel , if interested test cases here

java - Automated IllegalArgumentException message? -

i check arguments of public functions , throw exceptions when something's wrong. (for private helpers use assertions). like this: if( < 0 || >= b ) throw new illegalargumentexception("'a' must greater or equal 0 , smaller b "); but annoys me write these error messages. message seems redundant me, message negation of statement a < 0 || >= b . it happens rename variable refactoring (in eclipse) , message not reflect changes. or change conditions , forget change messages. it great, if write like: assertargument(a >= 0 && < b); this should raise illegalargumentexception message "violated argument assertion: >= 0 && < b." in c write macro (actually in c assert macro). there simple way in java? thank you! in c language cannot use macros this, in cpp (the c preprocessor) can :-) if want there nothing restricts running cpp on java source before gets compiled. let use cpp st...

Create link in PHP with Get Parameters -

i'm new php, i'm working on simple web page. this page quite configurable different parameters. so, may called like: www.example.com/index.php?test=1&foo=3&bar=4 now question is, idiom generating link current page 1 parameter changed? for example, i'd change foo 5, what's easiest way generate link like: www.example.com/index.php?test=1&foo=5&bar=4 i can loop through , manually, figured there common idiom this. thanks ton! array_merge() you're looking for <a href="http://www.example.com/index.php?<?php echo http_build_query(array_merge($_get, array('foo' => 5)), '', '&amp;');?>">link text</a>

Hidden features of C -

i know there standard behind c compiler implementations, there should no hidden features. despite that, sure c developers have hidden/secret tricks use time. function pointers. can use table of function pointers implement, e.g., fast indirect-threaded code interpreters (forth) or byte-code dispatchers, or simulate oo-like virtual methods. then there hidden gems in standard library, such qsort(),bsearch(), strpbrk(), strcspn() [the latter 2 being useful implementing strtok() replacement]. a misfeature of c signed arithmetic overflow undefined behavior (ub). whenever see expression such x+y, both being signed ints, might potentially overflow , cause ub.

debugging - Reasons to NOT run a business-critical C# console application via the debugger? -

i'm looking few talking points use convince coworkers it's not ok run 24/7 production application opening visual studio , running app in debug mode. what's different running compiled console application vs. running same app in debug mode? are there ever times when use debugger in live setting? (live: meaning connected customer facing databases) am wrong in assuming it's bad idea run live configuration via debugger? you suffer reduced performance when running under debugger (not mention complexity concerns mentioned bruce ), , there nothing keep getting same functionality running under debugger when compiled in release mode -- can set program log unhandled exceptions , generate core dump allow debug issues after restarting app. in addition, sounds plain wrong manually managing app needs 24/7 availability. should using scheduled tasks or sort of automated process restarting mechanism. stepping bit, this question may provide guidance on influenc...

javascript - Traversing negative Array indeces in JScript -

i have sparse array in jscript, non-null elements occuring @ both negative , positive indices. when try use in loop, doesn't traverse array lowest (negative) index highest positive index. instead returns array in order added elements. enumeration doesn't work either. there method allow me that? example arrname = new array(); arrname[-10] = "a"; arrname[20] = "b"; arrname[10] = "c"; when looping through, should give me c b. technically, "a" isn't in array @ since can't have negative index. member of arrname object. if check arrname.length see 21 (0,1,2,...,20) why don't use plain object instead (as hashtable). should work: <script type="text/javascript"> //define , initialize object/hastable var obj = {}; obj[20] = 'c'; obj[10] = 'b'; obj[-10] = 'a'; // indexes , sort them var indexes = []; for(var in obj){ indexes.push(i); } indexes.sort(function(a,b){ retur...

android - Using clipRect - explanation -

public class pocii extends activity { myview mv = new myview(this); @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(mv); } } class myview extends view { public myview(context context) { super(context); } @override public void ondraw(canvas canvas) { paint paint = new paint(); canvas.drawrect(0,0,100,100, paint); canvas.cliprect(0,0,50,50); } } my question is, shouldn't above code draw rectangle , crop top left portion? rectangle not getting cropped. please explain cliprect does. clipping? clip in form of rectangle, given co-ordinates? if so, why above code not working? canvas. cliprect(left, top, right, bottom) reduces region of screen future draw operations can write to. sets clipbounds spacial intersection of current clipping rectangle , rectangle specified. there lot of variants of cliprect me...

struct - Does ANSI C support signed / unsigned bit fields? -

does make sense qualify bit fields signed / unsigned? the relevant portion of standard (iso/iec 9899:1999) 6.7.2.1 #4: a bit-field shall have type qualified or unqualified version of _bool, signed int, unsigned int, or other implementation-defined type.

UIKit.h and Foundation.h in Objective-C -

if import uikit.h automatically import foundation.h? uikit.h doesn't explicitly include it, wouldn't surprised if 1 of other uikit headers does. however, of files have anyway, because default pch (precompiled header, or header that's automatically added every file in project) comes this: #ifdef __objc__ #import <foundation/foundation.h> #import <uikit/uikit.h> #endif this means every file in iphone app automatically have foundation , uikit imported.

.net - Should I provide a deep clone when implementing ICloneable? -

it unclear me msdn documentation if should provide deep or shallow clone when implementing icloneable. preferred option? short answer: yes. long answer: don't use icloneable. because .clone isn't defined being shallow or deep clone. should implement own iclone interface, , describe how clone should work.

sql server - Migrate SQL2000 Database to SQL2005 on another machine -

i've been beating myself on head app migration few days now. have old mssql server 2000-backed application being upgraded windows 2003 server running smsql server 2005. know little sql server not enough. i tried backing database on old server going databases->[database]->all tasks->backup database..., selecting 'full', , saving file. moved backup file new server , tried restore complained saying looking [database].mdf file in location on old server. so tried export data, selected local sql 2000 database, pointed new sql 2005 database on other machine, , gets way end , dies complaining way 1 of tables being joined. i tried doing 'generate sql' command on 2000 box , running under sql 2005. looks there lot of outer joins using old *= syntax sql server 2005 doesn't support anymore and, being vendor database, have no idea true intentions when set these tables. is there other way can try migrating database over? the backup file has "...

SSRS 2005 help - need to get file size from within TSQL (path specified in column). Anyone? -

i need folder size , display info on report (ssrs). need number of databases (loop!). these db's websites' backends. has done before? can please point me samples or right direction? xp_filesize , right solution? help! looking @ question , tomalak's response, , i'm assuming reporting server able reach folders held in db: firstly set query result-set of paths - assume you'll have no trouble part. next you'll need add custom code function report: http://msdn.microsoft.com/en-us/library/ms155798.aspx - function take folder path parameter, , pass size of folder. you'll have write in vb.net if want embed code in report, or code dll , bring in. an example vb.net code block (remember may need prefix objects system.io.) http://www.freevbcode.com/showcode.asp?id=4287 public shared function getfoldersize(byval dirpath string, _ optional includesubfolders boolean = true) long dim lngdirsize long dim objfileinfo fileinfo dim objdir directory...

c++ - Compiling Quantlib via SWIG for C# -

anyone have experience using swig ? researching quantlib , saw c# code can generated using swig. exploring options create combined library of financial functions using quantlib , proprietary closed source library (which made available .net dlls). idea combine both of these create unified super library. have seen .net port of quantlib , seems not actively maintained (and not entirely sure of how ported), avoiding it. step 1 of evaluate difficulty in producing library can used 'anywhere' i.e. ms office applications ( via vba), console apps server-side (eg web apps). assume involves com interop, have no clue start or if on right track. i have no experience c++; , com (a buzzword me @ moment) have glazed over. aware of relevant msdn articles related topic. i looking along following lines: are there alternatives using quantlib in c#? with respect development environment, need? does know of ready-to-use quantlib c# library compiled via swig? (first prize = less work ...

math - In Python 2, what is the difference between '/' and '//' when used for division? -

is there benefit using 1 on other? in python 2, both seem return same results: >>> 6/3 2 >>> 6//3 2 in python 3.0, 5 / 2 return 2.5 , 5 // 2 return 2 . former floating point division, , latter floor division, called integer division. in python 2.2 or later in 2.x line, there no difference integers unless perform from __future__ import division , causes python 2.x adopt behavior of 3.0 regardless of future import, 5.0 // 2 return 2.0 since that's floor division result of operation. you can find detailed description @ https://docs.python.org/whatsnew/2.2.html#pep-238-changing-the-division-operator

c# - What interface or method should my class implement to print what I want in Console.WriteLine? -

i have object of class f. want output contents of object using console.writeline quick , dirty status updates this: console.writeline(objectf); this prints out name of class console: f i want overload somehow can instead print out useful information object , properties. i have workaround already: overload tostring method in class , call: console.writeline(objectf.tostring()); but rather have simpler syntax. ideas? console.writeline(objectf) should work, if overloaded tostring . when framework needs convert object string representation, invokes tostring . public override string tostring() { // replace line below code return base.tostring(); }

cmd - Windows scripting FOR command to rename all files in a directory -

i trying rename files present in windows directory using for command follows @ command prompt: for %1 in (*.*) ren %1 test%1 e.g. renames file enc1.ctl testenc1.ctl enc2.ctl testenc2.ctl thats not want. want enc1.ctl renamed test1.ctl enc2.ctl renamed test2.ctl how do that? @akelunuk: thanks, w kind of works have files names h263_enc_random_pixels_1.ctl , h263_enc_random_pixels_2.ctl want rename to test1.ctl , test2.ctl respectively then how? if know number of files, (say 10), can use for /l %1 in (1,1,10) ren enc%1.ctl test%1.ctl

c# - Pass multiple values to SQL insert statement -

i have web form has 23 textbox's , need pass function, has sql command insert values of 23 textbox table.. is there better way using dataset , sqldataadapter? becuase if not need pass 23 vlues in function like //function insert textbox values table public int createrecord(val1,val2,val3,....val23) { string query = "insert tablename values (.23 values...)"; sqlcommand command = new sqlcommand(query,connectionstring); .. } please suggest me atleast method or give link can solve problem.. if inserting record , 23 values necessary, there's not better way. however, it'd better use stored procedure , pass parameters stored procedure instead of using hardcoded sql in application, bad idea. something this: sqlcommand cmd = new sqlcommand("yourspname", conn); cmd.commandtype = commandtype.storedprocedure; // add parameters sp needs cmd.parameters.add(new sqlparameter("@parm1", parm1value)); cmd.parameters.add(new sqlpa...

caching - When does browser automatically clear cache of external JavaScript file? -

i have javascript resource has possibility of being edited @ time. once edited want propagated user's browser relatively (like maybe 15 minutes or so), however, frequency of resource being editing few , far between (maybe 2 month). i'd rather resource cached in browser, since retrieved frequently, i'd cache reset on browser @ semi-regular interval. i know can pass no-cache header when request resource, wondering when cache automatically reset on browser if did not pass no-cache. i imagine independent each browser, i'm not sure. i tried google this, of hits found clearing browser's cache... isn't i'm looking for. you may pass version string parameter url of script tag. parameter won't evaluated static javascript file force browser new version. if not want assign version string every time edited source may compute based on file system time stamp or subversion commit number: <script src="/script.js?time_stamp=1224147832156...

How do I remove a property from a JavaScript object? -

say create object follows: var myobject = { "ircevent": "privmsg", "method": "newuri", "regex": "^http://.*" }; what best way remove property regex end new myobject follows? var myobject = { "ircevent": "privmsg", "method": "newuri" }; like this: delete myobject.regex; // or, delete myobject['regex']; // or, var prop = "regex"; delete myobject[prop]; demo var myobject = { "ircevent": "privmsg", "method": "newuri", "regex": "^http://.*" }; delete myobject.regex; console.log(myobject); for interested in reading more it, stack overflow user kangax has written incredibly in-depth blog post delete statement on blog, understanding delete . highly recommended.

package - Confusion with a simple Scala packaging example -

i've been experiencing confusion on packaging classes in scala , importing packages. let me start pair of simple source files: file: a/a.scala package // of these imports should used? both seem work. //import a.b._ import b._ class { val fieldb = new b } file: a/b/b.scala package a.b class b usage compiling scalac works without complaint either of imports above in a.scala trying load these files in repl works differently: $ scala welcome scala version 2.8.0.r0-b20100714201327 (java hotspot(tm) server vm, java 1.6.0_20). type in expressions have them evaluated. type :help more information. scala> :l a/b/b.scala loading a/b/b.scala... <console>:1: error: illegal start of definition package a.b ^ defined class b scala> :l a/a.scala loading a/a.scala... <console>:1: error: illegal start of definition package ^ <console>:5: error: not found: value b import b._ ^ defined class scala> ...

iphone - UI Elements placed in IB appears shifted up in Simulator -

Image
i dont know if missing here when drop elements (uiimage or uilabel) in ib , run app in simulator, ui elements shifting little (snapping status bar if place them @ first blue hig line). looks setting overlooking. sound familiar? please help! added screenshot explain whats going on ... in interface builder alt text http://dl.dropbox.com/u/3093402/images/ib.png in simulator alt text http://dl.dropbox.com/u/3093402/images/simulator.png try this: select view in interface builder , in inspector, under “simulated user interface elements,” change status bar “gray.”

ajax - Improving BOSH Throughput -

i've implemented web chat system using jabber, tigase server , ajax-based client communicating on bosh using jsjac, apache mod_proxy forwarding http traffic tigase. works reasonably well, i've noticed 1 major gap in performance versus desktop jabber client (like exodus), particularly when joining multi-user chat long history of messages. specifically, monitoring http traffic, appears server can send 1 xmpp message per http request-response cycle. normal usage fine (we're getting 80-100msec round-trip times, isn't bad), when loading muc history can real drag. so question is: jabber or bosh provide mechanism bundling or streaming messages might apply use case? clients , servers out there implementing already? or have modify tigase , jsjac myself (which possible, not ideal)? actually, bosh server can collect many responses jabber server , send them 1 single response client. author of 1 such bosh library: http://code.google.com/p/node-xmpp-bosh/ . the re...

jquery - Fake loading/progress bar for slow non-Ajax page -

i'm developing site serves slow (up around 4 sec. loading time) pages due extensive database queries. in order let users know new page loading (also prevent multiple clicks), i'm displaying div fake loading bar on page users clicked link slow loading page. actually, showing fake loading div working good. dom of old page (with fake loading bar) still displayed when new page loading, means loading div shown until new page ready displayed. this how it's done. html part: <!-- link example execute javascript --> <a href="link/to/slow/page/" class="loading">slow page</a> <!-- full screen div gets displayed when clicking "loading" class link. --> <div id="dim" style="display:none; top:0; left:0; width:100%; height:100%; z-index:9999;"> <div id="loading"> <p>loading data, please wait...</p> <img src="loading.gif" alt="lo...

command line - Including all the jars in a directory within the Java classpath -

is there way include jar files within directory in classpath? i'm trying java -classpath lib/*.jar:. my.package.program , not able find class files in jars. need add each jar file classpath separately? using java 6 or later, classpath option supports wildcards. note following: use straight quotes ( " ) use * , not *.jar windows java -cp "test.jar;lib/*" my.package.mainclass unix java -cp "test.jar:lib/*" my.package.mainclass this similar windows, uses : instead of ; . if cannot use wildcards, bash allows following syntax (where lib directory containing java archive files): java -cp $(echo lib/*.jar | tr ' ' ':') (note using classpath incompatible -jar option. see also: execute jar file multiple classpath libraries command prompt ) understanding wildcards from classpath document: class path entries can contain basename wildcard character * , considered equivalent specifying list of...

Getting Height and Width of Image in Java without an ImageObserver -

i trying height , width of images (via url) in java without imageobserver. current code is: public static void main(string[] args) throws ioexception { // todo auto-generated method stub file xmlimages = new file("c:\\images.xml"); bufferedreader br = new bufferedreader(new filereader(xmlimages)); file output = new file("c:\\images.csv"); bufferedwriter bw = new bufferedwriter(new filewriter(output)); stringbuffer sb = new stringbuffer(); string line = null; string newline = system.getproperty("line.separator"); while((line = br.readline()) != null){ if(line.contains("http")){ url url = new url(line.) image img = toolkit.getdefaulttoolkit().getimage(url); sb.append(line + ","+ img.getheight(null) + "," + img.getwidth(null) + newline); } } br.close(); bw.write(sb.tostring()); bw.close(); } when go deb...