As configured in my dotfiles.
start new:
tmux
start new with session name:
-module(bst). | |
-behaviour(gen_server). | |
-export([start_link/0, insert/1, search/1, traverse/1]). | |
-export([init/1, code_change/3, handle_call/3, handle_cast/2, handle_info/2, terminate/2]). | |
-record(bstNode, {key = nil, value=nil, leftNode = nil, rightNode = nil}). | |
-define(Name, bst). | |
init(_Arg) -> {ok,#bstNode{}}. | |
code_change(_, _, _) -> ok. |
require 'nokogiri' | |
require 'open-uri' | |
require 'json' | |
doc = Nokogiri::HTML(open('http://www.fifa.com/worldcup/matches/index.html')) | |
matches = doc.css('.mu').map do |row| | |
match = {} | |
match[:home_team_name] = row.css('.t.home').css('.t-nText').first.content | |
match[:home_team_code] = row.css('.t.home').css('.t-nTri').first.content |
class Proc | |
#This defines a method that can allow the case equality === http://www.ruby-doc.org/core-2.1.1/Proc.html#method-i-3D-3D-3D be called on 2 proc objects | |
def &o | |
->(a) { call(a) && o[a] } | |
end | |
end | |
def multiple_of(x) | |
#A partial function http://en.wikipedia.org/wiki/Partial_function | |
->(a) { a % x == 0 } |
A=Array;d=A.new(9){A.new(9,"_")};loop{a,b,c=gets.split(":").map(&:to_i);next(p"invalid")if(d.map{|x|x[b]}+d[a-a%3,3].flat_map{|x|x[b-b%3,3]}+d[a]).include?c;d[a][b]=c;puts d.map{|x|x.join" "}} |
As configured in my dotfiles.
start new:
tmux
start new with session name:
(defn fact ([n] (fact n 1)) | |
([n mul] (if (< n 1) mul (fact (dec n) (*' n mul))))) |
def valid?(tic) | |
tac = *tic | |
3.times { |i| tac.push((0..2).map { |x| tic[x][i] }) } | |
tac.push((0..2).map { |x| tic[x][x] }).push((0..2).map { |x| tic[tic.size - 1 - x][x] }) | |
(tac.select { |x| x.uniq.size == 1 && x.first != :e }).first | |
end |
(fn [tic_tac] | |
(first (first (filter #(and (apply = %) (not (.contains % :e))) | |
((fn [tic_tac] (conj (apply conj tic_tac | |
((fn [tic_tac] (vec (map (fn[x] (vec (map #((tic_tac %) x) (range 3)))) (range 3)))) tic_tac)) | |
((fn [tic_tac] (vec (map #((tic_tac %) %) (range 3)))) tic_tac) | |
((fn [tic_tac] (vec (map #((tic_tac (- 2 %)) %) (range 3)))) tic_tac))) tic_tac)))) | |
) |
(map #(cond | |
(= 0 (mod % 15)) "FizzBuzz" | |
(= 0 (mod % 5)) "Buzz" | |
(= 0 (mod % 3)) "Fizz" | |
:else %) | |
(range 1 101)) |
require 'spec_helper' | |
describe User do | |
before do | |
@user = User.new(name: "Example User", email: "[email protected]", | |
password: "foobar", password_confirmation: "foobar") | |
end | |
subject { @user } |