Skip to content

Instantly share code, notes, and snippets.

View betawax's full-sized avatar

Holger Weis betawax

  • Germany
View GitHub Profile
@betawax
betawax / gist:794687
Last active November 21, 2018 06:45
jQuery document ready shortcut
$(function() {})
@betawax
betawax / gist:794736
Created January 25, 2011 10:01
Recursively remove Mac OS X .DS_Store files
find . -name '.DS_Store' -exec rm -f {} \;
@betawax
betawax / gist:794975
Last active September 24, 2015 19:07
Recursively adjust permissions for files and directories
find * -type f -exec chmod 644 {} \;
find * -type d -exec chmod 755 {} \;
@betawax
betawax / gist:804020
Created January 31, 2011 13:25
Generate a random key
sha1(microtime(TRUE).mt_rand(10000, 90000));
@betawax
betawax / gist:805859
Created February 1, 2011 13:37
Perform a SELECT statement with a case sensitive WHERE clause
SELECT foo, bar FROM foobar WHERE BINARY foo = bar;
@betawax
betawax / gist:822138
Created February 11, 2011 09:42
Encode a ISO-8859-1 string to UTF-8 if necessary
$foobar = (mb_detect_encoding($foobar, 'UTF-8, ISO-8859-1') != 'UTF-8' ? utf8_encode($foobar) : $foobar);
@betawax
betawax / gist:860120
Created March 8, 2011 10:19
Convert a ISO-8859-1 file to UTF-8
iconv -f iso-8859-1 -t utf-8 file_iso.txt > file_utf8.txt
@betawax
betawax / gist:919102
Created April 14, 2011 08:06
Format a NSDate according to the current locale
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *localizedDateFormat = [NSDateFormatter dateFormatFromTemplate:@"MMMM d, y" options:0 locale:[NSLocale currentLocale]];
[dateFormatter setDateFormat:localizedDateFormat];
NSString *dateString = [dateFormatter stringFromDate:date];
[dateFormatter release];
// dateString will be "April 19, 2010" for US and "19. April 2010" for DE locale
@betawax
betawax / gist:1053967
Last active January 16, 2024 07:06
Git cheat sheet

Git cheat sheet

Common commands

General

Create repository:

git init
@betawax
betawax / gist:1055927
Created June 30, 2011 09:38
Output the last built query in a TYPO3 Extension
$GLOBALS["TYPO3_DB"]->store_lastBuiltQuery = TRUE;
echo $GLOBALS["TYPO3_DB"]->debug_lastBuiltQuery;