Posts

Showing posts from January, 2012

R - Sorting and Sub-setting Maximum Values within Columns -

i trying iteratively sort data within columns extract n maximum values. my data set first , second columns containing occupation titles , codes, , of rest of columns containing comparative values (in case location quotients had calculated each city) occupations various cities: *occ_code city1 ... city300* occ1 5 ... 7 occ2 20 ... 22 . . . . . . . . occ800 20 ... 25 for each city want sort maximum values, select subset of maximum values matched respective occupations titles , titles. thought relatively trivial but... edit clarification: want end sorted subset of data analysis. occ_code city1 occ200 10 occ90 8 occ20 2 occ95 1.5 at same time want able repeat sort column-wise (so i've tried lots of order commands through calling columns directly: data[,2]; able run same analysis functions on entire dataset. i've been...

c# - Filling GridView on some Button Click in MVC -

i working on project in classic asp.net, need migarate mvc right having page 1 button , gridview fill on clicking button. gridview has functionality edit, delete, paging, onrowcommand event. how should perform page through mvc. know gridview can't used in mvc, what's alternative of that. thanks consider using jquery grid plugin, like one. assume have figured out how populate view data, etc.

objective c - Sharing Non-Persistent Objects Between Contexts in Core Data? -

i wondering if there way share nsmanagedobject between 2 or more nsmanagedobjectcontext objects running in same thread. i have following problem: have 1 main context shared through code in application , several different contexts created each remote fetch request issue. (i created custom class fetches remotely , inserts objects found in server in own nsmanagedobjectcontext ). fetch requests may run simultaneously since use nsurlconnection objects may end @ different times. if same remote object gets fetched different connections, end duplicates @ moment of saving , merging context main one. (that is, objects have same remote id different objectid ). one possible solution save (and persist) every object created can't because may have relationships may still have not been filled , won't validate during save operation. i'm looking forward method allows share same non-persistent instance of object between context. if has encountered issue , came solution, pleased k...

html - ASP.Net <%# %> and <%= %> rules? -

can explain me rules around can , cannot evaluated/inserted markup using <%# %> , <%= %> tags in asp.net? when first discovered inject code-behind variables mark-up using <%= thought 'great'. discovered if such tags present can not add controls collection of page (that's whole different question!). <%# tags ok. is there way can inject code-behind variable or function evaluation page using <%# ? thanks. the <%# inline tag used data binding, if want use code-behind variable inside it, have bind page or control variable resides in: page.databind(); you can include statement in page_load or page_prerender event. see this article more information use of inline tags in asp.net, , this article more server-side databinding.

.net - Are CLR stored procedures preferred over TSQL stored procedures in SQL 2005+? -

my current view no, prefer transact sql stored procedures because lighter weight , (possibly) higher performing option, while clr procedures allow developers sorts of mischief. however have needed debug poorly written tsql stored procs. usual found many of problems due original developer developer having no real tsql experience, asp.net / c# focused. so, using clr procedures firstly provide more familiar toolset type of developer, , secondly, debugging , testing facilities more powerful (ie visual studio instead of sql management studio). i'd interested in hearing experience it's seems not simple choice. there places both well-written, well-thought-out t-sql , clr. if function not called , if required extended procedures in sql server 2000, clr may option. running things calculation right next data may appealing. solving bad programmers throwing in new technology sounds bad idea.

crash - core dump files on Linux: how to get info on opened files? -

i have core dump file process has file descriptor leak (it opens files , sockets apparently forgets close of them). there way find out files , sockets process had opened before crashing? can't reproduce crash, analyzing core file seems way hint on bug. if have core file , have compiled program debuging options (-g), can see core dumped: $ gcc -g -o something.c $ ./something segmentation fault (core dumped) $ gdb core you can use post-mortem debuging. few gdb commands: br prints stack, fr jumps given stack frame (see output of br). now if want see files opened @ segmentation fault, handle sigsegv signal, , in handler, dump contents of /proc/pid/fd directory (i.e. system('ls -l /proc/pid/fs') or execv). with these informations @ hand can find caused crash, files opened , if crash , file descriptor leak connected.

c# - Access the current InstanceContext in a WCF UsernamePasswordValidator -

i have wcf service using custom usernamepasswordvalidator. validator needs access entity framework context. i create 1 objectcontext entire service call , destroy/dispose @ end of call. created singleton static class provided functionality, however, what's happening if 2 service calls happen concurrently, 1 of calls disposes singleton. i either keep local reference objectcontext, in case second service use sees disposed , throws , error, or, put wrapper property around singleton class wherever need , changes thrown away because i'm getting new instance of object if call has disposed it. so question how instantiate objectcontext per service call? note: instance needs accesible in both service code , custom usernamepasswordvalidator code. i can't in constructor or use using statement because custom usernamepasswordvalidator doesn't have access it . there way have static class per call? sound impossible, what's way around this? should caching object in s...

linux - Visibility of template specialization of C++ function -

suppose have filea.h declares class classa template function somefunc<t>() . function implemented directly in header file (as usual template functions). add specialized implementation of somefunc() (like somefunc<int>() ) in filea.c (ie. not in header file). if call somefunc<int>() other code (maybe library), call generic version, or specialization? i have problem right now, class , function live in library used 2 applications. , 1 application correctly uses specialization, while app uses generic form (which causes runtime problems later on). why difference? related linker options etc? on linux, g++ 4.1.2. it an error have specialization template not visible @ point of call. unfortunately, compilers not required diagnose error, , can code (in standardese "ill formed, no diagnostic required"). technically, need define specialization in header file, every compiler handle might expect: fixed in c++11 new "extern template" faci...

Android - query if a sync account is checked for syncing -

how can query if sync account checked syncing or not? the user doesn't control whether account selected syncing -- rather, (acount, contentauthority) pairs selected. example, gmail account can checked sync contacts, not calendar events. here code check whether first entered "com.google-type" account syncs against google contacts. (note "com.google" type of account, not actual content of username. might have google apps account own domain name in there) import android.provider.contactscontract; accountmanager = accountmanager.get(this); account[] accounts = am.getaccountsbytype("com.google"); boolean syncenabled = contentresolver.getsyncautomatically(accounts[0], contactscontract.authority); this code fail if accounts[] size 0 (no accounts registered) , kind of meaningless in presence of multiple accounts. you'll need sort of reasonable selection account. there other ways hold of account well. just becuase it...

ios - iPhone, passing object to method(s), memory management -

i know there lot of questions on topic already, not clear me yet. so, still wondering is, if call method , pass object, have retain object inside method use there. , if retain it, release it. lets make bit of more complex example. explain whats wrong this: nsstring *mystr = [[nsstring alloc]initwithstring:@"hello"]; mystr = [self modstring2:[self modstring1:mystr]]; [mystr release]; //these methods... -(nsmutablestring*)modstring1:(nsstring*)str{ return [[[str stringbyappendingstring:@" mr. memory"] mutablecopy] autorelease]; } -(nsmutablestring*)modstring2:(nsstring*)str{ return [[[str stringbyappendingstring:@" how this?"] mutablecopy] autorelease]; } this confusing me. lets assume create object inside method: [self modstring:[self createstring]]; -(nsstring*)createstring{ nsstring *string = [nsstring stringwithstring:@"hello"]; return string; } -(nsmutablestring*)modstring:(nsstring *)str{ [str retain]; nsmutablestring *...

multithreading - lock keyword in C# -

i understand main function of lock key word msdn lock statement (c# reference) the lock keyword marks statement block critical section obtaining mutual-exclusion lock given object, executing statement, , releasing lock. when should lock used? for instance makes sense multi-threaded applications because protects data. necessary when application not spin off other threads? is there performance issues using lock? i have inherited application using lock everywhere, , single threaded , want know should leave them in, necessary? please note more of general knowledge question, application speed fine, want know if design pattern follow in future or should avoided unless absolutely needed. when should lock used? a lock should used protect shared resources in multithreaded code. not else. but necessary when application not spin off other threads? absolutely not. it's time waster. sure you're not implicitly using system threa...

ruby on rails - What is the easiest way to duplicate an activerecord record? -

i want make copy of activerecord record, changing single field in process (in addition id ). simplest way accomplish this? i realize create new record, , iterate on each of fields copying data field-by-field - figured there must easier way this... such as: @newrecord=record.copy(:id) *perhaps?* to copy, use clone (or dup rails 3.1) method: # rails < 3.1 new_record = old_record.clone #rails >= 3.1 new_record = old_record.dup then can change whichever fields want. activerecord overrides built-in object#clone give new (not saved db) record unassigned id. note not copy associations, you'll have manually if need to. rails 3.1 clone shallow copy, use dup instead...

access $(this) with href="javascript:..." in JQuery -

i using jquery. call javascript function next html: <li><span><a href="javascript:uncheckel('tagvo-$id')">$tagname</a></span></li> i remove li element , thought easy $(this) object. javascript function: function uncheckel(id) { $("#"+id+"").attr("checked",""); $("#"+id+"").parent("li").css("color","black"); $(this).parent("li").remove(); // not working retrieveitems(); } but $(this) undefined. ideas? try (e.g. hide <li> ): function uncheckel(id, ref) { (...) $(ref).parent().parent().hide(); // should <li> } and link: <a href="javascript:uncheckel('tagvo-$id', \$(this))"> $(this) not present inside function, because how supposed know action called from? pass no reference in it, $(this) refer <a> .

How do you keep your keyboard clean? -

i've had same keyboard 3 years , it's getting pretty grimy , disgusting. flip on , try bang out crumbs time time , wipe down rubbing alcohol time time. doesn't seem job. any other ideas? covers? rubber keyboards? new keyboard? i regularly (2x year, probably) pop off keys. lets have access sides of key cleaning, tray below. some people using dishwasher, i'm not putting g15 in dishwasher. :-p

silverlight 4.0 - Should properties of ViewModels that implement INotifyPropertyChanged automatically update the data in DataGrid control when I update them? -

i may confused purpose behind inotifypropertychanged , silverlight... i have xaml created in designer: <usercontrol.resources> <collectionviewsource x:key="theviewsource" d:designsource="{d:designinstance my:transferobject, createlist=true}" /> </usercontrol.resources> as this <canvas datacontext="{staticresource theviewsource}"> <sdk:datagrid itemssource="{binding}" name="thedatagrid"> <sdk:datagrid.columns> <!-- columns omitted post --> </sdk:datagrid.columns> </sdk:datagrid> </canvas> and have codebehind: private sub control_loaded(byval sender system.object, byval e system.windows.routedeventargs) handles mybase.loaded if not (system.componentmodel.designerproperties.getisindesignmode(me)) dim mycollectionviewsource system.wind...

How to determine the value of a controller variable during execution in Ruby on Rails? -

what best way me determine controller variable's value during execution? for example, there way can insert break in code, , cause value of variable output screen (or log)? yes. easiest way raise value string. so: raise @foo.to_s or, can install debugger ( gem install ruby-debug ), , start development server --debugger flag. then, in code, call debugger instruction. inside debugger prompt, have many commands, including p print value of variable. update: here's a bit more ruby-debug .

xamarin.ios - UIImagePickerController Crashing Monotouch -

i trying write application, crashing when using uiimagepickercontroller. thought might because not disposing of picker after each use, freeze on first run well. i'll take picture , freezes, never asking "use" picture. do have suggestions? here code. has gotten work? public override void viewdidload () { base.viewdidload (); mypicker = new uiimagepickercontroller(); mypicker.delegate = new mypickerdelegate(this); myalbumbutton.clicked += delegate { if(uiimagepickercontroller.issourcetypeavailable(uiimagepickercontrollersourcetype.photolibrary)){ mypicker.sourcetype = uiimagepickercontrollersourcetype.photolibrary; mypicker.allowsediting = true; this.presentmodalviewcontroller (mypicker, true); }else{ console.writeline("cannot album"); } }; mycamerabutton.clicked += delega...

php - How to check if a value already exists to avoid duplicates? -

i've got table of urls , don't want duplicate urls. how check see if given url in table using php/mysql? if don't want have duplicates can following: add uniqueness constraint use " replace " or " insert ... on duplicate key update " syntax if multiple users can insert data db, method suggested @jeremy ruten, can lead error : after performed check can insert similar data table.

Hidden Features of JavaScript? -

what "hidden features" of javascript think every programmer should know? after having seen excellent quality of answers following questions thought time ask javascript. hidden features of html hidden features of css hidden features of php hidden features of asp.net hidden features of c# hidden features of java hidden features of python even though javascript arguably important client side language right (just ask google) it's surprising how little web developers appreciate how powerful is. you don't need define parameters function. can use function's arguments array-like object. function sum() { var retval = 0; (var = 0, len = arguments.length; < len; ++i) { retval += arguments[i]; } return retval; } sum(1, 2, 3) // returns 6

regex - How to use RegexIterator in PHP -

i have yet find example of how use php regexiterator recursively traverse directory. the end result want specify directory , find files in given extensions. example html/php extensions. furthermore, want filter out folders such of type .trash-0, .trash-500 etc. <?php $directory = new recursivedirectoryiterator("/var/www/dev/"); $it = new recursiveiteratoriterator($directory); $regex = new regexiterator($it,'/^.+\.php$/i',recursiveregexiterator::get_match); foreach($regex $v){ echo $value."<br/>"; } ?> is have far result in : fatal error: uncaught exception 'unexpectedvalueexception' message 'recursivedirectoryiterator::__construct(/media/hdmovies1/.trash-0) any suggestions? there couple of different ways of going this, i'll give 2 quick approaches choose from: quick , dirty, versus longer , less dirty (though, it's friday night we're allowed go little bit crazy). 1. quick (and dirty) this...

Python list remove method: how's the implementation? -

in java, have client class have "code" attr, , equals method. method equals receives client , compares itself's code attr. in python, read have __cmp__ method, same java method equals. ok, did that. created class client, "code" attr , method comp verify if code same. class client(): def __init__(self, code): self.code = code def __cmp__(self, obj): return obj.code == self.code def __repr__(self): return str(self.code) then put 3 client objects in python's list: bla = [client(1), client(2), client(3)] then, when try: bla.remove(client(3)) the amazing python removes first element (the client code 1). what doing wrong? searched implementation of list in python's lib files, not easy find. anyone can help? http://docs.python.org/reference/datamodel.html#object.__cmp__ __cmp__(self, other) called comparison operations if rich comparison (see above) not defined. should return n...

c# - ZedGraph on resize? -

how can access event triggered when graph pane resized? after each resize, want fix text size on title , labels don't huge when window maximized. you can subscribe zedgraphcontrol 's resize event: zg1.resize += new eventhandler(zg1_resize); but it's easier achieve want disabling automatic font scaling on graphpane: zg1.masterpane[0].isfontscaled = false; if have more 1 graphpane on masterpane, use: foreach(graphpane pane in zg1.masterpane.panelist) pane.isfontscaled = false; see also: http://zedgraph.org/wiki/index.php?title=how_does_the_font_and_chart_element_scaling_logic_work%3f http://zedgraph.sourceforge.net/documentation/html/p_zedgraph_panebase_isfontsscaled.htm

continue - Java String initialization (part 2) -

i asked this goofy question earlier today , got answers. think meant ask following: string astring = ""; // or = null ? if(somecondition) astring = "something"; return astring; in case, string has initialized in order return it. thought either option (setting "" or null looks kind of ugly. wondering others here...or more of matter of whether want empty string or null being passed around in program (and if prepared handle either)? also assume intermediary logic long cleanly use conditional (? :) operator. depends on want achieve, in general return null signal nothing processed, might later pop cases somecondition true string build "" anyway, way can differentiate case if return null if nothing processed. i.e. string astring = null; if(somecondition) astring = "something"; return astring; but depends on want achieve... e.g. if code suppose build string delivered directly in ui go "" instead ...

python - What's a good way to find relative paths in Google App Engine? -

so i've done trivial "warmup" apps gae. i'd build more complex directory structure. along lines of: siteroot/ models/ controllers/ controller1/ controller2/ ... templates/ template1/ template2/ ... ..etc. controllers python modules handling requests. need locate (django-style) templates in associated folders. of demo apps i've seen resolve template paths this: path = os.path.join(os.path.dirname(__file__), 'mypage.html') ...the __ file __ property resolves executing script. so, in above example, if python script running in controllers/controller1/, 'mypage.html' resolve same directory -- controllers/controller1/mypage.html -- , rather cleanly separate python code , templates. the solution i've hacked feels... hacky: base_paths = os.path.split(os.path.dirname(__file__)) template_dir = os.path.join(base_paths[0], "templates") so, i'm snipping off las...

c# - Is for keyword obsolete like goto in modern object-oriented languages? -

is for keyword obsolete or may become obsolete goto in languages c# or java? in few years, strange , suspicious see object-oriented code uses for , today, it's suspicious see goto s? in other words, there reason know , use for in programs? i notice there bunch of weaknesses for doesn't exist when using foreach : 'for' used , need it: don't know scientific development, general stuff, software products , websites not dealing calculus, for used extremely rarely. i've seen , done many projects there no loop in thousands of lines of code. when dealing calculus, manipulating arrays , collections or matrices or ranges more frequent, elegant , useful loop. a few places when seems for required, in fact, not, , collection-oriented solution may used instead. reading source code of beginner developers, find for used .net framework does. example, fill array same value, repeated n times, people use loop, when must rather use enumerable.repeat() . ...

desktop - qemu vnc server for remote address -

qemu -vnc 0.0.0.0:1 -monitor stdio -hda ubunt* i running command isn't opening port. have checked netstat. goal log vnc server somewhere else besides locally. try qemu -vnc :1 . 0.0.0.0 should work, according man qemu omitting should allow connections host.

optimization - Process vs Threads -

how decide whether use threads or create separate process altogether in application achieve parallelism. threads more light weight, , making several "workers" utilize availabe cpus or cores, you're better of threads. when need workers better isolated , more robust, servers, go sockets. when 1 thread crashes badly, takes down entire process, including other threads working in process. if process turns sour , dies, doesn't touch other process, can happily go on bussiness if nothing happened.

PHP: Calling a function within a return string -

i'm trying call function within string return statement. both in same class. however, i'm not calling right because doesn't work :) private static function dosomething(){ $d['dt'] = //unix time stamp here; return '<div class="date" title="commented on '.date('h:i \o\n d m y',$d['dt']).'">'.time_since($d['dt']).'</div>'; } function time_since(){ //return 'string'; } any appreciated! thanks first, calling time_since() , function time_stamp(). second, in php need explicitly call $this->time_stamp() - not resolve object scope c++ does. third, cannot call regular method static function because object not instantiated - make time_stamp() static too. if this, needs invoked self::time_stamp().

C# - get line number which threw exception -

in catch block, how can line number threw exception? if need line number more formatted stack trace exception.stacktrace, can use stacktrace class: try { throw new exception(); } catch (exception ex) { // stack trace exception source file information var st = new stacktrace(ex, true); // top stack frame var frame = st.getframe(0); // line number stack frame var line = frame.getfilelinenumber(); } note work if there pdb file available assembly.

java - @Override on Implementation -

would put annotation in implementation class methods? serve purpose? if mistype or don't have it, compile error anyway. i assume asking annotating methods defined in implemented interface, or abstract in super class. in case, correct typo in method signature result in compile error or without @override . however, think annotation still helpful explicitly mark method implementing interface. if interface ever changes, having @override annotations on implementing methods can pinpoint method signatures have changed , need updated. more importantly, mklhmnn mentioned in answer, if method removed interface, @override annotation in implementing class cause compile error. without annotation, might not aware method had been removed interface, lead subtle bugs.

Disable screen rotating on Android -

this question has answer here: how disable orientation change on android? 12 answers when press button, disable screen rotation on activities . how can that? btw, phone can located in landscape or portrait position when user click button. setrequestedorientation(activityinfo.screen_orientation_landscape); setrequestedorientation(activityinfo.screen_orientation_portrait);

asp.net - Linq dbml show int return type for an SP which SP return some fields from temporary table -

i have written stored procedure return fields temporary table create in stored procedure. when include in dbml file show return type of stored procedure int. should not returning field table although temporary. linq-to-sql uses sql server "fmtonly" setting determine return type stored procedures. avoid having stored procedures make changes database inadvertedly when getting signature. if stored procedure safe execute no param values etc, can add " set fmtonly off; " in beginning of procedure. linq-to-sql able correctly identify return type stored proc.

c# - Can I control what subtype to use when deserializing a JSON string? -

i'm working facebook api , it's search method returns json response this: { "data": [ { "id": "1", "message": "heck of babysitter...", "name": "baby eating watermelon", "type": "video" }, { "id": "2", "message": "great produce deals", "type": "status" } ] } i have class structure similar this: [datacontract] public class item { [datamember(name = "id")] public string id { get; set; } } [datacontract] public class status : item { [datamember(name = "message")] public string message { get; set; } } [datacontract] public class video : item { [datamember(name = "string")] public string name { get; set; } [datamember(name = "message")] public string message { ...

Simple database application for Windows -

i need build simple, single user database application windows. main requirements independence windows version , installed software. technologies (language/framework) recommend? preference language visual basic. edit: vb.net , sql server compact edition? i recommend sqlite . it's self-contained, , public domain there no license issues @ all.

CSS and Html question -

i found page of web developer interview questions , , i'm not sure answers 2 of them. q1, pick answer e. q2, pick answer b, i'm not sure if there better ways it. which markup structure semantic title within document body, considering title may horizontally centered using large, bold, red font? a. <h1>this title</h1> b. <p align="center"><font size="+3"><b>this title</b></font></p> c. <h1 style="font-weight:bold; font-size:large; text-align:center; color:red;">this title</h1> d. <title>this title</title> e. <h1 class="largeredboldcenterheading">this title</h1> f. <span class="title">this title</span> are each of following footer markup solutions acceptable? why or why not? alternate solution(s) propose? a. <div id="footer"> copyright 2010 company | text arbitratry. </div> b...

mysql - SQL clone record with a unique index -

is there clean way of cloning record in sql has index(auto increment). want clone fields except index. have enumerate every field, , use in insert select, , rather not explicitly list of fields, may change on time. not unless want dynamic sql. since wrote "clean", i'll assume not. edit: since asked dynamic sql example, i'll take stab @ it. i'm not connected databases @ moment, off top of head , need revision. captures spirit of things: -- list of columns in table select #t exec sp_columns @table_name = n'targettable' -- create comma-delimited string excluding identity column declare @cols varchar(max) select @cols = coalesce(@cols+',' ,'') + column_name #t column_name <> 'id' -- construct dynamic sql statement declare @sql varchar(max) set @sql = 'insert targettable (' + @cols + ') ' + 'select ' + @cols + ' targettable somecondition' print @sql -- debugging exec(@sq...

ruby on rails - How to implement mongoid many-to-many associations? -

i want port social network mongoid. join table between friends large. there way mongoid handle join table out of box? i've seen couple of in-model roll-your-own solutions it, nothing looks efficient. there way handle this? or case shouldn't using mongoid? this method deprecated. can use references_and_referenced_in_many so: class person include mongoid::document field :name references_and referenced_in_many :preferences end class preference include mongoid::document field :name references_and referenced_in_many :people end

java - When would you use a WeakHashMap or a WeakReference? -

the use of weak references i've never seen implementation of i'm trying figure out use case them , how implementation work. when have needed use weakhashmap or weakreference , how used? one problem strong references caching, particular large structures images. suppose have application has work user-supplied images, web site design tool work on. naturally want cache these images, because loading them disk expensive , want avoid possibility of having 2 copies of (potentially gigantic) image in memory @ once. because image cache supposed prevent reloading images when don't absolutely need to, realize cache should contain reference image in memory. ordinary strong references, though, reference force image remain in memory, requires somehow determine when image no longer needed in memory , remove cache, becomes eligible garbage collection. forced duplicate behavior of garbage collector , manually determi...

Cheapest Java code signing certificate? (not self-signed) -

where can inexpensive java code signing certificate? everywhere want usd200 usd300 per year! unfortunately cannot use self-signed 1 i'm trying rid of scary warnings users more accept application. , far know (per stack overflow question are java code signing certificates same ssl certificates? ), has code signing certificate, cannot ssl certificate. what startssl ? offer code signing certificates 49.90$ 2 years (with wild card capabilities). haven't tried using it, no guarantees, looks good. update: startssl no longer valid option, given previous limitations. google , mozilla , apple stopped trusting them. encourage use, given development. giving current state of affairs, should not accepted answer anymore. sorry!

javascript - Regular expression which matches a pattern, or is an empty string -

i have following regular expression matches email address format: ^[\w\.\-]+@([\w\-]+\.)+[a-za-z]+$ this used validation form using javascript. however, optional field. therefore how can change regex match email address format, or empty string? from limited regex knowledge, think \b matches empty string, , | means "or", tried following, didn't work: ^[\w\.\-]+@([\w\-]+\.)+[a-za-z]+$|\b to match pattern or empty string, use ^$|pattern explanation ^ , $ beginning , end of string anchors respectively. | used denote alternates, e.g. this|that . references regular-expressions.info/anchors , alternation on \b \b in flavor "word boundary" anchor. zero-width match, i.e. empty string, matches strings @ very specific places , namely @ boundaries of word. that is, \b located: between consecutive \w , \w (either order): i.e. between word character , non-word character between ^ , \w i.e. @ beginning of string...

asp.net mvc - how to redirect to a url in mvc view -

i implementing live search , when user selects of options accordingly page gets redirected depending on option selected. i have jquery implementing live search . in select option :-->> want redirect page index function in homecontrollers file using javascript. index function has few parametres inside ... i not able redirect ... url want send .. gets appended current url. i doing window.location = "home/index/"+ ui.item.value; kindly suggest ??? waiting reply soon. you're using relative uri. need use absolute uri. instead of window.location = "home/index/"+ ui.item.value; do window.location = "/home/index/"+ ui.item.value; note /

iphone - How do I programmatically zoom a UIScrollView? -

i'd zoom , unzoom in ways base class doesn't support. for instance, upon receiving double tap. i'm answering own question, after playing things , getting working. apple has very-simple example of in documentation on how handle double taps. the basic approach doing programmatic zooms yourself, , tell uiscrollview did it. adjust internal view's frame , bounds. mark internal view needing display. tell uiscrollview new content size. calculate portion of internal view should displayed after zoom, , have uiscrollview pan location. also key: once tell uiscrollview new contents size seems reset concept of current zoom level. @ new 1.0 zoom factor. you'll want reset minimum , maximum zoom factors.

jquery - unable to download dynamically created file -

i've created custom action result in mvc application, generate csv file according configuration user provides. however. problem have if create download link this: <a id="lnkdownload" href="<%= url.action("downloadfile", "download", new { id = model.id, userid = model.userid, startdate = "30/05/2010", enddate = "30/05/2005"}) %>">download</a> it works fine. thing i've introduced 2 date time controllers on page, user can set start , end date. therefore i'm adding in dates controller url this: $('#lnkdownload').click(function() { var startdate = $('#tbextratestartdate').val(); var enddate = $('#tbextrateenddate').val(); var link = $('#lnkdownload').attr('href') + "&startdate=" + startdate + "&enddate=" + enddate; $.get(link, function() { }); return false; }); this gives me problem "downlo...

wpf - How do I reference a font resource in a satellite assembly? -

i have localised wpf application , need embed font each locale. have font added project , it's build action set resource. if remove <uiculture>en-us</uiculture> .csproj (which eliminates creation of satellite assemblies) font compiled resource project assembly. can add font by: <button content="my button" fontfamily="fonts/#frutiger lt 87 extrablackcn" /> this works perfectly. if add en-us .csproj font gets added localised satelite assembly. <button x:uid="button1" content="my button" fontfamily="fonts/#frutiger lt 87 extrablackcn" /> no longer works. how should referencing localised font? while not directly answer question, msdn page on wpf globalization , localization overview seems recommends you: create customized composite font obtain better control of fonts used different languages. the idea use single, "composite", font contains fonts languages might want u...

almost live forex currency rates -

i need live forex exchange rates personal application. know there's no free service has data available download. i've been using yahoo finance, i've found out has delay of 15 minutes or so. there way fresher rates somewhere? say, 5-minute old instead of 15? many forex brokers offer free "informers" autoload data in interval of seconds, maybe there's few allow data downloaded in bigger intervals without use of informers strictly personal use? truefx has free real-time (multiple updates per second) forex quotes, limited number of pairs: http://webrates.truefx.com/rates/connect.html?f=html they have free downloadable tick data same pairs, going may 2009: http://truefx.com/?page=downloads you can real-time quotes larger selection of pairs fxcm: http://rates.fxcm.com/ratesxml realtime rates 40 currency pairs available here: http://1forge.com/forex-data-api , eg: https://1forge.com/forex-quotes/quotes they have free downloadable tick-data, goi...

Growing Access Frontend: Should I be concerned? -

i've read opinions across internet if design or ms access frontend properly, shouldn't shrink when compact. i've got 1 front end i'm using typically around 15 mb when compacted, grows 20-25 mb while i'm working on it! should concerned about? as adding reports , on, not think should concerned. suggest decompile* regularly when working on code, forms , reports. * http://wiki.lessthandot.com/index.php/decompile

c++ - Borland x86 inlined assembler; get a label's address? -

i using borland turbo c++ inlined assembler code, presumably turbo assembler (tasm) style assembly code. wish following: void foo::bar( void ) { __asm { mov eax, somelabel // ... } // ... somelabel: // ... } so address of somelabel placed eax. doesn't work , compiler complains of: undefined symbol 'somelabel'. in microsoft assembler (masm) dollar symbol ($) serves current location counter, useful purpose. again not seem work in borlands assember (expression syntax error). update: little more specific, need compiler generate address moves eax constant during compilation/linking , not @ run time, compile "mov eax, 0x00401234". can suggest how working? update: respond pax's question (see comment), if base address changed @ run time windows loader dll/exe pe image still relocated windows loader , labels address patched @ run time loader use re-based address using compile/link time value label address not issue. man...

security - The necessity of hiding the salt for a hash -

at work have 2 competing theories salts. products work on use user name or phone number salt hash. different each user readily available us. other product randomly generates salt each user , changes each time user changes password. salt encrypted in database. my question if second approach necessary? can understand purely theoretical perspective more secure first approach, practicality point of view. right authenticate user, salt must unencrypted , applied login information. after thinking it, don't see real security gain approach. changing salt account account, still makes extremely difficult attempt brute force hashing algorithm if attacker aware of how determine each account. going on assumption passwords sufficiently strong. (obviously finding correct hash set of passwords 2 digits easier finding correct hash of passwords 8 digits). incorrect in logic, or there missing? edit: okay here's reason why think it's moot encrypt salt. (lemme know if i...

Possible to combine calls in WCF? -

i have 2 methods need call in wcf application client. authenticate(username, password) getuser(username) is possible combine these calls avoid many calls being sent back/forth? there few ways handle type of thing. first, can use wcf sessions initiate group of commands need maintain context between calls: http://msdn.microsoft.com/en-us/library/ms733136.aspx secondly, can take advantage of wcf's support ws-security standards avoid need pass credentials second call: http://msdn.microsoft.com/en-us/library/aa702565.aspx

What are the benefits of MS Word content controls? -

office 2007 brings new goodie called 'content controls'. need evaluate see if serves solution problem under research. due paucity of time , general disdain office-interop-pains, can summarize benefits? is possible define custom content controls? where word programmers (if there any) hang out :) ? rtfmsdn links welcome. so far see (from screencasts) possible define - template word docs content can stubbed in data-behind-xml. create xml wish.. e.g. translate contents of db xml form. word doc can 'data-bind' xml. well after 2 days of research, here's found. content controls next step in evolution old bookmarks.. protection - can protect content-controls in document such user cannot edit them. e.g. terms of contract may not editable rest of doc data binding - can create 'forms' in word doc content controls bind custom xml via visual designer. 2-way: changing xml updates controls in word doc , vice versa. throw in xml schema xml ...

sql - MySQL, reading this EXPLAIN statement -

i have query starting cause concern in application. i'm trying understand explain statement better understand indexes potentially missing: +----+-------------+-------+--------+---------------+------------+---------+-------------------------------+------+---------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | | +----+-------------+-------+--------+---------------+------------+---------+-------------------------------+------+---------------------------------+ | 1 | simple | s | ref | client_id | client_id | 4 | const | 102 | using temporary; using filesort | | 1 | simple | u | eq_ref | primary | primary | 4 | www_foo_com.s.user_id | 1 | | | 1 | simple | | ref ...

iis - Do MOD_Rewrite rewrites invoke a second run through the rewrite rules? -

when rewriterule executed mod_rewrite mod_rewrite rules executed again newly generated request? in following example, cause loop? rewritecond host: (?:www\.)?mysite\.com rewriterule ^(.*)$ $1 [qsa,l] in case, won't @ rate loop. have "l" switch on, fixing particular rule last one. further, have explicitly force next iteration using "n" or "ns" switches, or move through rule file , stop last rule matches. docs: n (next iteration) forces rewriting engine modify rule's target , restart rules checking beginning (all modifications saved). number of restarts limited value specified in repeatlimit directive. if number exceeded n flag ignored. ns (next iteration of same rule) works n flag restarts rules processing same rule (i.e. forces repeat of rule application). maximum number of single rule iterations given repeatlimit directive. number of single rule repeats not count global number of...

iphone - How can I use different .h files for several targets? -

i have project several targets. of classes, can use single .h file , change details in .m file (adding different .m file each target). for 1 of uiviewcontroller subclasses, need declare different uilabel iboutlet s different targets (each target shows different set of labels depending on what's available). problem header files can't targeted. there's no checkbox next them specify target membership. the way i've been dealing add outlets of targets , ignore unused ones. doesn't seem ideal. do need use header build phase this? what's best way deal problem? thanks. edit: should have mentioned want .h files have same name: placeviewcontroller.h . you can use preprocessor directives selectively include header files. instance #if target_os #import "firsttarget.h" #else #import "secondtarget.h" #endif you can use different folders different targets if headers named same: #if target_os #import "first/target...

ruby on rails - How to increase key size in Memcached -

problem i'm getting error: key long "rack:session:bah7...." /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/memcache-client-1.8.5/lib/memcache.rb:703:in `get_server_for_key' /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/memcache-client-1.8.5/lib/memcache.rb:920:in `request_setup' /usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/memcache-client-1.8.5/lib/memcache.rb:885:in `with_server' when looked @ memcache-client-1.8.5/lib/memcache.rb:703 def get_server_for_key(key, options = {}) raise argumenterror, "illegal character in key #{key.inspect}" if key =~ /\s/ raise argumenterror, "key long #{key.inspect}" if key.length > 250 ... end also according http://code.google.com/p/memcached/wiki/faq#what_is_the_maxiumum_key_length?_(250_bytes) max length 250 bytes. since production , pretty hard replicate error, figured can ask here if 1 had same issue before. question 1: can remove statement memcache-client? ques...

regex - Validating Crontab Entries with PHP -

what best way validate crontab entry php? should using regex, or external library? i've got php script adds/removes entries crontab file, want have way verify time interval portion in valid format. hmmm, interesting problem. if you're going validate it, regex isn't going enough, you'll have parse entry , validate each of scheduling bits. that's because each bit can number, month/day of week string, range (2-7), set (3, 4, saturday), vixie cron-style shortcut (60/5) or combination of above -- single regex approach going hairy, fast. just using crontab program of vixie cron validate isn't sufficient, because doesn't validate completely! can crontab accept sorts of illegal things. dave taylor's wicked cool shell scripts ( google books link ) has sh script partial validation, found discussion interesting. might use or adapt code. i turned links 2 php classes (whose quality haven't evaluated): http://www.phpclasses.org/browse/pac...

process - When deciding on a feature, what do you do? -

do think of reasons implement it, or reasons not implement it? advantages of each? this fine joel spolsky post says: make list of possible features. vote filter out worst features. assign cost each feature. allot limited feature budget each participant. find out features popular when allocating budgets.

c# - what Windows account should a service run under to access network sql servers -

i considering creating windows service run periodically , query networked databases , store information on local machine (please don’t ask why!). service run when there no 1 logged on computer locally. account should service run under localservice, localsystem or network. username , password provided networked databases including local. i'd create specific domain account , grant rights both sql server , whatever local store going use. if want use sql credentials connect db, local account (with access local resources) or higher privileged user (like localsystem).

sql server - SQL query to find where no primary key exists -

added foreign key relationship table in order had abandon checking data on creation. presume parent(company) objects have been deleted , want find orphaned(division) records. how find row foreign key not exist in primary table? this thinking struggling clause. select tb_division.divisionname, tb_division.divisioncompanyid tb_division left outer join tb_company on tb_division.divisioncompanyid = tb_company.companyid (tb_company.companyid = null or 'doesn't exist in tb_company') any pointers appreciated. you've got it, need compare using is null predicate: select d.divisionname, d.divisioncompanyid tb_division d left outer join tb_company c on d.divisioncompanyid = c.companyid c.companyid null or write way, same thing , maybe it's more intuitive: select d.divisionname, d.divisioncompanyid tb_division d not exists (select * tb_com...

visual studio 2008 - Code Coverage and Unit Testing of Python Code -

i have visited preferred python unit-testing framework . not looking @ python unit testing framework, code coverage respect unit tests. far have come across coverage.py . there better option? an interesting option me integrate cpython , unit testing of python code , code coverage of python code visual studio 2008 through plugins (something similar ironpython studio ). can done achieve this? forward suggestions. pydev seems allow code coverage within eclipse. i've yet find how integrate own (rather complex) build process, use ned batchelder's coverage.py @ command line.

vb.net - how to pass an event from a child object in a generic list to the parent? -

here example code: public class parent private _testproperty string private withevents _child ilist(of child) public property test() string return _testproperty end set(byval value string) _testproperty = value end set end property public property child() ilist(of child) return _child end set(byval value ilist(of child)) _child = value end set end property private sub eventhandler handles _child end class public class child private _testproperty string public event propertychanged eventhandler friend sub notify() raiseevent propertychanged(me, new eventargs()) end sub public property test() string return _testproperty end set(byval value string) _testproperty = value notify() end set end property end class how can handle event raised 1 ...

java - How can I check if a method is static using reflection? -

i want discover @ run-time static methods of class, how can this? or, how differentiate between static , non-static methods. use modifier.isstatic(method.getmodifiers()) . /** * returns public static methods of class or interface, * including declared in super classes , interfaces. */ public static list<method> getstaticmethods(class<?> clazz) { list<method> methods = new arraylist<method>(); (method method : clazz.getmethods()) { if (modifier.isstatic(method.getmodifiers())) { methods.add(method); } } return collections.unmodifiablelist(methods); } note: method dangerous security standpoint. class.getmethods "bypass[es] securitymanager checks depending on immediate caller's class loader" (see section 6 of java secure coding guidelines). disclaimer: not tested or compiler. note modifier should used care. flags represented ints not type safe. common mistake test modifier flag on ...

How are DLLs created out of C++ source, and how are they used in other sources? -

how dlls created out of c++ source code, , how used in other sources? the dll 'dynamic link library' works lot other libraries not linked executable application. @ run time can call specific functions loading dll , executing exported methods. you can try creating dll yourself- create project using visual studio , specify dll. create of base constructs project such settings project compile dll , base code exposing methods, objects, or variables. there many walk through's @ point: check here . so, summarize: a dll library can loaded @ runtim e. flexible 'plug-in' model. example: can programmatically select , load different dll @ runtime. each dll can 'plug-in' provide different functionality. a dll has entry point . main function of command line executable entry point, dll has entry point function called when different events occur on dll such loading, unloading, , more. to use dll must use exported objects or methods of dll. wh...

Load HTML frames in a specific order without back button problems? -

i have web page uses frameset. due scripting , object dependencies, need load frames in specific order. i have used example template: the javascript source: navigation: frames load order this loads empty page in place of page need load last, replaces correct page after first page has loaded. however: need use browser button. if run sample @ above link, let both frames load, click button, top frame reverts temporary blank page. necessary click button again navigate page before frameset. is there way force frames load in specific order without button behavior - or way force button skip empty page? this needs work internet explorer 6 , 7 , preferably firefox 3 well. you mention quite lot in post... this legacy system. frameset required. if working on legacy system, think time accepted how framesets behave in terms of browser's button. if legacy system, don't need fix behaviour. if not legacy system , need fix problem, need away using frameset. fram...