This file contains hidden or 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
| function ab-deploy { | |
| api_key=$AIRBRAKE_API_KEY | |
| env=${1:-development} | |
| sha=$(git rev-parse ${1:-HEAD} 2>/dev/null) | |
| user=$USER | |
| repo=$REPO | |
| body="api_key=$api_key&deploy[rails_env]=$env&deploy[local_username]=$user&deploy[scm_repository]=$repo&deploy[scm_revision]=$sha" | |
| echo -n "curl -d \"$body\" https://api.airbrake.io/deploys.txt" | pbcopy | |
| echo "Copied curl command to clipboard!" | |
| } |
This file contains hidden or 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
| -type folder(T, Acc) :: fun((T, Acc) -> Acc). | |
| -type byte_folder(Acc) :: folder(byte(), Acc). | |
| -spec foldl_bytes(byte_folder(Acc), Acc, io()) -> Acc. | |
| foldl_bytes(Fun, Acc, Binary) when is_binary(Binary) -> | |
| foldl_binary_bytes(Fun, Acc, Binary); | |
| foldl_bytes(Fun, Acc, IoList) when is_list(IoList) -> | |
| foldl_iolist_bytes(Fun, Acc, IoList). | |
| -spec foldl_binary_bytes(byte_folder(Acc), Acc, binary()) -> Acc. |
This file contains hidden or 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
| sign(Req, Auth) -> | |
| Params = Req#req.params, | |
| Method = Req#req.method, | |
| Url = Req#req.url, | |
| {H, P} = oauth_params(Params, Auth), | |
| Sig = signature(Method, Url, P, Auth), | |
| IoList = ["OAuth ", | |
| "oauth_signature", $=, Sig | |
| |H], | |
| Req#req{headers = [{"Authorization", iolist_to_string(IoList)} |
This file contains hidden or 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
| -spec permission_name(binary()) -> atom() | binary(). | |
| permission_name(<<"create_note">>) -> create_note; | |
| permission_name(<<"installed">>) -> installed; | |
| permission_name(<<"manage_pages">>) -> manage_pages; | |
| permission_name(<<"offline_access">>) -> offline_access; | |
| permission_name(<<"photo_upload">>) -> photo_upload; | |
| permission_name(<<"publish_stream">>) -> publish_stream; | |
| permission_name(<<"read_insights">>) -> read_insights; | |
| permission_name(<<"read_stream">>) -> read_stream; | |
| permission_name(<<"share_item">>) -> share_item; |
This file contains hidden or 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
| % Fuck you, erlang! | |
| mem_get(Addr, <<_:Addr/unit:?WORD, Word:1/binary-unit:?WORD, _/binary>>) -> | |
| Word. |
This file contains hidden or 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
| module ::RubyVM::Helpers | |
| class << self | |
| def compile_option name | |
| line = __LINE__ + 2 | |
| code = <<-RUBY | |
| def #{name} | |
| ::RubyVM::InstructionSequence.compile_option[:#{name}] | |
| end | |
| def #{name}= bool |
This file contains hidden or 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 k = nil | |
| if k | |
| a = Rational(4, 8 * k + 1) | |
| b = Rational(2, 8 * k + 4) | |
| c = Rational(1, 8 * k + 5) | |
| d = Rational(1, 8 * k + 6) | |
| return (a - b - c - d) * (16 ** -k) | |
| end |
This file contains hidden or 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
| UnboundMethod.class_exec do | |
| def to_proc | |
| method = self | |
| lambda { |*args, &block| method.bind(self).call(*args, &block) } | |
| end | |
| end |
This file contains hidden or 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 Y f = nil, &b | |
| f ||= b; -> g { g[g] }.call -> g { f[-> *a { g[g][*a] }] } | |
| end | |
| # Hash Autovivification | |
| Y { |d| -> { Hash.new do |h, k| h[k] = d[] end }[] | |
| # Factorial | |
| Y -> fac { -> n { n <= 2 ? n : n * fac[n - 1] } } |
This file contains hidden or 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 FormattedString < String | |
| PATTERN = /:(\w+)/ | |
| DEFER = lambda { |match| match } | |
| def initialize str = '', pattern = nil | |
| super str | |
| pattern ||= PATTERN | |
| @compiler = DEFER |