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
class User < ActiveRecord::Base | |
validates :bitcoin_address, format: { with: /\A(1|3)[a-zA-Z1-9]{26,33}\z/, | |
message: "invalid bitcoin address" } | |
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
# download this: http://www.ubuntu.com/download/desktop | |
# convert it to an img | |
hdiutil convert -format UDRW -o ~/Downloads/ubuntu.img ~/Downloads/ubuntu-12.04.3-desktop-amd64.iso | |
# remove .dmg extension | |
mv ~/Downloads/ubuntu.img.dmg ~/Downloads/ubuntu.img | |
# figure out which drive your usb stick is | |
diskutil list |
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
alias vime="vim -u ~/.encrypted_vimrc -x" |
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
mplayer -vo null -vc dummy -af resample=44100 -ao pcm -ao pcm:waveheader file.wma && lame -m s audiodump.wav -o file.mp3 && rm audiodump.wav |
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 'time' | |
class Float | |
def round_to(x) | |
(self * 10**x).round.to_f / 10**x | |
end | |
def ceil_to(x) | |
(self * 10**x).ceil.to_f / 10**x | |
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
def pi_monte(n=100_000) | |
inside = total = 0 | |
n.times{ | |
x, y = rand*2-1, rand*2-1 | |
d = Math.sqrt(x**2+y**2) | |
if d < 1 | |
inside += 1 | |
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
# runs in about 10s on my 1.1GHz MacBook. | |
equation = "x+13*x/x+x+12*x-x-11+x*x/x-10==66".gsub("x", "%.1f") | |
puts (1..9).to_a.permutation.map{|nums|equation%nums}.select{|eq| eval(eq)} |
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 'json' | |
require 'time' | |
recordings = JSON.parse(ARGF.read) | |
recordings.each{|recording| | |
timestamp = Time.at(recording["created"].to_i).strftime("%Y-%m-%d %H.%M.%S") | |
destination = File.expand_path("#{timestamp}.mp3") | |
cmd = "curl \"#{recording["url"]}\" > \"#{destination}\"" | |
puts cmd |
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
#!/usr/bin/env osascript | |
-- usage: | |
-- add_to_reading_list "http://google.com" "http://yahoo.com" | |
on run argv | |
repeat with arg in argv | |
tell app "Safari" to add reading list item (arg as text) | |
end repeat | |
end run |
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
import React, { Component } from "react"; | |
import "./App.css"; | |
import { db } from "./firebase"; | |
window.db = db; | |
class App extends Component { | |
state = { | |
title: "Loading...", |