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:1063274
Created July 4, 2011 12:13
Recursively remove Mac OS X tar "dot underscore" files
find . -name '._*' -exec rm -f {} \;
@betawax
betawax / gist:1063282
Created July 4, 2011 12:29
Search & Replace
UPDATE table SET field = REPLACE(field, 'foo', 'bar');
@betawax
betawax / gist:1063285
Created July 4, 2011 12:31
Find duplicate records
SELECT field, COUNT(field) AS count FROM table GROUP BY field HAVING (count>1);
@betawax
betawax / gist:1063288
Created July 4, 2011 12:34
Filter duplicate IDs
SELECT id, MAX(count) AS count FROM table GROUP BY id ORDER BY count;
@betawax
betawax / gist:1063292
Created July 4, 2011 12:38
Combine the result from multiple SELECT statements into a single result set
(SELECT foo FROM table) UNION (SELECT bar FROM table) ORDER BY foobar;
@betawax
betawax / gist:1136849
Created August 10, 2011 13:55
Get the most used domains of email addresses
SELECT SUBSTRING_INDEX(email, '@', -1) AS domain, COUNT(SUBSTRING_INDEX(email, '@', -1)) AS count FROM table GROUP BY domain ORDER BY count DESC;
@betawax
betawax / t3dump.sh
Created October 21, 2011 09:01
Make a dump of a TYPO3 installation
#!/bin/sh
# Project infos
PROJECT_NAME=foobar
DOCUMENT_ROOT=htdocs
# Database access
DB_USERNAME=foo
DB_PASSWORD=bar
DB_DATABASE=foobar
@betawax
betawax / gist:1760260
Created February 7, 2012 15:37
Use the row number in a SELECT statement
SELECT @rownum := @rownum + 1 AS row FROM foobar fb, (SELECT @rownum := 0) rn ORDER BY foobar;
@betawax
betawax / gist:1783404
Created February 9, 2012 21:28
Standalone XML
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
@betawax
betawax / html4.html
Created February 13, 2012 14:52
HTML4
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="" />
</head>