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
# Prerequisites: | |
# gem install bitcoin-ruby | |
require 'bitcoin' | |
def amino_to_bech32( base64_pubkey_value ) | |
bytes = [ | |
*["1624DE6420"].pack('H*').bytes, | |
*Base64.decode64( base64_pubkey_value ).bytes | |
] |
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 ruby | |
class Integer | |
def to_roman_numerals | |
num = self | |
map = { | |
1 => 'I', | |
5 => 'V', | |
10 => '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
;;; DECK | |
(ns card-game.deck) | |
(defn create [] | |
(shuffle [:h2 :h3 :h4 :h5 :h6 :h7 :h8 :h9 :h0 :hj :hq :hk :ha | |
:d2 :d3 :d4 :d5 :d6 :d7 :d8 :d9 :d0 :dj :dq :dk :da | |
:s2 :s3 :s4 :s5 :s6 :s7 :s8 :s9 :s0 :sj :sq :sk :sa | |
:c2 :c3 :c4 :c5 :c6 :c7 :c8 :c9 :c0 :cj :cq :ck :ca]) | |
) |
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
(ns fizzbuzz.core (:gen-class)) | |
(use '[clojure.string :only [blank? capitalize]]) | |
; a macro which expands (fbfn name M) to a function of one | |
; argument N which outputs "Name" if N % M == 0, otherwise "" | |
(defmacro fbfn [name test] | |
`(fn [arg#] (if (zero? (mod arg# ~test)) | |
~(capitalize (str 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
#!/usr/bin/env ruby | |
# autoshot.rb | |
# | |
# Ryan Funduk (ryanfunduk.com) | |
# Licensed under WTFPL (http://sam.zoy.org/wtfpl) | |
# | |
# Watch a directory and scp new files to a host that | |
# is running a webserver. Only works on OSX, could be | |
# made to work on other platforms with alternatives |
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
The Regex Game | |
Avi Bryant | |
This is a game for two programmers, although it's easy to imagine variations for more. | |
It can be played over email, twitter, or IM, but it's easy to imagine a custom web app for it, and I encourage someone to build one. | |
Each player starts by thinking of a regular expression. The players should decide beforehand on dialect and length restrictions (eg, has to be JavaScript-compatible and under 20 characters). | |
They don't reveal the Regex, but if playing over email etc, should send each other a difficult to brute force hash (eg bcrypt) of the Regex for later verification. | |
They do reveal two strings: one which the Regex will match, and one which it will not. |
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
# SHUT UP with the "GET /assets/whatever..." in the log. Do not want. | |
if Rails.env.development? | |
Rails::Rack::Logger.class_eval do | |
def call_with_quiet_assets(env) | |
previous_level = Rails.logger.level | |
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0 | |
call_without_quiet_assets(env).tap do | |
Rails.logger.level = previous_level | |
end | |
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
rails_env = ENV['RAILS_ENV'] || "development" | |
rails_root = ENV['RAILS_ROOT'] || Dir.pwd | |
num_workers = rails_env == 'production' ? 5 : 1 | |
num_workers.times do |num| | |
God.watch do |w| | |
w.dir = "#{rails_root}" | |
w.name = "resque-#{num}" | |
w.group = 'resque' | |
w.interval = 30.seconds |
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
{ | |
"Version": "2008-10-17", | |
"Statement": [ | |
{ | |
"Sid": "PublicReadForGetBucketObjects", | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "*" | |
}, | |
"Action": "s3:GetObject", |
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 ExampleController < ApplicationController | |
rescue_from Exception, :with => :render_custom | |
def render_custom(exception) | |
if Exceptional::Remote.error(Exceptional::ExceptionData.new(exception, "Test Exception")) | |
Rails.logger.info "Exceptional: #{exception.class} has been reported to Exceptional" | |
else | |
Rails.logger.error "Exceptional: Problem sending exception. Check your API key." | |
end |