Skip to content

Instantly share code, notes, and snippets.

Avatar
🌻
Working from home.

Baylee Schmeisser bayleedev

🌻
Working from home.
View GitHub Profile
@bayleedev
bayleedev / parse_transform.rb
Last active Aug 29, 2015
Parses/transforms terminal (specifically git) commands using boolean logic.
View parse_transform.rb
require 'parslet'
require 'pry'
class Command < Struct.new(:cmd, :args)
def initializer(cmd, args = [])
@cmd = cmd
@args = args
end
def execute
p String(cmd)
@bayleedev
bayleedev / short_circuit_iterator.rb
Last active Aug 29, 2015
Give it a tree (array) and it will evaluate them in a short-circuit evaluation fashion.
View short_circuit_iterator.rb
# Helps with executing, and short-circut evaluation.
class ShortCircuitIterator
def initialize(tree)
@tree = tree
end
# Executes all the OR logic breaking on the first `true`-ish value
def each(&block)
@tree.each do |and_operation|
View keybase.md

Keybase proof

I hereby claim:

  • I am blainesch on github.
  • I am blainesch (https://keybase.io/blainesch) on keybase.
  • I have a public key whose fingerprint is 7012 3250 A4B2 D882 ABD3 5806 763C CD80 524B 1779

To claim this, I am signing this object:

View FileLock.php
<?php
/**
* This has the same interface as the previous FileLock but supports multiple locks.
* This allows you to run x processes at the same time.
*/
class FileLock {
public $lockFile = null;
View weird.php
<?php
class Object {
}
class Unit extends Object {
public $me = null;
View LayeredTemplate.php
<?php
class LayeredTemplate {
/**
* The methods defined in this class.
*
* We want to determine if class B (extends A)
* has method C, but not if class A has it.
*
View gist:11181328
<?php
class VariableStream {
private $position;
private $varname;
public function stream_open($path, $mode, $options, &$opened_path) {
$url = parse_url($path);
$this->varname = $url["host"];
$this->position = 0;
return true;
View test_cs.sh
bschmeisser@bschmeisser [11:40:49] [~/sites/devup/apps] [master *]
-> % git clone git://github.com/squizlabs/PHP_CodeSniffer.git && cd PHP_CodeSniffer
Cloning into 'PHP_CodeSniffer'...
remote: Reusing existing pack: 36757, done.
remote: Total 36757 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (36757/36757), 22.82 MiB | 996.00 KiB/s, done.
Resolving deltas: 100% (19370/19370), done.
Checking connectivity... done.
bschmeisser@bschmeisser [11:41:22] [~/sites/devup/apps/PHP_CodeSniffer] [master]
@bayleedev
bayleedev / output
Created May 9, 2014
Hash traverser implemented in ruby
View output
-> % ruby traverser.rb
" - Created configer"
" - Created Document"
1
" - Created Document"
"Blaines Practice"
View find_diff.js
lastWeek = new Date('2014-05-07');
db.git_queue.find({notified_build: {$ne: null}, finished_build: {$ne: null}}).forEach(function(el) {
if (new Date(el.notified_build) > lastWeek) {
total_ms = new Date(el.finished_build) - new Date(el.notified_build);
total_secs = total_ms / 1000;
total_mins = total_secs / 60;
print(total_mins);
}
});