See https://github.com/rbenv/ruby-build/wiki
Assuming rbenv and ruby-build already setup
brew install openssl libyaml libffi readline
# required for building Ruby <= 1.9.3-p0:
brew tap homebrew/dupes && brew install apple-gcc42
def time_to_angle h=0, m=0 | |
puts "hours: #{h*30+m/2}" | |
puts "mins: #{m*6}" | |
end |
module WhiteHat101 | |
module Factorial | |
# returns 1 for input < 1 | |
def fact | |
(1..self).inject 1, :* | |
end | |
alias_method :!, :fact | |
end | |
end |
# some credit: https://gist.github.com/matugm/db363c7131e6af27716c | |
# Print all 26 iterations of Carsar's Chiper for a string | |
def caesar_cipher(string, shift = 1) | |
alphabet = Array('a'..'z') | |
non_caps = Hash[alphabet.zip(alphabet.rotate(-shift))] | |
alphabet = Array('A'..'Z') | |
caps = Hash[alphabet.zip(alphabet.rotate(-shift))] | |
""" | |
Port the to_base/from_base functions from Ruby to Python | |
""" | |
from __future__ import division | |
def __to_base_notation(value, base): | |
result = [] | |
while value > 0 or not len(result): | |
part = value % base | |
value = (value - part) / base |
#!/bin/bash | |
# | |
# WARNING | |
# | |
# This script does not "work". It does correctly upate the preferences (good syntax). | |
# However, those settings are not reloaded until the user logs in again. | |
# They do NOT apply to the current session, and I haven't been able to find anything that | |
# can reload these values, other than AppleScript (with Accessability) simulating user input | |
# to the System Preferences application. | |
# |
# Thanks: https://github.com/dotgee/geoauth/blob/78e859b2d4ca5cd5788aeb3c3a64f2ccc92202dc/config/puma.god | |
ROOT = "/var/www/app/rails/development/geoauth" | |
God.pid_file_directory = "#{ROOT}/tmp/pids" | |
# rails_env = ENV['RAILS_ENV'] || 'production' | |
rails_env = ENV['RAILS_ENV'] || 'development' | |
rails_root = ENV['RAILS_ROOT'] || ROOT |
# mod_rewrite method | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteRule /\.well-known/acme-challenge/(.+) http://example.com/cert-central/$1 [R=301,L] | |
</IfModule> | |
# mod_alias method | |
<IfModule mod_alias.c> | |
Alias "/.well-known/acme-challenge" "/var/acme-challenge" | |
<Directory "/var/acme-challenge"> |
#!/bin/bash | |
# | |
# !!! This function will attempt DOZENS of ssh connections !!! | |
# try not to scare your sysadmins | |
# | |
function collect_host_keys { | |
ukhf=$(mktemp) | |
keys="" |
See https://github.com/rbenv/ruby-build/wiki
Assuming rbenv and ruby-build already setup
brew install openssl libyaml libffi readline
# required for building Ruby <= 1.9.3-p0:
brew tap homebrew/dupes && brew install apple-gcc42
(function(chars, index) { | |
for (chars = index = 0; index < localStorage.length; index++ ) | |
chars += localStorage.getItem(localStorage.key(index)).length | |
return `${(chars/1024/1024).toPrecision(5)} MB ≈${(chars/5/1024/1024*100).toPrecision(3)}%` | |
})() |