This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\newenvironment{someSection}{% | |
% some \newcommands go here | |
\header{Some Section}% | |
\addvspace{\vpad}% | |
\begin{adjustwidth}{\extraMargin}{\extraMargin}% | |
}{% | |
\end{adjustwidth}% | |
\addvspace{\vpad}% | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
root = rev-parse --show-toplevel | |
current-branch = rev-parse --abbrev-ref HEAD | |
ls-untracked = ls-files -o --exclude-standard | |
release = !"$(git root)/.git/local-commands/release.pl" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Dump a variable to error_log instead of the main page | |
* | |
* To do debugging, it's often preferable to stick output into the | |
* error log rather than the main page, in case you might forget to remove | |
* a statement (it does happen) - but you can't do `var_dump()` or | |
* `print_r()` to output, or at least you couldn't before. This will get | |
* the output of those functions and send them to error_log(), reformatted |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RUBY_VER=$(rvm list strings | cut -d\- -f2 | sort -rn | head -n1) echo "ruby-$RUBY_VER-p$((for v in $(rvm list strings | grep "ruby-$RUBY_VER" | cut -d\- -f3); do; echo ${v[2,${#v}]}; done) | sort -rn | head -n1)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp < Sinatra::Base | |
RestfulObjects = [ | |
SampleObject | |
] | |
require 'restful_sinatra.rb' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def m(m) | |
puts m | |
puts " Currently at: #{`ps -o rss= -p #$$`.to_i / 1024} MB" | |
puts " #{GC.stat.inspect}" | |
end | |
m 'Started'; | |
10_000_000.times { Class.new } | |
m 'Made 10,000,000 (unstored) objects' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 | |
Argument "hello" isn't numeric in addition (+) at test.pl line 9. | |
1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set up the database connection. Note that these require either a | |
* connection string be provided by the $PHP_DATABASE_STR env variable, a | |
* filename be provided by the $PHP_CONNECTION_SCRIPT variable, or a | |
* filename matching the parameters demanded by | |
* Migrator::default_connection_script(), the latter two of which must | |
* exist, or the script will fail at this point. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$output = ''; | |
foreach (scandir(session_save_path()) as $x => $dir) { | |
if (!preg_match('/^sess_(.*)/', $dir, $matches)) continue; | |
ob_start(); | |
session_id($matches[1]); | |
session_start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# we assume $dbh gets assigned somewhere else | |
sub do_query { | |
my ($name, $wildcard) = @_; | |
my ($sth) = $dbh->prepare(<<<QUERY); | |
SELECT * | |
FROM some_table | |
WHERE name = ? AND | |
address LIKE CONCAT('%', ?, '%'); | |
QUERY |