Skip to content

Instantly share code, notes, and snippets.

View aaronpk's full-sized avatar

Aaron Parecki aaronpk

View GitHub Profile
@aaronpk
aaronpk / public-for-phpunit.php
Last active December 6, 2015 18:58
Make all protected methods public for PHPUnit
<?php
/*
* Make all protected methods public for PHPUnit
*/
class ExampleClassTest extends ExampleClassTest {
public function __call($method, $args) {
$method = new \ReflectionMethod('ExampleClass', $method);
$method->setAccessible(true);
require 'bundler'
Bundler.require :default
logger = Logger.new(STDOUT)
# comma-separated list of user IDs to follow
user_ids = '1000,2000,3000'
search = {
:consumer_key => '',
/*
Array.findRanges
Turns this:
["a","a","a","b","b","c","c","c","c","c","a","a","c"]
into this:
{
var request = require('request');
var crypto = require('crypto');
var hash = crypto.createHash('sha256');
hash.setEncoding('hex');
var fp = request.get('http://www.google.com/favicon.ico').on('end', function(){
hash.end();
console.log("Request finished. Hash: " + hash.read());
}).pipe(hash);
<?php
// When I try to sign in, I get TokenMismatchException
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
links = [
{:a => :z},
{:b => :z},
{:c => :z},
{:d => :y},
{:e => :x},
{:e => :w},
{:e => :v},
{:f => :u},
{:f => :t},
@aaronpk
aaronpk / ruby-setup.txt
Last active August 29, 2015 14:25
setting up Ruby on a new OSX computer
brew install ruby-install
ruby-install ruby 2.1.6
gem install bundler
brew install libxml2 libxslt # usually required for some ruby libraries
brew install chruby
# this sets the paths for ruby and bundle to the newly installed ruby
chruby 2.1.6
# now you can install other rubies:
ruby-install ruby 2.2.2
<?php
/**
* Converts base 10 to base 60.
* http://tantek.pbworks.com/NewBase60
* @param int $n
* @return string
*/
function b10to60($n)
{
$s = "";
GET http://atlas.dev/api/context?latitude=45.5118&longitude=-122.6433
{
"latitude":45.5118,
"longitude":-122.6433,
"locality":"Portland",
"region":"Oregon",
"country":"USA",
"best_name":"Portland",
"full_name":"Portland, Oregon, USA",
<?php
trait Hello {
public function sayHello() {
echo 'Hello ';
}
}
trait World {
public function sayWorld() {
echo 'World';