Skip to content

Instantly share code, notes, and snippets.

@jimrubenstein
jimrubenstein / gist:e68e4011ebd4f4850762
Last active August 29, 2015 14:16
make a closure out of a callable
function closureify(callable $fn)
{
return function() use ($fn) {
return call_user_func_array($fn, func_get_args());
};
}
$ php callable_test.php
bool(false)
bool(true)
<?php
class Test {
public function __invoke() {}
}
var_dump(is_callable('Test'));
<?php namespace App\Http\Middleware;
use Closure;
class NoCache {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
<div class="campaign-property-container">
<div class="campaign-property-value">
<? if ($Campaign->started()): ?>
<? if ($Campaign->running()): ?>
<span class="campaign-status mod-running">Running</span>
<? elseif ($Campaign->ended()): ?>
<span class="campaign-status mod-ended">Ended</span>
<? elseif ($Campaign->pending()): ?>
<span class="campaign-status mod-scheduled">Scheduled</span>
<? endif; ?>
function getPageHistory() {
var hist = $.cookie('history');
try {
hist = JSON.parse(hist);
if (false == $.isArray(hist)) hist = [];
}
catch (e)
{
#!/usr/bin/python
import os
import random
import time
os.system("osascript -e 'set volume 1' 2>/dev/null");
phrases = ("Help me, I'm stuck in here!", "Is anyone out there?", "Can anybody hear me?", "S O S", "It's dark in here..", "I'm watching you", "Please don't look at me like that", "Don't touch me there!", "What are you doing?", "Who are you?", "I know what you're typing...", "I wouldn't say that if I were you..")
voices = ("Zarvox", "Fred", "Ralph", "Victoria", "Princess", "Alex")
@jimrubenstein
jimrubenstein / ami-to-ebs.sh
Created December 16, 2011 19:56 — forked from hubgit/ami-to-ebs.sh
creating an EBS AMI from a running Instance
# in web browser
# http://uec-images.ubuntu.com/releases/karmic/release/
# canonical karmic 64-bit AMI:
# ami-55739e3c
# canonical karmic 32-bit AMI:
# ami-bb709dd2
# https://console.aws.amazon.com/ec2/home#c=EC2&s=Instances
# Launch Instance > Community AMIs
<?
class MyException extends Exception
{
public function getType() { return 'NotException'; }
}
function doTest()
{
$e = new MyException('stupid php', 1);
@jimrubenstein
jimrubenstein / gist:3152882
Created July 20, 2012 20:00
mandrill library
var request = require('request'),
_ = require('underscore');
var MANDRILL_API_ROOT = 'https://mandrillapp.com/api/1.0/';
function makeMandrill(key)
{
function mandrill(path, opts, callback)
{
console.log(this.key, 'key');
The Trustees of Reservations: Berkshires
"e" inc.
11:11 Theatre Company
17 Cox
185 Photos
33 Restaurant &amp; Lounge
3rd Wheel Comedy
3Scoops Cafe and Gallery
4th Floor Artists
54th Mass Volunteer Infantry, Company 'A'