Skip to content

Instantly share code, notes, and snippets.

@cmattoon
cmattoon / keybase.md
Created March 7, 2016 14:00
keybase.md

Keybase proof

I hereby claim:

  • I am cmattoon on github.
  • I am cmattoon (https://keybase.io/cmattoon) on keybase.
  • I have a public key whose fingerprint is ED86 EBAE C5E7 6272 F3EB 2897 2645 4202 36A6 F479

To claim this, I am signing this object:

@cmattoon
cmattoon / slidegenerator.php
Last active February 25, 2016 01:48
slides.php
<?php
/**
* Reads a directory and outputs an <img> tag for each *.jpg
* file it finds.
*/
$slides = array_map(function($fname) {
$src = "img/slides/anatomy/" . basename($fname);
return "<img src=\"{$src}\" class=\"slide\">";
}, array_filter(scandir($dir), function($path) {
return (bool)(strpos($path, '.jpg'));
@cmattoon
cmattoon / docker-cleanup.sh
Created February 2, 2016 14:42
Docker Cleanup
#!/bin/bash
docker rm $(docker ps --no-trunc -aq)
docker rmi $(docker images -q --filter "dangling=true")
@cmattoon
cmattoon / example.amd.js
Created January 12, 2016 21:07
Require.js By Example
/**
* Example Asynchronous Module Definition (AMD)
*
*
*/
define(['jquery', 'console'], function($, console) {
"use strict";
var my_private_var = 'This value is private';
function my_private_method() {
@cmattoon
cmattoon / whatever.sh
Created January 12, 2016 01:08
Misc commands
# git rm all those temp files from your new repo
# Did you forget to add a .gitignore?
find . -name '*~' | xargs git rm -f
@cmattoon
cmattoon / .gitconfig
Created November 11, 2015 19:21
git aliases
## Some useful git aliases
## To apply aliases globally (for all repos on your computer), copy into ~/.gitconfig
## To add an alias to one repository only, add it to /path/to/repo/.git/config
##
## ALIASES THAT MENTION BRANCH/ORIGIN NAMES ('master', 'develop', 'origin', 'upstream') should be
## double-checked before adding to anything other than our repos, since these are relative terms.
## If you create a new repo, for example, that doesn't have a 'develop' branch, or 'origin' is not what
## you expect, it can mess things up. Most of them are safe for general use though.
##
@cmattoon
cmattoon / Object.php
Last active November 4, 2015 19:11
PHP Base Object
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
class NotImplementedException extends BadMethodCallException {
public function __construct($message = null, $code = 0, $previous = null) {
parent::__construct($message, $code, $previous);
$this->message = "Method '{$message}' not implemented";
}
@cmattoon
cmattoon / func_overload.py
Created October 18, 2015 15:57
Function Overloading - Alternative
#!/usr/bin/env python
from string import ascii_lowercase
def sum_list(values, ignore_invalid=True):
"""Returns the sum of a list of values.
String representations of integers ('0'-'9') are added at their
integer value, but letters have a value between 1-26.
(a=1, b=2, c=3, ...)
"""
total = 0
@cmattoon
cmattoon / disasm.pl
Created October 8, 2015 18:48
disasm.pl
#!/usr/bin/perl -w
# Found at: http://www.ouah.org/RevEng/code/disasm.pl.txt
# Disasm.pl v0.4
#Assumes that the file we're working with is stripped
#TODO:
# 0. Sort NUMERICALLY on function call names, not lexographically
# 1. Get this to work if symbols are present
# 2. Add options or speed up the finding of unused functions (can we do it
# without an extra pass?)
@cmattoon
cmattoon / 1_phpunit-api.md
Created October 6, 2015 21:08 — forked from loonies/1_phpunit-api.md
PHPUnit Cheat Sheet

PHPUnit API reference

  • version 3.6

TODO

Check those constraints:

$this-&gt;anything()