User : jarnaldich

Title User Language Tags Description Date
Measuring a command with console output in PowerShell jarnaldich Windows PowerShell

This times the execution of a Command. The Out-Default part is just to print the command output to console.

June 12, 2012
Python Time Bomb jarnaldich Python

Making a python process exit with error code 1 after 30 seconds. Exit is unclean (no garbage is collected, no flushed buffers, etc...).

June 1, 2012
Delete files in a directory tree matching a regex jarnaldich Windows PowerShell July 5, 2011
Get an absolute from a path relative to the current file jarnaldich Python

Sometimes (ex. django templates section at setting.py), a function expects an absolute path, but it's more practical when developing to refer it to the current file position in our code base. The rel function does exactly that.

June 22, 2011
CamlCase conversion jarnaldich Python

Turn a string LikeThis into like_this

January 19, 2011
Search and Replace regexp in subdirectories jarnaldich Windows PowerShell

replace foo -> bar in all .txt files down the tree

Dunno why, the syntax highlighter adds \3's to the code. Try plain text.

November 18, 2010
UNIX regexp search down a directory tree jarnaldich Bash

Searches down the current directory every file whose name matches (case insensitively) {{file_pattern}} for the regexp {{text}}.

November 16, 2010
Batch rename with wildcard support in Unix jarnaldich Bash

To rename a bunch of files from ".foo" to ".bar" (like windows' REN *.foo *.bar) in unix.

Looking at the solution, it is easy to adapt it to more powerful character substitutions on a 1 to 1 basis.

If you want to test what will be executed before doing so, just drop the last pipe.

September 1, 2010
Horizontally Centering a div with CSS jarnaldich CSS

Centering a div with css is easy, but there are some compatibility quirks...

January 10, 2009
Macro to ease auto_ptr usage jarnaldich C++

Use this macro to help declaring auto-release pointers in C++. See usage in the source. Remember that std::auto_ptr is a standard template class that helps releasing memory, since the pointer you provide in the constructor will be released in the destructor of the class. This means that memory is released "automagically" when the variable goes out of scope. Use of this class is specially advisable in a method with serveral returns or capable of throwing an exception.

December 12, 2008
Importing data from (Excel) CSV into MySQL jarnaldich SQL

Imports data from CSV (excel-compatible format) into MySQL. Also check the mysqlimport utility and the complementary SELECT ... INTO OUTFILE.

June 26, 2008
Grouping keys of an associative list jarnaldich Scheme

Given an an associative list ((k1 . v1) (k2 . v2) ... (kn . vn)), with possibly equal values for ki, it returns another alist where all cells have distinct keys and where values originally associated to the same key have been grouped as a list in the new cons cell. Ouch! This is much harder to explain than to code. Just check the commented example in the code.

April 30, 2008
File slurping in SmallTalk jarnaldich SmallTalk

Reading the contents of a whole file as a string.

April 16, 2008
Turning array values into hash keys jarnaldich Ruby

Useful for speeding up searches.

April 5, 2008
backup mysql databases jarnaldich Other

MySQL backup and restore example through mysqldump / mysql command line utilities.

February 24, 2008