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 Enumerable | |
def each_with_emptiness | |
return to_enum(__callee__) unless block_given? | |
if empty? | |
yield nil, true | |
else | |
each do |element| | |
yield element, false | |
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 get_account_balance(fail: false) | |
if fail | |
[:error, "I literally can't even"] | |
else | |
"$1234.56" | |
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
TEXT = <<EOF | |
See, the interesting thing about this text | |
is that while it seems like the first line defines an indent | |
it's actually the last line which has the smallest indent | |
there are also some blank lines | |
both with and without extra spaces in them | |
and it just goes on and on |
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
require 'equalizer' | |
class EqualizableStruct < Struct | |
def initialize *args, &block | |
class << self | |
include Equalizer.new(*members) | |
end | |
super | |
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
# You will need the pygments and xclip packages | |
# This example highlights some Bash source code | |
# '-O noclasses=true' tells pygments to embed colors inline in the source | |
# the '-t text/html' option tells xclip what "target" to specify for the selection | |
pygmentize -l bash -f html -O noclasses=true mysource.sh | xclip -selection clipboard -t text/html |
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
while true; do { echo -e 'HTTP/1.1 200 OK\r\n\r\n'; echo "Hello, world"; } | nc -l 1234; done |
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
c.filter_sensitive_data('<AUTH FILTERED>') {|interaction| | |
Array(interaction.request.headers['Authorization']).first | |
} |
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
;;; rubytapas-theme.el --- rubytapas theme with Emacs theme engine | |
;; Copyright (C) 2013 by Adam Lloyd | |
;; Copyright (C) 2013 by Syohei YOSHIDA | |
;; Copyright (C) 2013 by Avdi Grimm | |
;; Author: Avdi Grimm <[email protected]> | |
;; URL: | |
;; Version: | |
;; X-Original-Version: 0.01 |
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 download_video(Episode[filename: filename] = episode) do | |
Stream.resource(fn -> begin_download(episode) end, | |
&continue_download/1, | |
&finish_download/1) | |
|> File.stream_to!(filename) | |
|> Stream.run | |
end | |
def begin_download(Episode[video_url: video_url, | |
account: Account[login: login, |
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
require "thread" | |
Thread.abort_on_exception = true | |
def none | |
counter = 0 | |
threads = 10.times.map do | |
Thread.new do | |
100.times do |