Skip to content

Instantly share code, notes, and snippets.

View ybur-yug's full-sized avatar

yburyug ybur-yug

View GitHub Profile
# module = "YourModule"
module = "Enum"
# this call here as to match the module name, hacky
Enum.__info__(:functions)
|> Enum.each(fn({function, arity}) ->
Code.eval_string("require IEx.Helpers; IEx.Helpers.h #{module}.#{function}")
end)
@ybur-yug
ybur-yug / spin.rb
Created June 27, 2016 05:03 — forked from JoshCheek/spin.rb
Spinning words in the console
# https://twitter.com/josh_cheek/status/747207002443546624
require "io/console"
text = ARGV.join(" ").split(/\b/).flat_map.with_index(0) do |word, index|
word.chars.map { |char| "\e[9#{index%7+1}m#{char}" }
end + (" "*10).chars
include Math
print "\e[H\e[2J\e[?25l"
at_exit { print "\e[#{$stdout.winsize[0]-2}H\e[A\e[?25h" }
radius = text.length / 2 / PI
[info] GET /bars
[debug] Processing by UshersOnline.BarController.index/2
Parameters: %{"str" => "lill"}
Pipelines: [:browser]
[debug] SELECT *
FROM bars
WHERE levenshtein(baz, $1) < 6
ORDER BY levenshtein(baz, $1)
LIMIT 20;
["lill"] OK query=109.6ms queue=26.0ms

But with the throttle screwed on, there is only the barest margin, and no room at all for mistakes. It has to be done right... and that's when the strange music starts, when you stretch your luck so far that fear becomes exhilaration and vibrates along your arms. You can barely see at a hundred; the tears blow back so fast that they vaporize before they get to your ears. The only sounds are the wind and a dull roar floating back from the mufflers.

You watch the white line and try to lean with it... howling through a turn to the right, then to the left, and down the long hill to Pacifica... letting off now, watching for cops, but only until the next dark stretch and another few seconds on the edge...

The Edge... There is no honest way to explain it because the only people who really know where it is are the ones who have gone over. The others- the living- are those who pushed their luck as far as they felt they could handle it, and then pulled back, or slowed down, or did whatever they had to when it came ti

module Hamming
def compute_hamming_distance string_1, string_2
raise ArgumentError unless strings_like_length? string_1, string_2
string_1.chars.zip(string_2.chars).count { |x, y| x != y }
end
def strings_like_length? a, b
a.length == b.length
end
end
map <C-g> :!export TEMP1=$(read); export TEMP2=$(read);export TEMP3=$(read); git grep $TEMP1 $(git rev-list —$TEMP3 — $TEMP2/)
map <C-g> :!export TEMP1=$(read); export TEMP2=$(read);export TEMP3=$(read); git grep $TEMP1 $(git rev-list —$TEMP3 — $TEMP2/)
defmodule Etudes.Geom do
@spec area(atom(), number(), number()) :: number()
def area(:rectangle, x, y) when x > 0 and y > 0 do
x * y
end
def area(:triangle, base, height) when base > 0 and height > 0 do
(base * height) / 2.0
end
require 'mechanize'
browser = Mechanize.new
listing_page_url = 'http://www.forsalebyowner.com/search/list/44135/20000:69999-price/proximity,desc-sort'
page = browser.get(listing_page_url)
listings = page.at(".estateSummary")
listings_text = listings.map(&:children).map(&:text)
listings_text.each do |text|
puts text
end
a = 1
10000.times do |t|
b = a * t
puts b.to_s
end