Skip to content

Instantly share code, notes, and snippets.

View meadsteve's full-sized avatar
🌲
stuff

Steve Brazier meadsteve

🌲
stuff
View GitHub Profile
@meadsteve
meadsteve / example.php
Last active August 26, 2015 08:45
Api !== Http
<?
class Api {
const SUCCESS = 0;
const FAILURE = 13;
public function doThingOne($SomeArgument)
{
// do something
return self::SUCCESS;
}
@meadsteve
meadsteve / eyesbleeding.php
Last active August 29, 2015 13:56
Totally legitimate ordinal number creator
<?php
function intToString($int) {
$first = 'second';
$second = 'third';
$third = 'forth';
$forth = 'fifth';
$dollarer = function ($count) { return ($count > 1) ? str_repeat('$', min($count - 1, 4)) : str_repeat('$', 5); };
@meadsteve
meadsteve / ouch.php
Last active August 29, 2015 13:56
Exception Looper - because it helps me relax
<?php
class ControlFlowception extends \Exception {}
class Breakception extends ControlFlowception {}
class Countception extends ControlFlowception
{
protected $count;
protected $max;
@meadsteve
meadsteve / password_needs_rehash.php
Last active August 29, 2015 13:56
using password_needs_rehash()
<?php
$stevesSecret = "pass123";
$hashOne = password_hash($stevesSecret, PASSWORD_BCRYPT, array("cost" => 4));
$hashTwo = password_hash($stevesSecret, PASSWORD_BCRYPT, array("cost" => 12));
echo $hashOne . PHP_EOL;
echo $hashTwo . PHP_EOL;
assert('$hashOne != $hashTwo', "The two hashes should be different");
@meadsteve
meadsteve / experiment.php
Last active August 29, 2015 13:56
Symfony events without statics
<?php
namespace MeadSteve\Eventing;
require_once "vendor/autoload.php";
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyEventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use \Symfony\Component\EventDispatcher\Event;
@meadsteve
meadsteve / keybase.md
Created January 24, 2015 17:17
keybase.md

Keybase proof

I hereby claim:

  • I am meadsteve on github.
  • I am meadsteve (https://keybase.io/meadsteve) on keybase.
  • I have a public key whose fingerprint is RETU RN T HIS. PGP. GET_ FING ERPR INT( ); }

To claim this, I am signing this object:

@meadsteve
meadsteve / example.js
Last active August 29, 2015 14:17
js-private-type-info
type_with_secrets = (function() {
var secret_type_number = 0;
var exported_type = function(){};
exported_type.prototype.increment_secret = function() { secret_type_number += 1;};
exported_type.prototype.get_secret = function() { return secret_type_number;};
return exported_type;
})();
@meadsteve
meadsteve / oops.js
Last active August 29, 2015 14:25
unicode vs javascipt coder sanity
var a‌a = "first assignment";
aa = "second assignment";
console.log(a‌a == aa);
#!/usr/bin/env elixir
defmodule Committer do
defstruct [:name, :email]
def list(repo) do
repo
|> from_repo
|> Stream.unfold(fn str ->
case String.split(str, "\n", parts: 2, trim: true) do
@meadsteve
meadsteve / clock.ex
Created September 30, 2015 19:31 — forked from CrowdHailer/clock.ex
Creating boundary modules for elixir applications. These have their implementation set during the configuration step. In this example we switch clock between system clock and a dummy clock
# This module represents a behaviour and when used picks from the Application configuration which implementation will be used
defmodule Clock do
@callback now() :: Integer.t
defmacro __using__([]) do
module = Application.get_env(:my_app, :Clock)
quote do
alias unquote(module), as: Clock
end