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
sudo foreman export --app foo --user bar upstart /etc/init |
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
Less is better you know (: | |
Ruby 2.1: | |
- with out VM tweak: 1 min 57.06 sec | |
- with VM tweak: 2 min 3.6 sec | |
Ruby 2.0 | |
- with out VM tweak: 2 min 28.9 sec | |
- with VM tweak: 2 min 1.7 sec |
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(" ") |
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
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version | |
# see https://github.com/defunkt/resque/issues/49 | |
# see http://redis.io/commands - new commands | |
namespace :resque do | |
desc "Clear pending tasks" | |
task :clear => :environment do | |
queues = Resque.queues | |
queues.each do |queue_name| | |
puts "Clearing #{queue_name}..." |
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 Life do | |
def run(board) when is_binary(board) do | |
board |> parse_board |> run | |
end | |
def run(board) do | |
IO.write("\e[H\e[2J") | |
Life.print_board board | |
:timer.sleep 1000 | |
board = next_board(board) |
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 'spec/support/grep_matcher' | |
describe do | |
disallow_presence_of pattern: "send(.*#", | |
location: "app/", | |
description: "Do not use dynamic method invocations", | |
failure: "Please change dynamic method call to something more sane." | |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |