Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am pheuter on github.
  • I am markfayngersh (https://keybase.io/markfayngersh) on keybase.
  • I have a public key whose fingerprint is 57E0 005D 96B5 5B63 C102 899A 6F7F 5E37 2A2F ED01

To claim this, I am signing this object:

@pheuter
pheuter / gist:9b108bd425cd9d405308
Created August 13, 2014 18:52
Rick Ross image scraper using Nokogiri (鋸)
require 'open-uri'
require 'nokogiri'
i = 0
file = File.new "ross_image_urls.txt", "w"
50.times do
imageUrls = Nokogiri::HTML(open(URI.escape("https://www.google.com/search?q=rick+ross&biw=1301&bih=442&sei=WKvrU9nIJ43gsASAxYHQDQ&tbm=isch&ijn=2&ei=WKvrU9nIJ43gsASAxYHQDQ&start=#{i}"))).css('img').each do |image|
file.puts image['data-src']
end
server = ServerSocket new() : ServerSocket
---------------------------------------------------------------
ERROR No such function accept(Int, SockAddr*, UInt*)
conn := accept(descriptor, addr&, addrSize&)
^^^^^^
Nearest match is:
accept: func (s : Int, addr : SockAddr*, addrlen : UInt) -> Int
..but the type of this arg should be UInt (lang/types [23951, 23955]), not UInt* (lang/types [23951, 23955])
5 4 1 + = [ "5 = 5, YAY!" ] [ ":(" ] if
import Data.List
main = print $ length . filter (\x -> sum x `elem` a) . filter (\x -> length x > 1) $ subsequences a
where a = [3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99]
require "prime"
fib = Fiber.new do
x, y = 0, 1
loop do
Fiber.yield y
x,y = y, x+y
end
end
str = "FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesed
def uncipher(str)
1.upto(26) do |shift|
key = Hash[('a'..'z').zip((97..122).collect{ |i| if (i+shift > 122) then ((i + shift) % 122) + 96 else i+shift end })].merge({' '=>' '.ord,','=>','.ord,'.'=>'.'.ord,'?'=>'?'.ord,'!'=>'!'.ord})
freqs = Hash.new(0)
tmp = str.split('').collect { |letter| switched = (key[letter]).chr; freqs[switched] += 1; switched }
total = 0
freqs.each { |e| total += e[1] }
puts tmp.join if freqs['e']/total.to_f * 100 > 7 and freqs['t']/total.to_f * 100 > 5 # Might want to eventually make more accomodating
end
end
@pheuter
pheuter / remove_all_gems.sh
Created November 12, 2010 00:13
Concurrently uninstalls all ruby gems
gem list | ruby -e "while line = STDIN.gets do puts line[/([\w_-]+)/,1] end" | parallel gem uninstall
@pheuter
pheuter / peculiar.rb
Created November 29, 2010 20:56
Guess what happens...
def f(*x) {:f=>->(o){p o}}[:f][x*", "] end
f 'Hello', gets