Skip to content

Instantly share code, notes, and snippets.

View danielfone's full-sized avatar

Daniel Fone danielfone

View GitHub Profile
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
@danielfone
danielfone / unindent.rb
Last active August 29, 2015 14:06 — forked from avdi/unindent.rb
TEXT = <<EOF
See, the interesting thing about this text
is that while it seems like the first line defines an indent
it's actually the last line which has the smallest indent
there are also some blank lines
both with and without extra spaces in them
and it just goes on and on
# CAVEAT: I have not run this code
require 'rails/generators/erb/scaffold/scaffold_generator'
module Erb
module Generators
class ScaffoldGenerator < Base
protected
@danielfone
danielfone / nested.rb
Last active August 29, 2015 14:02
Iterate over multiple arrays
x_coords = [...]
y_coords = [...]
x_coords.each do |x|
y_coords.each do |y|
do_point x, y
end
end
//
//-- Create a subscriber
//
// POST /api/my-brand/subscribers
{
"subscriber": {
"name": "Test Subscriber",
"email": "test@example.com",
"subscribe": [
'my-list-1',
#!/bin/bash
source .config
# Setup up master repo
# git clone --bare $TMP_REPO $MASTER_REPO
sudo -u git git daemon \
--verbose \
--enable=receive-pack \
@danielfone
danielfone / exist.rb
Created April 1, 2014 07:31
Memoized exist matcher
module RSpec
module Matchers
module BuiltIn
# @api private
# Provides the implementation for `exist`.
# Not intended to be instantiated directly.
class Exist < BaseMatcher
def initialize(*expected)
@expected = expected
end
URL_MATCH = Oniguruma::ORegexp.new %q{(?i)(?<=\s|^)((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))}