Skip to content

Instantly share code, notes, and snippets.

<?php
try {
try {
try {
throw new Exception();
} catch (Exception $e) {
echo 'third';
}
} catch (Exception $e) {
return new Frapi_Response(
'code' => 201,
'location' => '/user/1'
);
(function($){
// $ is definitely jQuery now throughout the rest of this function
})(jQuery);
I cannot even imagine why you think *this* syntax is hard to read, write, or remember.
# Markdown has lots of benefits:
* It is concise
* It is very human-readable
* In many cases, it looks like what you want. It is designed to replace characters that you would normally use to emphasize or organize text in plain text.
* Noah doesn't like it, so it is probably good.
Sure, markdown can start to become more [complex](http://daringfireball.net/projects/markdown/syntax), but that is the nature of showing all content in any markup language. You can't "hide" information such as the previous url like you can when the markdown is ultimately parsed. The same goes for any markup out there.
@epixa
epixa / gist:1364511
Created November 14, 2011 17:24
Temporarily build PHP 5.4.0RC1, run tests, and submit back to qa.php.net
mkdir ~/tmp-php-build
cd ~/tmp-php-build
wget http://downloads.php.net/stas/php-5.4.0RC1.tar.gz
tar -xzf php-5.4.0RC1.tar.gz
cd php-5.4.0RC1
./configure --prefix=$HOME/tmp-php-build
make test
Y
<?php
function blah($foo, $bar)
{
echo implode("\n", array_map(function($step) {
extract($step);
return sprintf('%s(%s) called at [%s:%d]', $function, implode(', ', $args), $file, $line);
}, debug_backtrace())) . "\n";
};
@epixa
epixa / gist:9220667
Last active August 29, 2015 13:56
Top 6 UI Fuck-ups of All Time
// space between items indicates difference in level of egregiousness
1. Captcha
2. Icon-only links
<?php
// A traditional route in slim:
$app->get('/foo/:id', someMiddleware, function($id) use ($app) {
$app->response->headers->set('x-custom-header', 'foo');
$app->render('foo.php', ['id' => $id]);
});
// This is a very convenient pattern for small apps that can not only
// declare but also define all routes in a single file, but it has some
class Something {
constructor() => this.calls = 0;
totalCalls() => ++this.calls;
}
let something = new Something();
something.totalCalls(); // 1