Skip to content

Instantly share code, notes, and snippets.

View colinodell's full-sized avatar

Colin O'Dell colinodell

View GitHub Profile
@colinodell
colinodell / .gitignore
Last active March 13, 2017 07:42
Standard Magento .gitignore
# Don't include any temporary files and other unimportant things
*.log
*.bak
*.bak.*
*.thumbs/
.DS_Store
Thumbs.db
.svn
*.swp
@colinodell
colinodell / checker.php
Created October 24, 2014 23:22
Google Inbox invite checker
<?php
$last = '';
while (true) {
$json = file_get_contents('https://www.reddit.com/r/google/comments/2k0kjr/google_inbox_invite_chain.json?sort=new&foo='.rand(1,500));
$json = json_decode($json, true);
$comment = $json[1]['data']['children'][0];
$msg = $comment['data']['author'] . ' - ' . $comment['data']['body'] . "\n";
if ($msg != $last) {
@colinodell
colinodell / keybase.md
Created January 20, 2015 19:25
keybase.md

Keybase proof

I hereby claim:

  • I am colinodell on github.
  • I am colinodell (https://keybase.io/colinodell) on keybase.
  • I have a public key whose fingerprint is 8FBC 987A 0483 128A C055 E483 60A4 DAD2 72A0 1CB8

To claim this, I am signing this object:

@colinodell
colinodell / console.js
Created April 1, 2015 17:45
/r/thebutton
// Super-simple console script to push the button only when the timer gets low
var h;
var armed = false;
var lowestSoFar = 9999999999;
h = setInterval(function() {
if (r.thebutton._msLeft <= 0) {
console.log('Game over :-/');
clearInterval(h);
return;
@colinodell
colinodell / rateLimit.js
Created July 8, 2015 15:52
JS Rate Limiting
// Returns a function that won't fire more than
// once every `wait` milliseconds.
//
// Example usage:
//
// $('.button').click(rateLimit(function(){
// console.log('clicked!');
// }));
//
function rateLimit(func, wait) {
@colinodell
colinodell / AbstractEnum.php
Created August 18, 2015 15:09
Enum-like class for PHP
<?php
/**
* Base class used to build enums
*/
abstract class AbstractEnum
{
/**
* @var array Options array, suitable for a select box
*/
@colinodell
colinodell / create-multiple.sh
Created August 20, 2015 15:33
Create Drupal upgrade patches
#!/bin/bash
# A sample script for batch-creating multiple patches at once
# Generate 6.x patches
for i in `seq 0 36`
do
./create-patch.sh 6.$i 6.37
done
# Generate 7.x patches
@colinodell
colinodell / services.yml
Created August 20, 2015 22:59
Guzzle with logger
services:
guzzle.client:
class: Guzzle\Http\Client
calls:
- [addSubscriber, ["@guzzle.logger"]]
guzzle.logger:
class: Guzzle\Log\MonologLogAdapter
arguments:
- "@logger"
@colinodell
colinodell / portVarKeywords.php
Last active September 28, 2016 12:24 — forked from nikic/portAlternativeTags.php
Tool for changing "var" keywords to "public" in PHP
<?php
/*
* Note: This script will directly modify the .php files in the given directory.
* It is assumed that the code is under version control, so you can easily review
* the changes using `git diff` or similar.
*/
function usageError() {
die("Usage: php portVarKeywords.php dir/\n");
@colinodell
colinodell / ParagraphDirProcessor.php
Created March 10, 2016 16:29
Adding 'dir' attribute to all paragraphs (UNTESTED)
<?php
// TODO: Set your "namespace" and "use" statements here
// Also see this documentation: http://commonmark.thephpleague.com/customization/abstract-syntax-tree/#document-processor
class ParagraphDirProcessor implements DocumentProcessorInterface
{
public function processDocument(Document $document)
{
$walker = $document->walker();