Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
@jeremyworboys
jeremyworboys / Vagrantfile
Created October 29, 2014 08:15
Provision V8Js
$provision_v8js = <<SCRIPT
apt-get install -y libv8-dev
yes | pecl install v8js-0.1.3
echo "extension=v8js.so" > /etc/php5/mods-available/v8js.ini
php5enmod v8js
SCRIPT
config.vm.provision "shell", inline: $provision_v8js

Keybase proof

I hereby claim:

  • I am jeremyworboys on github.
  • I am jeremyworboys (https://keybase.io/jeremyworboys) on keybase.
  • I have a public key whose fingerprint is 0736 97FD 69CB 1DE3 53FE F640 3EE1 8861 E834 E7AE

To claim this, I am signing this object:

@jeremyworboys
jeremyworboys / AnnotatedEntityTrait.php
Created March 22, 2014 06:24
Annotated Entity Trait
<?php
namespace Domain\Entities\Traits;
/**
* Annotated entity trait
*/
trait AnnotatedEntityTrait
{
/** @var array */
@jeremyworboys
jeremyworboys / .zshrc
Last active August 29, 2015 13:57
Personal Vagrant Provisions
export ZSH=$HOME/.oh-my-zsh
ZSH_THEME="pure"
DISABLE_AUTO_TITLE="true"
ENABLE_CORRECTION="true"
COMPLETION_WAITING_DOTS="true"
plugins=(bower composer cp git laravel4 npm common-aliases pip python virtualenv)
source $ZSH/oh-my-zsh.sh
@jeremyworboys
jeremyworboys / .zalias
Last active August 29, 2015 13:56
ZSH Aliases
alias c='clear'
alias l="ls -FlAGh"
alias lo="ls -FlAGh | awk '{k=0;for(i=0;i<=8;i++)k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(\"%0o \",k);print}'"
alias server="php -S 0.0.0.0:8080"
alias clearcache="sudo killall -HUP mDNSResponder"
alias pubkey="/bin/cat ~/.ssh/id_rsa.pub | pbcopy"
alias name="uname -n | tee /dev/ttys001 | pbcopy"
alias art="php artisan"
alias test="clear && phpunit"
@jeremyworboys
jeremyworboys / laravel
Last active August 29, 2015 13:56
Personal Laravel project bootstrapper
#!/bin/bash
# Get project name
if [[ $1 == "" ]]
then
echo -n "Enter project name (or domain): "
read -e PROJECT_NAME
if [[ $PROJECT_NAME == "" ]]
then
@jeremyworboys
jeremyworboys / README.md
Created January 28, 2014 03:34
Domain Independent wp-config.php

Dynamic Wordpress Config

This makes Wordpress play super friendly with Git :)

Usage

  1. Copy and paste this snippet in wp-config.php
  2. Enter the hostname of your production server on line 24
  3. Setup your database credentials for production and development (you can add more environments by adding a new case using that server's hostname)
  4. Replace the keys and salts block with the contents of https://api.wordpress.org/secret-key/1.1/salt/
@jeremyworboys
jeremyworboys / Data only.html
Created October 27, 2013 21:55
Separation of concerns with MVVM EE Stash
{!-- model.html --}
{exp:channel:entries
channel="work"
url_title="{stash:url_title}"
require_entry="yes"
{global:disable}
}
{exp:stash:set_list name="images"}
{post_carousel_images}
<?php
trait DefaultsModel {
/**
* Default values to seed the model with
* @var Array
*/
protected $defaults = array();