instruction
stringlengths
0
30k
Make sure that the currentPage variable is correctly scoped in the code where it is being accessed. Could the variable be changed somewhere else in the code before you are accessing it? Tools like [Firebug][1] can help you to add a breakpoint at the point of execution and see the value of your variable. [1]: https://addons.mozilla.org/firefox/addon/1843
Regular expression matching, Parsing, Flow control in a complex system. Regular expressions are a simple form of state machine, specifically finite automata. They have a natural represenation as such, although it is possible to implement them using mutually recursive functions. State machines when implemented well, will be very efficient. There is an excellent state machine compiler for a number of target languages, if you want to make a readable state machine. http://research.cs.queensu.ca/~thurston/ragel/ It also allows you to avoid the dreaded 'goto'.
IntelliJ IDEA works as a Flex IDE, if you happen to also be a Java developer. It's free if you contribute to open source projects.
jQuery and Prototpye Selector Madness
|jquery|prototype|addclass|css-selectors|
Both the jQuery and Prototpye JavaScript libraries refuse to allow me to use a variable to select an list item element by index number although they accept a hard coded number. For example, in Prototype this works: $$('li')[5].addClassName('active'); But this will not work no matter how I try to cast the variable as a number or integer: $$('li')[currentPage].addClassName('active'); In jQuery I get similar weirdness. This will work: jQuery('li').eq(5).addClass("active"); But this will not work again even though the value of currentPage is 5 and its type is number: jQuery('li').eq(currentPage).addClass("active"); I'm trying to create a JavaScript pagination system and I need to set the class on the active page button. The list item elements are created dynamically depending upon the number of pages I need.
jQuery and Prototype Selector Madness
|jquery|prototype|css-selectors|addclass|
Often, you can connect to the IPC$ "pseudo-share" on the machine to help establish the credentials before running commands like SC.EXE. Use a command like: C:\> net use \\xx.xx.xx.xx\ipc$ * /user:username The "*" tells it to prompt you for the password.
Effectively Converting dates between UTC and Local (ie. PST) time in SQL 2005
|sql-server|
What is the best way to convert a UTC datetime into local datetime. It isn't as simple as a getutcdate() and getdate() difference because the difference changes depending on what the date is. CLR integration isn't an option for me either.
What is the best way to convert a UTC datetime into local datetime. It isn't as simple as a getutcdate() and getdate() difference because the difference changes depending on what the date is. CLR integration isn't an option for me either. The solution that I had come up with for this problem a few months back was to have a daylight savings time table that stored the beginning and ending daylight savings days for the next 100 or so years, this solution seemed inelegant but conversions were quick (simple table lookup)
If either of these issues affects you, you should never store local times in the database: 1. With DST is that there is an "hour of uncertainty" around the falling back period where a local time cannot be unambiguously converted. If exact dates & times are required, then store in UTC. 1. If you want to show users the date & time in their own timezone, rather than the timezone in which the action took place, store in UTC.
During an internship w/ a large company that had a lot of in house IT, I was paired w/ a mentor. The practice definitely aided my career development, both in terms of technical skills and business skills. Here are some of the reasons the mentoring worked out so well: - **Credible**: The mentor had 8+ years of experience and an accomplished background to draw upon in leading and training. He'd been through different challenges, worked in different environments, so he had a great perspective. - **Genuine**: The mentorship was encouraged by the supervisor, but not so formal as to make it an exercise in going through the motions. The mentor wanted to mentor, and I wanted someone to learn from. - **Passion**: The mentor loved the field he was in, the problems he was solving, and the technologies he was using. When I came under his wing, I found this to be infectious. - **Sharp and Articulate**: The mentor approached issues critically and framed them concisely. There wasn't a lot of fuzziness in our discussions; we got to the root of the matter and he directed me on wise courses of problem solving and action. - **Meaningful**: The work I was doing w/ the mentor was meaningful work, not just an exercise to keep busy or ramp up in a skill set. By jointly working on a task that tangibly aided the organization, that helped focus my interest and legitimize the mentoring process.
TClientDataSet Aggregates specification aren't added automatically when creating an Aggregate field.
|delphi|
Is "safe_eval" really safe?
|python|security|
I'm looking for a "safe" eval function, to implement spreadsheet-like calculations (using numpy/scipy). The functionality to do this (the [rexec module][1]) has been removed from Python since 2.3 due to apparently unfixable security problems. There are several third-party hacks out there that purport to do this - the most thought-out solution that I have found is [this Python Cookbok recipe][2], "safe_eval". Am I reasonably safe if I use this (or something similar), to protect from malicious code, or am I stuck with writing my own parser? Does anyone know of any better alternatives? [1]: http://docs.python.org/lib/module-rexec.html [2]: http://code.activestate.com/recipes/496746/
I'm looking for a "safe" eval function, to implement spreadsheet-like calculations (using numpy/scipy). The functionality to do this (the [rexec module][1]) has been removed from Python since 2.3 due to apparently unfixable security problems. There are several third-party hacks out there that purport to do this - the most thought-out solution that I have found is [this Python Cookbok recipe][2], "safe_eval". Am I reasonably safe if I use this (or something similar), to protect from malicious code, or am I stuck with writing my own parser? Does anyone know of any better alternatives? EDIT: I just discovered [RestrictedPython][3], which is part of Zope. Any opinions on this are welcome. [1]: http://docs.python.org/lib/module-rexec.html [2]: http://code.activestate.com/recipes/496746/ [3]: http://pypi.python.org/pypi/RestrictedPython
Validate email address in Javascript?
|javascript|email|validation|
What's the best way to validate an email address in Javascript? _Though this solution may be simple, I'm sure this is one of those useful things that people will be Googling for and deserves its own entry on the site_
|javascript|regex|email|validation|
[From Wikipedia][1]: > In computer programming, a branch > table (sometimes known as a jump > table) is a term used to describe an > efficient method of transferring > program control (branching) to another > part of a program (or a different > program that may have been dynamically > loaded) using a table of branch > instructions. The branch table > construction is commonly used when > programming in assembly language but > may also be generated by a compiler. > > A branch table consists of a serial > list of unconditional branch > instructions that is branched into > using an offset created by multiplying > a sequential index by the instruction > length (the number of bytes in memory > occupied by each branch instruction). > It makes use of the fact that machine > code instructions for branching have a > fixed length and can be executed > extremely efficiently by most > hardware, and is most useful when > dealing with raw data values that may > be easily converted to sequential > index values. Given such data, a > branch table can be extremely > efficient; it usually consists of the > following steps: optionally validating > the input data to ensure it is > acceptable; transforming the data into > an offset into the branch table, this > usually involves multiplying or > shifting it to take into account the > instruction length; and branching to > an address made up of the base of the > table and the generated offset: this > often involves an addition of the > offset onto the program counter > register. [1]: http://en.wikipedia.org/wiki/Jump_table
Given a string of JSON data, how can you safely turn that string into a JavaScript object? Obviously you can do this unsafely with something like... var obj = eval("(" + json + ')'); ...but that leaves us vulnerable to the json string containing other code, which it seems very dangerous to simply eval.
Have you tried View -> Zoom -> Reset on both sites?
I'm not sure about other ways to do it but here's how you do it in [Prototype (JSON tutorial)](http://www.prototypejs.org/learn/json). new Ajax.Request('/some_url', { method:'get', requestHeaders: {Accept: 'application/json'}, onSuccess: function(transport){ var json = transport.responseText.evalJSON(true); } }); Calling **evalJSON()** with true as the argument sanitizes the incoming string.
[JSON.org](http://json.org/) has JSON parsers for many languages including 4 different ones for Javascript. I believe most people would consider [json2.js](http://www.json.org/js.html) their goto implementation.
Hm. OK, I'm still trying to break mine... so I went to the layouts directory and created a file foo.aspx. Here it is: <%@ Page Language="C#" Inherits="System.Web.UI.Page" MasterPageFile="~/_layouts/simple.master" %> <%@ Register Tagprefix="foo" Namespace="Foople" Assembly="Foople, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5"%> <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"> <foo:WebPart1 id="fred" runat="server" /> <foo:WebPart1a id="barney" runat="server" /> </asp:Content> WebPart1 is the webpart from before. WebPart1a is the exact same code, but in a class that inherits directly from WebControl rather than from WebPart. It works fine, apart from a security validation problem on the postback that I can't be bothered to debug. Changing the masterpage to ~masterurl/default.master, I uploaded foo.aspx to the Shared Documents library, and it works fine from there too -- both the WebControl and the WebPart behave properly, and the security problem is gone too. So I'm at a loss. Although I did notice this page with an obscure might-be-bug which is also in SPFolder.get_ContentTypeOrder(): http://forums.msdn.microsoft.com/en-US/sharepointdevelopment/thread/63baf273-7f36-453e-8293-26417759e2e1/ Any chance you could post your code?
I am going out on a limb here to say that, don't get caught up in too many podcasts or blogs, but rather dive into technology/code and good tech books. although +1 to; - Thoughtworks - IT matters - Software Engineering Radio - Pragmatic podcasts - Alt.Net podcasts - Hanselminutes and while not strictly technology - Enterprise Thought Leaders from Stanford University, which often has speakers from fortune 500 and tech startups on how they made it.
Why javascrpit does not support multithreading?
|javascript|browser|
Is it a deliberate design decision or a problem with our current day browsers which will be rectified in the coming versions?
|javascript|browser|fix-title-typo|
Your best bet is to physically secure the hardware the key is on. Also, don't ever write it to disk - find some way to prevent that section of memory from being paged to disk. When encrypting/decrypting the key needs to be loaded into memory, and with unsecure hardware there's always this venue of attack. There are, like you said, hardware encryption devices but they don't scale - all encryption/decryption passes through the chip.
How do I stop Visual Studio's 'Publish Web Site' from publishing my _ReSharper folder?
|asp.net|visual-studio|deployment|
It's really quite annoying as they are not part of the project.
Have you tried adding the autocomplete="off" attribute in the input tag? Not sure if it'll work, but it is worth a try.
From Mozilla's documentation <form name="form1" id="form1" method="post" autocomplete="off" action="http://www.example.com/form.cgi"> [...] </form> http://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion
are all your input boxes set to type=password? That would do it. One of the things you can do, and I'm not at all sure that this is the best answer is to leave input box as an input type and just use javascript and onkeydown event to place stars in the input box instead of having the browser render it. Firefox won't pre-fill that. As an aside, I have had to work on single-page web-apps and I absolutely hate it. Why would you want to take away the user's ability to bookmark pages? To use the back button?
We run log4net (and log4cxx) in highly multi-threaded environments without issue. You will want to be careful how you configure them though. The issue with log4net that Jeff describes pertains to the use of a certain appender. We stick with simple log file appenders on the whole to reduce the impact of logging on the operation of the code. Writing a line to a file is pretty minimal, kicking off another database transaction is very heavy.
IMO, The real answer to this question is whatever works best for you app. I would recommend you benchmark your app using both persistent and non-persistent connections. Maggie Nelson @ [Objectively Oriented][1] posted about this in August and [Robert Swarthout][2] made an accompanying post with some hard numbers. Both are pretty good reads. [1]: http://www.objectivelyoriented.com/2008/08/to_persist_or_not_to_persist.html [2]: http://www.robertswarthout.com/2008/08/benchmarking-of-mysql-persistent-connections-vs-non-persistent-connections/
The Visual Studio Web Deployment addin lets you exclude folders and more. [VS2005][1] [VS2008][2] Also a decent writeup on the [Web Deployment addin][3] [1]: http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx [2]: http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&displaylang=en [3]: http://www.codedigest.com/Articles/VisualStudio/126_Web_Deployment_Project_for_Visual_Studio_2005_and_2008.aspx
I'm thinking of using this one: [Marlon Grech Date Picker][1]. [1]: http://marlongrech.wordpress.com/2007/09/11/wpf-datepicker/
|opengl|c++|glut|
|c++|opengl|glut|
I'm trying to do a simple rotation in OpenGL but must be missing the point. I'm not looking for a specific fix so much as a quick explanation or link that explains OpenGL rotation more generally. At the moment I have code like this: glPushMatrix(); glRotatef(90.0, 0.0, 1.0, 0.0); glBegin(GL_TRIANGLES); glVertex3f( 1.0, 1.0, 0.0 ); glVertex3f( 3.0, 2.0, 0.0 ); glVertex3f( 3.0, 1.0, 0.0 ); glEnd(); glPopMatrix(); But the result is not a triangle rotated 90 degrees. **Edit** Hmm thanks to Mike Haboustak - it appeared my code was calling a SetCamera function that use glOrtho. I'm too new to OpenGL to have any idea of what this meant but disabling this and rotating in the Z-axis produced the desired result. Thanks!
AFAIK, Safari doesn't have a Search plugin capability. You could try [Inquisitor][1]; just add the URL http://stackoverflow.com/search?s=%@ [1]: http://www.inquisitorx.com/safari/index_en.php
I have created an approximation of what I think you are looking for just using the Collections Framework in Java. Frankly, I think it is probably overkill as @Mike Deck points out. For such a small set of items to compare and process I think arrays would be a better choice from a procedural standpoint but here is my pseudo-coded (because I'm lazy) solution. I have an assumption that the Foo class is comparable based on it's unique id and not all of the data in it's contents: Collection<Foo> oldSet = ...; Collection<Foo> newSet = ...; private Collection difference(Collection a, Collection b) { Collection result = a.clone(); result.removeAll(b) return result; } private Collection intersection(Collection a, Collection b) { Collection result = a.clone(); result.retainAll(b) return result; } public doWork() { // if foo is in(*) oldSet but not newSet, call doRemove(foo) Collection removed = difference(oldSet, newSet); if (!removed.isEmpty()) { loop removed { Foo foo = removedIter.next(); doRemove(foo); } } //else if foo is not in oldSet but in newSet, call doAdd(foo) Collection added = difference(newSet, oldSet); if (!added.isEmpty()) { loop added { Foo foo = addedIter.next(); doAdd(foo); } } // else if foo is in both collections but modified, call doUpdate(oldFoo, newFoo) Collection matched = intersection(oldSet, newSet); Comparator comp = new Comparator() { int compare(Object o1, Object o2) { Foo f1, f2; if (o1 instanceof Foo) f1 = (Foo)o1; if (o2 instanceof Foo) f2 = (Foo)o2; return f1.activated == f2.activated ? f1.startdate.compareTo(f2.startdate) == 0 ? ... : f1.startdate.compareTo(f2.startdate) : f1.activated ? 1 : 0; } boolean equals(Object o) { // equal to this Comparator..not used } } loop matched { Foo foo = matchedIter.next(); Foo oldFoo = oldSet.get(foo); Foo newFoo = newSet.get(foo); if (comp.compareTo(oldFoo, newFoo ) != 0) { doUpdate(oldFoo, newFoo); } else { //else if !foo.activated && foo.startDate >= now, call doStart(foo) if (!foo.activated && foo.startDate >= now) doStart(foo); // else if foo.activated && foo.endDate <= now, call doEnd(foo) if (foo.activated && foo.endDate <= now) doEnd(foo); } } } As far as your questions: If I convert oldSet and newSet into HashMap<Foo> (order is not of concern here), with the IDs as keys, would it made the code easier to read and easier to compare? How much of time & memory performance is loss on the conversion? I think that you would probably make the code more readable by using a Map BUT...you would probably use more memory and time during the conversion. Would iterating the two sets and perform the appropriate operation be more efficient and concise? Yes, this would be the best of both worlds especially if you followed @Mike Sharek 's advice of Rolling your own List with the specialized methods or following something like the Visitor Design pattern to run through your collection and process each item.
To make a long story short, java objects have some very peculiar properties. In general, java has primitive types (`int`, `bool`, `char`, `double`, etc) that are passed directly by value. Then java has objects (everything that derives from `java.lang.Object`). Objects are actually always handled through a reference (a reference being a pointer that you can't touch). That means that in effect, objects are passed by value, as the references are normally not interesting. It does however mean that you cannot change which object is pointed to as the reference itself is passed by value. Does this sound strange and confusing? Let's consider how C implements pass by reference and pass by value. In C the default convention is pass by value. `void foo(int x)` passes an int by value. `void foo(int *x)` is a function that does not want an `int a`, but a pointer to an int: `foo(&a)`. One would use this with the `&` operator to pass a variable address. Take this to C++, and we have references. References are basically (in this context) syntactic sugar that hide the pointer part of the equation: `void foo(int &x)` is called by `foo(a)`, where the compiler itself knows that it is a reference and the address of the non-reference `a` should be passed. In java, all variables referring to objects are actually of reference type, in effect forcing call by reference for most intends and purposes without the fine grained control (and complexity) afforded by e.g. C++.
Check out [FlashDevelop][1] for Windows. I like it better than Flex Builder. [1]: http://www.flashdevelop.org
[@Jan][1] Checked versus unchecked is a central issue here. I question your supposition (#3) that the exception should be ignored in intervening frames. If I do that, I will end up with an implementation-specific dependency in my high-level code. If I replace Hibernate, catch blocks throughout my application will have to be modified. Yet, at the same time, if I catch the exception at a lower level, I'm not receiving much benefit from using an unchecked exception. Also, the scenario here is that I want to catch a specific logical error and change the flow of the application by re-prompting the user for a different ID. Simply changing the displayed message is not good enough, and the ability to map to different messages based on exception type is built into Servlets already. [1]: http://stackoverflow.com/questions/33497/how-do-i-recover-from-an-unchecked-exception#39769
Just as a side note, you can implement state machines with proper tail calls like I explained in the [tail recursion][1] question. In that exemple each room in the game is considered one state. Also, Hardware design with VHDL (and other logic synthesis languages) uses state machines everywhere to describe hardware. [1]: http://stackoverflow.com/questions/33923/tail-recursion#34540
Absolutely. I've been a Flex developer since Flex 2 and until recently I've used my regular editor, TextMate, for coding and Ant for building. TextMate has some good extensions for ActionScript and Flex coding, but I think you could get that for any decent editor. What's been missing from my setup is a usable debugger, the command line version is a pain to work with. Because of that I've been starting to use FlexBuilder on the side, using it in parallel with my regular setup. Having a profiler doesn't hurt too.
1. Use "ldd" to list shared libraries for each executable. 2. Cleanup the output 3. Sort, compute counts, sort by count To find the answer for all executables in the "/bin" directory: find /bin -type f -perm /a+x -exec ldd {} \; \ | grep -P '\t.*so' \ | sed -e 's/\t//' \ | sed -e 's/.*=..//' \ | sed -e 's/ (0.*)//' \ | sort \ | uniq -c \ | sort -n Change "/bin" above to "/" to search all directories. Output (for just the /bin directory) will look something like this: 1 /lib64/libexpat.so.0 1 /lib64/libgcc_s.so.1 1 /lib64/libnsl.so.1 1 /lib64/libpcre.so.0 1 /lib64/libproc-3.2.7.so 1 /usr/lib64/libbeecrypt.so.6 1 /usr/lib64/libbz2.so.1 1 /usr/lib64/libelf.so.1 1 /usr/lib64/libpopt.so.0 1 /usr/lib64/librpm-4.4.so 1 /usr/lib64/librpmdb-4.4.so 1 /usr/lib64/librpmio-4.4.so 1 /usr/lib64/libsqlite3.so.0 1 /usr/lib64/libstdc++.so.6 1 /usr/lib64/libz.so.1 2 /lib64/libasound.so.2 2 /lib64/libblkid.so.1 2 /lib64/libdevmapper.so.1.02 2 /lib64/libpam_misc.so.0 2 /lib64/libpam.so.0 2 /lib64/libuuid.so.1 3 /lib64/libaudit.so.0 3 /lib64/libcrypt.so.1 3 /lib64/libdbus-1.so.3 4 /lib64/libresolv.so.2 4 /lib64/libtermcap.so.2 5 /lib64/libacl.so.1 5 /lib64/libattr.so.1 5 /lib64/libcap.so.1 6 /lib64/librt.so.1 7 /lib64/libm.so.6 9 /lib64/libpthread.so.0 13 /lib64/libselinux.so.1 13 /lib64/libsepol.so.1 22 /lib64/libdl.so.2 83 /lib64/ld-linux-x86-64.so.2 83 /lib64/libc.so.6
1. Use "ldd" to list shared libraries for each executable. 2. Cleanup the output 3. Sort, compute counts, sort by count To find the answer for all executables in the "/bin" directory: find /bin -type f -perm /a+x -exec ldd {} \; \ | grep so \ | sed -e '/^[^\t]/ d' \ | sed -e 's/\t//' \ | sed -e 's/.*=..//' \ | sed -e 's/ (0.*)//' \ | sort \ | uniq -c \ | sort -n Change "/bin" above to "/" to search all directories. Output (for just the /bin directory) will look something like this: 1 /lib64/libexpat.so.0 1 /lib64/libgcc_s.so.1 1 /lib64/libnsl.so.1 1 /lib64/libpcre.so.0 1 /lib64/libproc-3.2.7.so 1 /usr/lib64/libbeecrypt.so.6 1 /usr/lib64/libbz2.so.1 1 /usr/lib64/libelf.so.1 1 /usr/lib64/libpopt.so.0 1 /usr/lib64/librpm-4.4.so 1 /usr/lib64/librpmdb-4.4.so 1 /usr/lib64/librpmio-4.4.so 1 /usr/lib64/libsqlite3.so.0 1 /usr/lib64/libstdc++.so.6 1 /usr/lib64/libz.so.1 2 /lib64/libasound.so.2 2 /lib64/libblkid.so.1 2 /lib64/libdevmapper.so.1.02 2 /lib64/libpam_misc.so.0 2 /lib64/libpam.so.0 2 /lib64/libuuid.so.1 3 /lib64/libaudit.so.0 3 /lib64/libcrypt.so.1 3 /lib64/libdbus-1.so.3 4 /lib64/libresolv.so.2 4 /lib64/libtermcap.so.2 5 /lib64/libacl.so.1 5 /lib64/libattr.so.1 5 /lib64/libcap.so.1 6 /lib64/librt.so.1 7 /lib64/libm.so.6 9 /lib64/libpthread.so.0 13 /lib64/libselinux.so.1 13 /lib64/libsepol.so.1 22 /lib64/libdl.so.2 83 /lib64/ld-linux-x86-64.so.2 83 /lib64/libc.so.6 Edit - Removed "grep -P"
1. Use "ldd" to list shared libraries for each executable. 2. Cleanup the output 3. Sort, compute counts, sort by count To find the answer for all executables in the "/bin" directory: find /bin -type f -perm /a+x -exec ldd {} \; \ | grep -P '\t.*so' \ | sed -e 's/\t//' \ | sed -e 's/.*=..//' \ | sed -e 's/ (0.*)//' \ | sort \ | uniq -c \ | sort -n Change "/bin" above to "/" to search all directories. Output (for just the /bin directory) will look something like this: 1 /lib64/libexpat.so.0 1 /lib64/libgcc_s.so.1 1 /lib64/libnsl.so.1 1 /lib64/libpcre.so.0 1 /lib64/libproc-3.2.7.so 1 /usr/lib64/libbeecrypt.so.6 1 /usr/lib64/libbz2.so.1 1 /usr/lib64/libelf.so.1 1 /usr/lib64/libpopt.so.0 1 /usr/lib64/librpm-4.4.so 1 /usr/lib64/librpmdb-4.4.so 1 /usr/lib64/librpmio-4.4.so 1 /usr/lib64/libsqlite3.so.0 1 /usr/lib64/libstdc++.so.6 1 /usr/lib64/libz.so.1 2 /lib64/libasound.so.2 2 /lib64/libblkid.so.1 2 /lib64/libdevmapper.so.1.02 2 /lib64/libpam_misc.so.0 2 /lib64/libpam.so.0 2 /lib64/libuuid.so.1 3 /lib64/libaudit.so.0 3 /lib64/libcrypt.so.1 3 /lib64/libdbus-1.so.3 4 /lib64/libresolv.so.2 4 /lib64/libtermcap.so.2 5 /lib64/libacl.so.1 5 /lib64/libattr.so.1 5 /lib64/libcap.so.1 6 /lib64/librt.so.1 7 /lib64/libm.so.6 9 /lib64/libpthread.so.0 13 /lib64/libselinux.so.1 13 /lib64/libsepol.so.1 22 /lib64/libdl.so.2 83 /lib64/ld-linux-x86-64.so.2 83 /lib64/libc.so.6 In response to a question on "grep -P ...": The grep command tests for a tab character followed by any string followed by "so". Without -P I had trouble testing for the tab character. Without testing for the tab character, the grep command runs the risk of matching executables that contain the string "so" (the point of this grep is to include only lines that include shared libraries.)
A jump table is described [here][1], but briefly, it's an array of addresses the CPU should jump to based on certain conditions. As an example, a C switch statement is often implemented as a jump table where each jump entry will go to a particular "case" label. In embedded systems, where memory usage is at a premium, many constructs are better served by using a jump table instead of more memory-intensive methods (like a massive if-else-if). [1]: http://en.wikipedia.org/wiki/Jump_table
[Wikipedia][1] sums it up pretty well: > In computer programming, a branch > table (sometimes known as a jump > table) is a term used to describe an > efficient method of transferring > program control (branching) to another > part of a program (or a different > program that may have been dynamically > loaded) using a table of branch > instructions. The branch table > construction is commonly used when > programming in assembly language but > may also be generated by a compiler. > ... Use of branch tables and other raw > data encoding was common in the early > days of computing when memory was > expensive, CPUs were slower and > compact data representation and > efficient choice of alternatives were > important. Nowadays, they are commonly > used in embedded programming and > operating system development. In other words, it's a useful construct to use when your system is extremely memory and/or CPU limited, as is often the case in an embedded platform. [1]: http://en.wikipedia.org/wiki/Jump_table
There's several reasons to avoid inline/internal Javascript: - HTML is for **structure**, not behavior or style. For the same reason you should not put CSS directly in HTML elements, you should not put JS. - If your client does not support JS you just pushed a lot of junk. Wasted bandwith. - External JS files are cached. That saves some bandwith. - You'll have a **descentralized** javascript. That leads to code repetition and all the known problemns that comes with it.
If you are specifically looking at how Google does it. If you look at the [PDF Properties][1] page, they use Prince 6.0 (see [princexml.com][2]) There are lots of other PDF generators out there. I've had great success with [PDFlib][3] for tricky jobs. ![alt text][4] [1]: http://docs.google.com/Doc?id=dd8xj6nh_2q9zprkd6 "I've embedded the image in a document here" [2]: http://www.princexml.com/ [3]: http://www.pdflib.com/ [4]: http://docs.google.com/File?id=dd8xj6nh_4g2836gdn_b "This may not be available, if not follow the above link to Google Docs"
Jump tables, more often known as a Branch table, are usually used only by the machine. The compiler creates a list of all labels in a assembly program and links all labels to a a memory location. A jump table pretty much is a reference card to where, a function or variable or what ever the label maybe, is stored in memory. So as a function executes, on finishing it jumps back to it's previous memory location or jumps to the next function, etc. And If your talking about what I think you are, you don't just need them in embedded systems but in any type of compiled/interpreted environment. Brian Gianforcaro
Deleting messages from Exchange IMAP mailbox on iPhone
Why doesn't JavaScript support multithreading?
|javascript|browser|
|javascript|browser|duplicate|
|javascript|browser|multithreading|duplicate|
|javascript|browser|multithreading|
Would it be too much of an effort just to have the value hard-coded into the URL (I know it's not too nice) with a default value or true then just have `booleanVar = !booleanVar;` run on every page load? At least that would move away from the need of having nested ifs to manipulate the URL.
MySQL can import CSV files very quickly onto tables using the [`LOAD DATA INFILE`][1] command. It can also read from CSV files directly, bypassing any import procedures, by using the [CSV storage engine][2]. Importing it onto native tables with `LOAD DATA INFILE` has a start up cost, but after that you can `INSERT/UPDATE` much faster, as well as index fields. Using the CSV storage engine is almost instantaneous at first, but only sequential scan will be fast. [1]: http://dev.mysql.com/doc/refman/5.0/en/load-data.html [2]: http://dev.mysql.com/doc/refman/5.0/en/csv-storage-engine.html
MySQL can import CSV files very quickly onto tables using the [`LOAD DATA INFILE`][1] command. It can also read from CSV files directly, bypassing any import procedures, by using the [CSV storage engine][2]. Importing it onto native tables with `LOAD DATA INFILE` has a start up cost, but after that you can `INSERT/UPDATE` much faster, as well as index fields. Using the CSV storage engine is almost instantaneous at first, but only sequential scan will be fast. **Update**: [This article][3] (scroll down to the section titled *Instant Data Loads*) talks about using both approaches to loading CSV data onto MySQL, and gives examples. [1]: http://dev.mysql.com/doc/refman/5.0/en/load-data.html [2]: http://dev.mysql.com/doc/refman/5.0/en/csv-storage-engine.html [3]: http://dev.mysql.com/tech-resources/articles/csv-storage-engine.html
F# is part of the ML family of languages and is very close to OCaml. You may want to read this discussion on the [differences between Haskell and OCaml](http://www.oreillynet.com/mac/blog/2006/03/haskell_vs_ocamlwhich_do_you_p.html).
I am not sure based upon the question, but isn't this where [HTTPHandlers][1] come to the rescue? Shouldn't you be handling the variable alteration on the object prior to page rendering in this case then? [1]: http://msdn.microsoft.com/en-us/library/ms227675(VS.80).aspx
Just to elaborate on Toran's answer: Use: `<asp:HiddenField ID="ShowAll" Value="False" runat="server" />` To toggle your state: protected void ToggleState(object sender, EventArgs e) { //parse string as boolean, invert, and convert back to string ShowAll.Value = (!Boolean.Parse(ShowAll.Value)).ToString(); }
It's worth knowing that the date format you have given is not an arbitrary one. It is the output of the built-in Date.toString() method (at least in the UK and US locales). Not coincidentally, it is also the format of the unix 'date' command (at least on linux, and I believe in other implementations too) - though to be pedantic, Date.toString() pads one-digit day numbers with a zero while unix date does not. What this means is that you are likely to receive this input format when you output an unformatted date into a user-modifiable field (e.g. an HTML INPUT field) and receive it back unmodified. So just because input is coming in this format, doesn't mean the users will type in a thousand other arbitrary formats. Of course, they still might. The way I handle date inputs in general is with a bunch of try/catch blocks, where I try it against one format, then another, then another. Our standard framework is now up to about 20 different formats by default. Of course it is still not perfect; I found someone the other day entering "03 Sept" as the date (a non-standard month abbreviation, and with no year) and we hadn't handled that scenario.
TreeView Drag & Drop help - _Invalid FORMATETC structure_ exception
|c#|.net|winforms|
I'm trying to implement Drag & Drop functionality with source being a TreeView control. When I initiate a drag on a node, I'm getting: _Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV\_E\_FORMATETC))_ The ItemDrag handler (where the exception takes place), looks like: private void treeView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) { this.DoDragDrop(e.Item, DragDropEffects.Move); } Does anyone know the root cause of this and how to remedy it? (.NET 2.0, Windows XP SP2)
This sounds more like a use case for a collaborative tool like [BaseCamp][1], [SpiceBird][2], or SharePoint than "source control." Those tools have the same aim as source control but are more geared toward Word Document type stuff and the corresponding users. It's one more item for the IT folks to maintain on the server but it also removes the possibility of someone's assistant wiping out your code. [1]: http://www.basecamphq.com/?source=37s+home [2]: http://www.spicebird.com/
This sounds more like a use case for a collaborative tool like [BaseCamp][1],<strike> [SpiceBird][2]</strike>, or SharePoint than "source control." Those tools have the same aim as source control but are more geared toward Word Document type stuff and the corresponding users. It's one more item for the IT folks to maintain on the server but it also removes the possibility of someone's assistant wiping out your code. [1]: http://www.basecamphq.com/?source=37s+home [2]: http://www.spicebird.com/
What happens when the uninstall of the previous version fails depends on the sequencing of the RemoveExistingProducts action. I have written a summary about the various options in the past: [http://jpassing.wordpress.com/2007/06/16/where-to-place-removeexistingproducts-in-a-major-msi-upgrade/][1]. Unfortunately, you do not have control over RemoveExistingProducts sequencing when using VS setup projects (Unless you edit the MSI with Orca after it has been built, which usually is not practical). But if your setup project is not completely trivial, I would strongly suggest you to use a different MSI authoring tool like WiX or one of the commercial tools anyway. [1]: http://jpassing.wordpress.com/2007/06/16/where-to-place-removeexistingproducts-in-a-major-msi-upgrade/
Get CPU usage in shell script?
|linux|shell|scripting|
I'm running some [JMeter][1] tests against a Java process to determine how responsive a web application is under load (500+ users). JMeter will give the response time for each web request, and I've written a script to ping the Tomcat Manager every X seconds which will get me the current size of the JVM heap. I'd like to collect stats on the server of the % of CPU being used by Tomcat. I tried to do it in a shell script using `ps` like this: PS_RESULTS=`ps -o pcpu,pmem,nlwp -p $PID` ... running the command every X seconds and appending the results to a text file. However I've found that this gives a different definition of "% of CPU Utilization" than I'd like - according to the manpages for ps, `pcpu` is defined as: >cpu utilization of the process in "##.#" format. It is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage. In other words, `pcpu` gives me the % CPU utilization for the process for the *lifetime* of the process. Since I want to take a sample every X seconds, I'd like to be collecting the CPU utilization of the process at the current time only - similar to what `top` would give me (CPU utilization of the process since the last update). How can I collect this from within a shell script? [1]: http://jakarta.apache.org/jmeter/
Named pipes. Create a series of fifos, using mkfifo i.e fifo0, fifo1 Then attach each process in term to the pipes you want: processn < fifo(n-1) > fifon
A named pipe might do it: $ mkfifo outside $ <outside calc | square >outside & $ echo "1" >outside ## Trigger the loop to start
If you need a simple stochastic process, you might use a Markov chain, which can be represented as a state machine (given the current state, at the next step the chain will be in state X with a certain probability).
[Mollom][1] is another [askimet][2] type service which may be of interest. From the guys who wrote drupal / run acquia. [1]: http://mollom.com "Mollom" [2]: http://akismet.com/development/
Short answer: Yes I'm working on a team of developers and designers. We code our .MXML and .AS in [FlashDevelop 3][1] and our designer creates .FLA with skins and widgets that get [Import()]ed in ActionScript. I wrote a little more about this subject here: http://stackoverflow.com/questions/25356/flash-designercoder-collaboration-best-practices#25533 [1]: http://www.flashdevelop.org/community/
Now you have provided us with some more clues about the nature of your question, namely mentioning COM, I think I understand what you mean. COM can marshal only a subset of the types Delphi knows between a COM server and client. You can define enums in the TLB editor, but these are all of the type TOleEnum which basically is an integer type (LongWord). You can have a variable of the type TOleEnum any integer value you want and assign values of different enum types to each other. Not really type safe. I can not think of a reason why Delphi's COM can't use the type safe enums instead, but it doesn't. I am afraid nothing much can be done about that. Maybe the changes in the TLB editor in the upcoming Delphi 2009 version might change that. For the record: When the TLB editor is not used, Delphi is perfectly able to have interface with methods who have type safe enums as parameters.
Check if a record exists in a VB6 collection?
|vb6|collections|
I've inherited a large VB6 app at my current workplace. I'm kinda learning VB6 on the job and there are a number of problems I'm having. The major issue at the moment is I can't figure out how to check if a key exists in a Collection object. Can anyone help?
Any workflow application, especially with asynchronous activities. You have an item in the workflow in a certain state, and the state machine knows how to react to external events by placing the item in a different state, at which point some other activity occurs.
There are a couple of really, really old tricks I'm surprised to not see here. atan(1) == PI/4, so an old chestnut when a trustworthy arc-tangent function is present is 4*atan(1). A very cute, fixed-ratio estimate that makes the old Western 22/7 look like dirt is 355/113, which is good to several decimal places (at least three or four, I think). In some cases, this is even good enough for integer arithmetic: multiply by 355 then divide by 113. 355/113 is also easy to commit to memory (for some people anyway): count one, one, three, three, five, five and remember that you're naming the digits in the denominator and numerator (if you forget which triplet goes on top, a microsecond's thought is usually going to straighten it out). Note that 22/7 gives you: 3.14285714, which is wrong at the thousandths. 355/113 gives you 3.14159292 which isn't wrong until the ten-millionths. Acc. to /usr/include/math.h on my box, M_PI is #define'd as: 3.14159265358979323846 which is probably good out as far as it goes. The lesson you get from estimating PI is that there are lots of ways of doing it, none will ever be perfect, and you have to sort them out by intended use. 355/113 is an old Chinese estimate, and I believe it pre-dates 22/7 by many years. It was taught me by a physics professor when I was an undergrad.
|iphone|exchange-server|imap|
I have a secondary Exchange mailbox configured on my iPhone using IMAP. This all appears to work fine except when a message is deleted on the phone, it still shows normally in Outlook. It does not seem to matter what I set the "remove deleted messages" setting to on the phone. I understand this is due to a combination of the phone not expunging the deleted messages and Exchange showing deleted but not expunged messages in Outlook. I'm looking for an automated solution to this that does not have a large delay between deleting the message on the phone and it disappearing in Outlook. The message should also show in the Deleted Items when deleted from the phone.