Skip to content

Instantly share code, notes, and snippets.

View smerrill's full-sized avatar
🤖
Attention is all you need

Steven Merrill smerrill

🤖
Attention is all you need
View GitHub Profile
@smerrill
smerrill / parallelize.sh
Created September 2, 2011 10:05
Run a list of commands (one per line) with a certain concurrency.
cat big_list_of_commands.txt | tr '\n' '\0' | xargs -0 -n1 -P{thread-count} bash -c
# or, per the example given:
(for i in 1 2 3 4 5 6 7 8 9 10; do echo "echo 'Delay $i'; sleep $i ; echo 'Done $i'" ; done) | tr '\n' '\0' | xargs -0 -n1 -P4 bash -c
<useSecurity>true</useSecurity>
<authorizationStrategy class="hudson.security.AuthorizationStrategy$Unsecured"/>
<securityRealm class="hudson.security.SecurityRealm$None"/>
@smerrill
smerrill / fix-profile.sh
Created August 2, 2011 21:59
Fix an XDebug 2.1.1 (or later) callgrind file to be usable with XDebugToolkit
#!/bin/bash
[[ $1 ]] || {
echo "Usage: fix-profile.sh [path to callgrind file]"
exit 1
}
egrep -v '^(cfl|positions|creator)' $1 | sed -e 's/^-//;1s/1/0.9.6/' > $1.fixed
# From http://stackoverflow.com/questions/5952939/htaccess-forward-local-to-remote-on-404
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(sites/default/files/.*)$ http://productionurl.com/$1 [R,L,NC]
@smerrill
smerrill / gist:1085786
Created July 15, 2011 23:41
Convert a Shapefile to list of lat/lon pairs.
ogr2ogr -t_srs WGS84 -f "Mapinfo File" out.mif in.shp
$form['chart_options']['plot']['plot_background_color'] = array(
'#type' => 'textfield',
'#title' => t('Page Title Color'),
'#default_value' => '#FFF',
'#description' => '<div id="plot_background_colorpicker"></div>',
'#size' => 9,
'#maxlength' => 7,
'#attached' => array(
// Add Farbtastic color picker.
'library' => array(
<!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" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en-us" />
<title>/1340$front-end-performance</title>
</head>
<body><br
/><ul><li>Front-end performance</li
><li>How to measure?<ul><li>HAR files<ul><li>HTTP archive</li
autossh
bash-completion
cmake
coreutils
csshx
ctags
curl
discount
dos2unix
drush
@smerrill
smerrill / hg-tagging-yay.sh
Created May 18, 2011 14:30
The best part of waking up?
#!/bin/bash
for i in `hg heads . | grep changeset: | awk '{ print $2; }' | egrep -o '^[0-9]+' | sort -n`; do
hg merge $i;
hg commit -m "Merge of doom.";
done
#!/bin/bash
for i in `hg log | grep -B3 "Added tag" | grep changeset: | egrep -o " [0-9]+"`; do hg up -C $i; cat .hgtags >> /tmp/all-tags.txt; done
hg up -C default
cat /tmp/all-tags.txt | awk '{ print $2" "$1; }' | sort -n | uniq | awk '{ print $2" "$1; }' > .hgtags