This file contains 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
module ActiveRecord | |
Base.singleton_methods.each do |m| | |
Base.class_eval <<-EOS | |
class << self | |
puts "redefining #{m}" | |
define_method "#{m}_with_introspection" do |*args| | |
puts "#{m}" | |
send(:"#{m}_without_introspection", *args) | |
end |
This file contains 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
Model.new.foo |
This file contains 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 ENV_PATH | |
class String | |
# http://www.devarticles.com/c/a/Development-Cycles/Tame-the-Beast-by-Matching-Similar-Strings/3/ | |
module Soundex | |
Codes = { | |
'b' => 1, | |
'f' => 1, | |
'p' => 1, | |
'v' => 1, |
This file contains 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
# #{Rails.root}/lib/tasks/databases.rake | |
=begin | |
Monkey Patch | |
activerecord-3.0.9/lib/active_record/railties/databases.rake | |
clears obstinate stale PG session to get parallel_tests working | |
also, PG user must be superuser to use these low level PG functions | |
=end | |
def drop_database(config) | |
case config['adapter'] | |
when /mysql/ |
This file contains 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
# #{Rails.root}/lib/tasks/databases.rake | |
=begin | |
Monkey Patch | |
activerecord-3.0.9/lib/active_record/railties/databases.rake | |
clears obstinate stale PG session to get parallel_tests working | |
also, PG user must be superuser to use these low level PG functions | |
=end | |
def drop_database(config) | |
case config['adapter'] | |
when /mysql/ |
This file contains 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
/** | |
* Angular needs to send the Rails CSRF token with each post request. | |
* | |
* Here we get the token from the meta tags (make sure <%= csrf_meta_tags %> | |
* is present in your layout.) | |
*/ | |
angular.module('myapp',[]). | |
// configure our http requests to include the Rails CSRF token | |
config(["$httpProvider", function(p) { | |
var m = document.getElementsByTagName('meta'); |
This file contains 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
$ ls | |
other_thing.exs | |
thing.exs | |
$ elixir thing.exs | |
calling other | |
other thing! | |
hooray! |
This file contains 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 IntMath do | |
use Bitwise | |
def pow(_, 0), do: 1 | |
def pow(a, 1), do: a | |
def pow(a, n) when band(n, 1) === 0 do | |
tmp = pow(a, n >>> 1) | |
tmp * tmp | |
end |
This file contains 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 Lab05 do | |
@doc """ | |
My take on [the histogram exercise] | |
(http://computing.southern.edu/halterman/Courses/Fall2013/124/Labs/lab05_F13.html) | |
mentioned in [this newsgroup post] | |
(https://groups.google.com/d/msg/elixir-lang-talk/TTSjV0iy9yA/hpiGDZOk6DkJ) | |
""" | |
def main(), do: parse_pars(System.argv, nil) | |
defp parse_pars([],nil), do: histogram() |
This file contains 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 NumbersInput do | |
def start do | |
IO.stream(:stdio, :line) | |
|> Stream.flat_map(&tokenize/1) | |
|> Stream.take_while(&(&1 > -1)) | |
end | |
defp tokenize(line) do | |
line | |
|> String.split(" ") |
OlderNewer