brew update
brew install libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz tar xvfz libiconv-1.13.1.tar.gz cd libiconv-1.13.1 ./configure --prefix=/usr/local/Cellar/libiconv/1.13.1 make sudo make install
#!/usr/bin/env ruby | |
# A quick and dirty implementation of an HTTP proxy server in Ruby | |
# because I did not want to install anything. | |
# | |
# Copyright (C) 2009-2014 Torsten Becker <[email protected]> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining | |
# a copy of this software and associated documentation files (the | |
# "Software"), to deal in the Software without restriction, including | |
# without limitation the rights to use, copy, modify, merge, publish, |
brew update
brew install libxml2 libxslt
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz tar xvfz libiconv-1.13.1.tar.gz cd libiconv-1.13.1 ./configure --prefix=/usr/local/Cellar/libiconv/1.13.1 make sudo make install
#!/usr/bin/env ruby | |
cmd = %q[echo '3...'; sleep 1; | |
echo '2...'; sleep 1; | |
echo '1...'; sleep 1; | |
echo 'Liftoff!'] | |
puts '------ beginning command ------' | |
output_log = [] | |
IO.popen(cmd).each do |line| |
# blog post: http://blog.slashpoundbang.com/post/1455548868/memcachemodel-make-any-ruby-object-that-persists-in | |
# No transactions or exceptions (yet). | |
module MemcacheModel | |
def self.included(base) | |
base.class_eval do | |
extend ActiveModel::Naming | |
extend ActiveModel::Translation | |
extend ActiveModel::Callbacks | |
extend MemcacheModel::ClassMethods |
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', path: '~/code/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'rack', github: 'rack/rack' | |
gem 'i18n', github: 'svenfuchs/i18n' | |
GEMFILE | |
system 'bundle' |
#!/bin/sh | |
usage () | |
{ | |
cat <<EOF | |
docker-enter -- Enter a running container via boot2docker and nsenter | |
Usage: docker-enter <container_name_or_ID> [command] | |
See https://github.com/jpetazzo/nsenter for details. |
class User | |
def similarity_with(user) | |
# Array#& is the set intersection operator. | |
agreements = (self.likes & user.likes).size | |
agreements += (self.dislikes & user.dislikes).size | |
disagreements = (self.likes & user.dislikes).size | |
disagreements += (self.dislikes & user.likes).size | |
# Array#| is the set union operator |
require 'rubygems' | |
require 'gsl' | |
users = { 1 => "Ben", 2 => "Tom", 3 => "John", 4 => "Fred" } | |
m = GSL::Matrix[ | |
#Ben, Tom, John, Fred | |
[5,5,0,5], # season 1 | |
[5,0,3,4], # season 2 | |
[3,4,0,3], # season 3 | |
[0,0,5,3], # season 4 |
z = fn | |
f -> fn | |
x -> f.(fn y -> x.(x).(y) end) | |
end.(fn | |
x -> f.(fn y -> x.(x).(y) end) | |
end) | |
end | |
add_squares = z.(fn | |
f -> fn |
LDFLAGS: -L/usr/local/opt/freetype/lib CPPFLAGS: -I/usr/local/opt/freetype/include
LDFLAGS="-L/usr/local/opt/freetype/lib -L/usr/local/opt/libpng/lib" CPPFLAGS="-I/usr/local/opt/freetype/include -I/usr/local/opt/libpng/include -I/usr/local/opt/freetype/include/freetype2" sudo pip install matplotlib