Skip to content

Instantly share code, notes, and snippets.

View glennpratt's full-sized avatar

Glenn Pratt glennpratt

View GitHub Profile
[1] boris> $things = ['foo' => 'bar', 'baz' => 'qux'];
→ array(
'foo' => 'bar',
'baz' => 'qux'
)
[2] boris> array_map(function($thing) { return "{$thing}s";}, $things);
→ array(
'foo' => 'bars',
'baz' => 'quxs'
)
Thread::spawn(move|| {
let mut eviction_lifo: Vec<(Vec<u8>, Timespec)> = vec![];
let mut timer = Timer::new().unwrap();
let validity = Duration::seconds(5);
loop {
let timeout = if eviction_lifo.len() > 1 {
let (_, arrival) = eviction_lifo[0];
let eviction_time = arrival + validity;
timer.oneshot(eviction_time - get_time())
<?php
function testThrows() {
$this->assertThrows(function() {
// throw new \Exception('BAH!');
}, 'Exception', "/BAH/");
}
function testThrowsA() {
$this->assertThrows(function() {
throw new \RuntimeException('BAH!');
}, 'InvalidArgumentException');
@glennpratt
glennpratt / composer_error
Created May 22, 2014 15:23
composer issue
vagrant@vagrant-ubuntu-precise-64:/vagrant/composer$ php composer.phar install -vvv
Reading ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Reading ./composer.lock
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Reading ./composer.lock
- Installing justinrainbow/json-schema (1.3.5)
Reading /home/vagrant/.composer/cache/files/justinrainbow/json-schema/01949f6d2130e9737ffae5d3952909a8de70d114.zip from cache
module A
THING = 1
module B
def self.thing
puts THING
end
end
end
module X
require 'syslog'
module Aq
# Clone the ::Syslog module so we can extend it.
Syslog = ::Syslog.dup
# Syslog for fields. No need to {::Syslog#open} it, we already did.
module Syslog
DEFAULT_OPTIONS = LOG_PID | ($stderr.isatty ? LOG_PERROR : 0)
DEFAULT_FACILITY = LOG_DAEMON
2.0.0p353 :015 > foo.nil?
NameError: undefined local variable or method `foo' for main:Object
from (irb):15
from /usr/local/.rvm/rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'
2.0.0p353 :016 > @foo.nil?
=> true
2.0.0p353 :017 > @@foo.nil?
(irb):17: warning: class variable access from toplevel
NameError: uninitialized class variable @@foo in Object
from (irb):17
require 'benchmark'
require 'pp'
class App
def initialize
$realm_match = Regexp.new(ENV['CLOUDAPI_DISABLE_REALM_MATCH']) rescue false
@@realm_match = Regexp.new(ENV['CLOUDAPI_DISABLE_REALM_MATCH']) rescue false
@realm_match = Regexp.new(ENV['CLOUDAPI_DISABLE_REALM_MATCH']) rescue false
$_match = nil
@@_match = nil
@glennpratt
glennpratt / d8-ExceptionController-error.log
Created May 28, 2013 21:06
Error in Exception handler
[Tue May 28 16:04:26 2013] [warn] [client 127.0.0.1] mod_fcgid: stderr: Uncaught PHP Exception Drupal\\Core\\Database\\DatabaseExceptionWrapper: "Exception in Frontpage[frontpage]: SQLSTATE[42S02]: Base table or view not found: 1146 Table &#039;portlandsprint.node_field_revision&#039; doesn&#039;t exist: SELECT data.*
[Tue May 28 16:04:26 2013] [warn] [client 127.0.0.1] mod_fcgid: stderr: FROM
[Tue May 28 16:04:26 2013] [warn] [client 127.0.0.1] mod_fcgid: stderr: {node_field_revision} data
[Tue May 28 16:04:26 2013] [warn] [client 127.0.0.1] mod_fcgid: stderr: WHERE (nid IN (:db_condition_placeholder_0)) AND (vid IN (:db_condition_placeholder_1_und))
[Tue May 28 16:04:26 2013] [warn] [client 127.0.0.1] mod_fcgid: stderr: ORDER BY data.nid ASC; Array
[Tue May 28 16:04:26 2013] [warn] [client 127.0.0.1] mod_fcgid: stderr: (
[Tue May 28 16:04:26 2013] [warn] [client 127.0.0.1] mod_fcgid: stderr: [:db_condition_placeholder_0] =&gt; 1
[Tue May 28 16:04:26 2013] [warn] [client 127.0.0.1] mod_fcgid: stderr

reStructuredText for tables?

Instead of Markdown

Grid table: