instruction stringlengths 0 30k ⌀ |
|---|
I like the XMLReader class for it's simplicity and speed. But I like the xml_parse associated functions as it better allows for error recovery. It would be nice if the XMLReader class would throw exceptions for things like invalid entity refs instead of just issuinng a warning. |
There are a couple of different ways to approach the problem:
1. Wrap command-line programs
2. use a Python library that provides SSH capabilities (eg - [Paramiko](http://www.lag.net/paramiko/) or [Twisted Conch](http://twistedmatrix.com/trac/wiki/TwistedConch))
Each approach has its own quirks. You will need to... |
Depending on the applications use, **I would recommend using SQL Lite** because it doesn't require you to install any other software (SQL CE or Express, etc. usually would require a separate install).
A list of the most important benefits for SQL Lite from the provider link at the bottom of this post:
> SQLite is... |
STL maps and sets are both sorted containers.
I second Doug T's book recommendation - the Josuttis STL book is the best I've ever seen as both a learning and reference book.
[Effective STL][1] is also an excellent book for learning the inner details of STL and what you should and shouldn't do.
[1]: http://... |
Here is the general workflow that you'd use with a non-centralized source control system like CVS or Subversion: At first you import your current project into the so-called repository, a versioned storage of all your files. Take care only to import hand-generated files (source, data files, makefiles, project files). Ge... |
document.getElementById('leaveCode').value = '10';
That should set the selection to "Annual Leave" |
Instead of using the Sun JDK Time/Date libraries (which leave much to be desired) I recommend taking a look at [http://joda-time.sourceforge.net][1].
This is a very mature and active sourceforge project and has a very elegant API.
[1]: http://joda-time.sourceforge.net |
TFS doesn't provide any mechanism for searching the contents of source control. Although all the source is stored in a SQL database, it's not in a format that the SQL FullText Search engine can index.
Your current solution of using Windows Search is about the best you can get.
Another option would be to setup a '... |
You could be using a class as class generator. Like (in some off the cuff code :)
class gen(object):
class base_1(object): pass
...
class base_n(object): pass
def __init__(self, ...):
...
def mk_cls(self, ..., type):
'''makes a class ba... |
Is XSLT worth it? |
|xslt|xml| |
A while ago, I started on a project where I designed a html-esque XML schema so that authors could write their content (educational course material) in a simplified format which would then be transformed into HTML via XSLT. I played around (struggled) with it for a while and got it to a very basic level but then was to... |
|xml|xslt| |
A while ago, I started on a project where I designed a html-esque XML schema so that authors could write their content (educational course material) in a simplified format which would then be transformed into HTML via XSLT. I played around (struggled) with it for a while and got it to a very basic level but then was to... |
I assume your combobox is a control on a form, not a combobox control in a commandBar. This combobox has a property called rowsource, that can be either a value list (husband;wife;son;girl) or a SQL SELECT instruction (SELECT relationDescription FROM Table_relationType).
I assume also that your form recordset has s... |
Best way to tackle global hotkey processing in c#? |
|c#|global|hotkeys| |
I'd like to have multiple global hotkeys in my new app (to control the app from anywhere in windows), and all of the given sources/solutions I found on the web seem to provide with a sort of a limping solution (either solutions only for one g.hotkey, or solutions that while running create annoying mouse delays on the s... |
My little guidelines are heavily influenced by the great book "Code complete":
- Use exceptions to notify about things that should not be ignored.
- Don't use exceptions if the error can be handled locally
- Make sure the exceptions are at the same level of abstraction as the rest of your routine.
- Except... |
The easiest way is to guarantee that the combobox is always up-to-date is to just requery the combobox once it gets the focus. Even if the recordset is then updated somewhere else, your combobox is always up-to-date. A simple TheCombobox.Requery in the OnFocus event should be enough. |
You need the [SQLite JDBC driver][1] (this page explains how to run queries on a SQLite database using that driver from within Java).
[1]: http://www.zentus.com/sqlitejdbc/ |
In Visual Studio 2008, how can I make control+click do a "Go To Definition"? |
|visual-studio|.net|ide| |
I know this is not strictly about programming, but it's pretty close.
Anyway, in Delphi, you can hold control and click on a method to jump to its definition. In VS2008, you have to right-click and select "Go To Definition".
I use this function quite often, so I'd really like to get VS to behave like delphi in th... |
I know this is not strictly about programming, but it's pretty close.
Anyway, in Delphi, you can hold control and click on a method to jump to its definition. In VS2008, you have to right-click and select "Go To Definition".
I use this function quite often, so I'd really like to get VS to behave like delphi in th... |
The answer heavily depends on your requirements... But I would expect only storing a record with the start and stop date for their stay is needed. If you explain your question more, we can give you more details. |
Becaus sed isn't very well setup for non-ASCII text. However you can use (almost) the same code in perl and get the result you want:
perl -pe 's/.*\| //' x |
Some questions you need to ask yourself:
- Is there a reason you need a record for each day of the stay?
- Could you not just have a table for the stay and have an arrival date and either a number of nights or a departure date?
- Is there specific bits of data that differ from day to day relating to one cust... |
A tuple-per-day is a bit overkill, I think. A few columns on a "stay" table should suffice.
stay.check_in_time_scheduled
stay.check_in_time_actual
stay.check_out_time_scheduled
stay.check_out_time_actual |
Have a cute, disarming image and/or backup page. Some sites implement simple javascript games to keep you busy while waiting for the update.
Eg, fail whale.
-Adam |
Can't you just write a link to a "zip server" or whatnot? Why does the zip archive itself need to be served from Django? A 90's era CGI script to generate a zip and spit it to stdout is really all that's required here, at least as far as I can see. |
Here is another workaround, also useful when you need to partialy specialize a function (which is not allowed). Create a template functor class (ie. class whose sole purpose is to execute a single member function, usually named operator() ), specialize it and then call from within your template function.
I think I l... |
Is creating a record for each day a person stays neccessary? It should only be neccessary if each day is significant, otherwise have a Customer/Guest table to contain the customer details, a Booking table to contain bookings for guests. Booking table would contain room, start date, end date, guest (or guests), etc.
... |
IMHO long downtimes (hours) are acceptable for a free site. If you educate your users enough they'll understand that it's a necessity. Maybe give them something to play with until the website goes back up (eg. flash game, webcam live feed showing the dev team at work, etc). For a website that people pay to access, a lo... |
This is the way i do it. There's probably an easier way but this works for me.
Edit: sorry, i overlooked that you want it as a list. I don't know how to do that...
Edit2: maybe you can map it as a protected IList[string], and convert to public IList[EAction] just as i do with a simple property.
public virt... |
Heres a different way (not necessarily the shortest but it also handles the 1 hour and many hours...
<?php
// your time
$var = "00:00:00";
if(substr($var, 0, 2) == 0){
$myTime = substr_replace(substr_replace($var, '', 0, 3), ' Minutes, ', 2, 1);
}
elseif(substr($var, 1, 1) ==... |
Heres a different way, with different functions which is more open and a more step by step for newbies. it also handles the 1 hour and many hours... you could try use the same logic to handle the 0 minutes and 0 seconds.
<?php
// your time
$var = "00:00:00";
if(substr($var, 0, 2) == 0){
... |
The answer here is going to be highly dependent on your operating system, can you provide more information? I have found that file open times under Linux have been reasonable up to directory sizes in the small tens of thousands, but I have not tried any tests with directory structures as large as yours (you do know th... |
Your example should be modfied so it does not have external dependencies, it now depends on Nz and addLog.
Anyway, the problem here seems to be that you are looping from 0 to len()-1. In VBA this would be 1 to n.
Dim cell_val As String
cell_val = "øabcdæøå~!#%&/()"
Dim iter As Long
For iter... |
cat dump.txt | head -16224 | tail -258
should do the trick. The downside of this approach is that you need to do the arithmetic to determine the argument for tail and to account for whether you want the 'between' to include the ending line or not. |
Another alternative besides the ones already mentioned is Continuity; however, it is (as the name is meant to imply) continuation-based rather than MVC in the typical sense. However, it is one of the better Perl web frameworks.
That said, I like Catalyst much better than any of the alternatives, and even so it is st... |
Another alternative besides the ones already mentioned is Continuity; however, it is (as the name is meant to imply) continuation-based rather than MVC in the typical sense. Still, it’s worth mentioning because it is one of the better Perl web frameworks.
That said, I like Catalyst much better than any of the altern... |
I used reflektor for fun a bit, but right now I'm not using it at all.
Since we got all source for our c# programs there is no real need to decompile anything. |
I was about to post the head/tail trick, but actually I'd probably just fire up emacs. ;-)
esc-x goto-line[ret] 16224
mark (ctl-space)
esc-x goto-line[ret] 16482
esc-w
open the new output file, ctl-y
save
Let's me see what's happening.
|
I remember when I first started learning emacs, it was after I was already very comfortable with Vim, and I was in the same or similar boat that you were, where I knew how to get a lot done in another editor, so as I started using emacs, it was always painfully slow.
However, I think what you'll have to do is just a... |
What you want is a queue.
Check out the reference page http://docs.jquery.com/Effects/queue for some working examples. |
Depending on your update frequency one of my favorites is the CopyOnWriteArrayList or CopyOnWriteArraySet. They create a new list/set on updates to avoid concurrent modification exception. |
Since you need to accommodate many different phone number formats (and probably include things like extensions etc.) it may make the most sense to just treat it as you would any other varchar. If you could control the input, you could take a number of approaches to make the data more useful, but it doesn't sound that w... |
You should describe how your Benchmark was done. Especially at which point you start to measure the time.
If you include the JVM startup time (which is useful for Benchmarking the User experience but not so useful to optimize Java code) then it might be a filesystem caching effect or it can be caused by a feature c... |
|.net|visual-studio|ide| |
I know this is not strictly about programming, but it's pretty close.
Anyway, in Delphi, you can hold control and click on a method to jump to its definition. In VS2008, you have to right-click and select "Go To Definition".
I use this function quite often, so I'd really like to get VS to behave like delphi in th... |
Auto-generating Unit-Tests for legacy Java-code |
|java|unit-testing|legacy| |
What is the best, preferably free/open source tool for auto-generating Java unit-tests? I know, the unit-tests cannot really serve the same purpose as normal TDD Unit-Tests which document and drive the design of the system. However auto-generated unit-tests can be useful if you have a huge legacy codebase and want to k... |
Yes it's supported by the kernel and the filesystem, but since it's not intended for general usage it's not exposed to the shell.
You could probably work out which APIs Time Machine uses and wrap them in a commandline tool, but it'd be better to take the hint and steer well-clear. |
It's simple:
Let n be the normal of the plane and x be the point.
n_u = n/norm(n) //this is a normal vector of unit length
d = scalarprod(n,x) //this is the distance of the plane to the origin
for each point p_i
d_i = abs(scalarprod(p_i,n) - d) //this is the distance of the poi... |
ACCESS databases all use UTF-8 encoding since (at least) version 2000 |
Production, Test, Developer Environments vs Security |
null |
What are current practices for enabling developers to build systems that contain private data? Can anyone point to a "best practices" guide for that sort of thing?
We have a Catch-22 here in that developers need to write applications that go against systems that have data that is considered "private." The IT adminis... |
use !==false instead of ===true<br />
stripos returns the position as an integer if the needle is found. And that's never ===bool.
<br />
You might also be interested in PHP's <a href="http://de2.php.net/tokenizer">tokenizer module</a> or the <a href="http://pear.php.net/package/PHP_LexerGenerator">lexer package</a>... |
You may want to look at the permissions for the table you are selecting from, if you are connecting to the server as a different user from each machine.
If some users but not others have access to read that table, you may get the result you describe. |
SoundPlayer crash on Vista |
|c#|winforms|windows-vista|audio| |
The following code is causing an intermittent crash on a Vista machine.
using (SoundPlayer myPlayer = new SoundPlayer(Properties.Resources.BEEPPURE))
myPlayer.Play();
I highly suspect it is this code because the prgram crashes mid-beep or just before the beep is played every time. I have top-level ... |
The following code is causing an intermittent crash on a Vista machine.
using (SoundPlayer myPlayer = new SoundPlayer(Properties.Resources.BEEPPURE))
myPlayer.Play();
I highly suspect it is this code because the prgram crashes mid-beep or just before the beep is played every time. I have top-level ... |
The only way I think then to get the functionality you want would be to do something like
<code>
import junit.framework.Test;
import junit.framework.TestResult;
import junit.framework.TestSuite;
public class AllTests {
public static Test suite() {
TestSuite suite = new TestSuite("TestEverything"); ... |
Why are you using the === Argument?
If it is anywhere in the line, it will be an integer. You're comparing the type also by using ====
From my understand you're asking it "If the position is equal and of the same type as true" which will never work. |
As you said, you can't really do it because of type erasure. You can sort of do it using reflection, but it requires a lot of code and lot of error handling. |
Yes, simple.
say you have
char *a = new char[10];
writing in the debugger:
a,10
would show you the content as if it were an array. |
In a watch window, add a comma after the name of the array, and the amount of items you want to be displayed. |
SVN with the TortoiseSVN add-on makes for a solid and easy to use interface. WinMerge is a great tool to thrown in that mix as well. |
[The Java EE 5 Tutorial][1] - read online or as pdf
[EJB 3 in Action][2] - great book that covers everything you need to know
[1]: http://java.sun.com/javaee/5/docs/tutorial/doc/
[2]: http://www.manning.com/panda/ |
[The Java EE 5 Tutorial][1] - read online or as pdf
[EJB 3 in Action][2] - great book that covers everything you need to know
[1]: http://java.sun.com/javaee/5/docs/tutorial/doc/
[2]: http://www.manning.com/panda/
I have also recently started with Java EE and I have only used Glassfish/Sun Application S... |
TestNG will run all the public methods from a class with a @Test annotation. Maybe you could change the methods you don't want TestNG to run to be non-public |
use the command line parameter -XX:MaxPermGen=128m for a Sun JVM. (obviously substituting 128 for whatever size you need) |
And when you need to inject it back into some other DOM (like your HTML page) you can export it again using the $dom->saveXML() method. The problem however is that it also exports an xml header (it's even worse for the saveHTML version). To get rid of that use this:
$xml = $dom->saveXML();
$xml = substr( $x... |
Can I see the currently checked out revision number in Tortoise SVN ? |
|tortoisesvn| |
I'd like to know what the currently checked out revision number is for a file or directory. Is there a way to do this in TortoiseSVN on Windows ? |
|version-control|tortoisesvn| |
Change your Explorer windows to Details View. Navigate to an SVN-controlled folder then go to View > Choose Details and select the SVN columns for status/rev/etc. |
I love Project Euler.
On the subject of prime generators, I am a big fan of the Sieve of Eratosthenes.
For the purposes of the numbers under 2,000,000 you might try a simple isPrime check implementation. I don't know how you'd do it in erlang, but the logic is simple.
For Each NUMBER in LIST_OF_PRIMES
... |
For years, I've tried to convince people that they needed to write unit test for their code. Whether they wrote the tests first (as in TDD) or after they coded the functionality, I always tried to explain them all the benefits of having unit tests for code. Hardly anyone disagreed with me. You cannot disagree with some... |
The successor to the repeater is the [ListView](https://web.archive.org/web/20210616112920/https://aspnet.4guysfromrolla.com/articles/010208-1.aspx), which will also help you handcraft your HTML. |
text watermark on website? how to do it? |
|html|watermark| |
I am a C++/C# developer and never spent time working on web pages. I would like to put text (randomly and diagonally perhaps) in large letters across the background of some pages. I want to be able to read the foreground text and also be able to read the "watermark". I understand that is probably more of a function ... |
I like configuring the command-line history stuff in my .bash_login (or .bashrc).
Setting the following makes bash erase duplicate commands in your history:
export HISTCONTROL="erasedups:ignoreboth"
I also jack my history size up pretty high too. Why not? It doesn't seem to slow anything down on today's... |
I remember seeing a free C++ library that gave you a Web-base UI.
Didn't try it, and can't remember it's name but that could the trick if you want C++.
Or perhaps I'd go with Adobe's Air or Google's Gear stuff.
if you want something you can do over a weekend. |
Reading Unformatted Data |
|windows|c| |
In C, using the standard Windows API, what is the best way to read an unformatted disk? Specifically, I have an [MMC][1] or [SD card][2] with data, but no file system (not FAT16, not FAT32, just raw data). If there was a simple way to open the entire card for byte by byte binary access, that would be great.
Thanks!
... |
PHP iconv()
<code>iconv("UTF-8", "ISO-8859-15", $input);</code> |
I'm relatively new to TDD and unit testing, but in the two side projects I've used it on, I've found it to be a design _aide_ rather than alternative to design. The abilty to test and verify components / sub-components independently has made it easier for me to make rapid changes and try out new design ideas.
The d... |
Seems like you'd just want to write an test app to generate 1024 folders, iterated 8 levels down, with each folder containing some number (100 - 1000?) of files 1KB in size and then randomly find and access the files.
Track the access times over multiple passes and see if it's acceptable to your requirements. |
I don't think your regex is correct.
First you need to start with ^ or else it will match this pattern anywhere on the line.
Second, the `..` should be `\/\/` or else it will match any two characters.
`^\/\/#[^\n]*` is probably what you want.
Then do what EricSchaefer says and read the file line by line onl... |
The easiest way is dbexport/dbimport, as others have mentioned.
The fastest way is using onpload, the High Performance Loader. If you have lots of data, but not a ridiculous number of tables, this is definitely worth pursuing. There are some bits and pieces on the IIUG site that may be of assistance in scripting the... |
Try setting it to: "C:\Programs\Vim \vim72\gvim.exe" -p --remote-tab-silent "%1" "%*"
See: http://www.vim.org/tips/tip.php?tip_id=1314 |
Try setting it to: "C:\Programs\Vim \vim72\gvim.exe" -p --remote-tab-silent "%1" "%*"
See: http://www.vim.org/tips/tip.php?tip_id=1314
EDIT: As pointed out by Thomas, vim.org tips moved to: http://vim.wikia.com/
See: http://vim.wikia.com/wiki/Add_open-in-tabs_context_menu_for_Windows |