This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class Module | |
private | |
def delegate(*args) | |
dest, prefix = _extract_valid_delegation_options(args.pop) | |
_define_delegators(caller_locations.first, prefix, dest, args) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dmanderson> Oh Domo :) | |
<dmanderson> Nice templater | |
<Sorella> Oh. | |
<dmanderson> I've been using an underscore to JST compiler as of late, but | |
this looks really nice. | |
<Sorella> I don't quite like Domo, but sure. | |
<Sorella> Oh Lord, don't use Underscore's templating. Like, | |
really. Don't. Just. Don't. | |
<dmanderson> No I'm using JST | |
<dmanderson> writing the templates in underscore |
- Towards a fully-reflective meta-programming language (G. Neverov, P. Roe)
- D-Expressions: Lisp Power, Dylan Style (J. Bachrach, K. Playford)
- The Java Syntactic Extender (J. Bachrach, K. Playford)
- Template Meta-Programming for Haskell (T. Sheard, S.P. Jones)
- First-class macros have types (A. Bawden)
- Macros that work (W. Clinger, J. Rees)
- Macros as multi-stage computations: type-safe, generative, binding macros in MacroML (S.E. Ganz, A. Sabry, W. Taha)
- Hygienic macro expansion (E. Kohlbecker, D. Friedman, M. felleisen, B. Duba)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'addressable/uri' | |
# Source: http://gist.github.com/bf4/5320847 | |
# Accepts options[:message] and options[:allowed_protocols] | |
# spec/validators/uri_validator_spec.rb | |
class UriValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
uri = parse_uri(value) | |
if !uri |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ApplicationRouter do | |
use Dynamo.Router | |
prepare do | |
# Pick which parts of the request you want to fetch | |
# You can comment the line below if you don't need | |
# any of them or move them to a forwarded router | |
conn.fetch([:cookies, :params]) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
gem "parser", "~> 1.4" | |
require "parser" | |
require "parser/ruby19" | |
require "set" | |
class ConstantDeclarationAndUseProcessor < Parser::AST::Processor | |
attr_reader :declared, :used | |
def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE ExistentialQuantification, RankNTypes #-} | |
{-# LANGUAGE InstanceSigs #-} | |
module CoYoneda where | |
import Data.IORef | |
import Data.Set (Set, map) | |
import Control.Monad (liftM) | |
-------------------------------------------------------------------------------- | |
-- Yoneda |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Functorial[F[_], B] { | |
def map[A](m: F[A])(f: A => B): F[B] | |
} | |
trait Monadic[M[_], B] extends Functorial[F, B] { | |
def point(b: B): M[B] | |
def flatMap[A](m: M[A])(f: A => M[B]): M[B] | |
} | |
trait Traversial[F[_], B] { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fiddle' | |
module IAmAHorriblePerson | |
def unset flag | |
value = _wrap self | |
flags = 8.times.map { |i| value[i] }.pack('C8').unpack('Q').first | |
[flags & ~flag].pack('Q').unpack('C8').each_with_index { |n,i|value[i] = n } | |
end | |
def class= k |