Skip to content

Instantly share code, notes, and snippets.

View druid628's full-sized avatar

Micah Breedlove druid628

View GitHub Profile
@druid628
druid628 / keybase.md
Created November 20, 2019 19:08
keybase.md

Keybase proof

I hereby claim:

  • I am druid628 on github.
  • I am druid628 (https://keybase.io/druid628) on keybase.
  • I have a public key ASABi_-5oNF0TF1OYmFVUTDcWOswkWL0LouSi-ioepimNAo

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am druid628 on github.
* I am druid628 (https://keybase.io/druid628) on keybase.
* I have a public key whose fingerprint is 607A EDE2 ADB2 6A44 D5DB A384 49E6 36E2 3685 70AF
To claim this, I am signing this object:
<?php
function curry(\Closure $f)
{
$a = [];
$t = 'function($%s) use ($f, $a) { $a[] = $%s; return %s };';
return eval('return '
.array_reduce(
array_reverse((new \ReflectionObject($f))->getMethod('__invoke')->getParameters()),
@druid628
druid628 / AnnotationDI.php
Last active December 16, 2015 16:29
Annotation based Dependency Injection
<?php
// Based on http://www.php.net/manual/en/reflectionclass.newinstancewithoutconstructor.php#108466
//dependency to inject
class dep {}
class a {
/**
* @inject
* @var dep
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@druid628
druid628 / s649.php
Last active December 16, 2015 02:59
who voted what in the senate in S. 649 (Safe Communities, Safe Schools Act of 2013)
<?PHP
$context = stream_context_create(array('http' => array('header' => 'Host: www.govtrack.us')));
$url = 'http://www.govtrack.us/api/v2/vote_voter?vote=113312';
$s649 = json_decode(file_get_contents($url, 0, $context), true);
foreach ($s649['objects'] as $key => $object) {
$name = $object['person']['name'];
$vote = substr($object['option']['value'], 0, 1);
echo "$name -- $vote\n";
}
@druid628
druid628 / MP3Player.php
Created March 8, 2013 20:16
PHP Traits -- After a discussion about traits and using them as a class within the name space I put together this little gist.
<?PHP
# src/druid628/traittesting/MP3Player.php
namespace druid628\traittesting;
use druid628\traittesting\traits as TRAITS;
class MP3Player
{
use TRAITS\Track
{
@druid628
druid628 / Shell_n2k
Created February 18, 2013 20:51
handy shell reminders
# Shell need to knows:
${PWD##*/} # current directory name not path cheaper than basename $PWD
@druid628
druid628 / f_ck_you.sh
Created February 6, 2013 16:40
Easy way to destroy all data within files inside a given directory
#!/bin/bash
# Gotcha!
if [ $# -ne 1 ]; then
echo "No directory using current."
exit 0
fi
if [ ! -d $1 ]; then
echo "That is not a directory dumbass."
@druid628
druid628 / delicious.groovy
Created December 16, 2011 02:54
Delicious RSS to HTML Converter (groovy)
#!/usr/bin/groovy
/**
* Del.icio.us RSS to HTML converter
* command line groovy script execution 1 required argument
* with 1 optional argument
*
*
* syntax:
* groovy delicious http://feeds.delicious.com/v2/rss/<user>?private=<key>\&count=<count> [ /path/to/output/file ]
* groovy delicious http://feeds.delicious.com/v2/rss/<user>?count=<count> [ /path/to/output/file ]