Skip to content

Instantly share code, notes, and snippets.

@reprah
reprah / SHA1.rb
Last active January 16, 2022 06:10 — forked from tstevens/SHA1.rb
#!/usr/bin/ruby
require 'rubygems'
require 'active_support/all'
require 'digest/sha1'
def leftrotate(value, shift)
return ( ((value << shift) | (value >> (32 - shift))) & 0xffffffff)
end
# FIPS 180-2 -- relevant section #'s below
@reprah
reprah / io_nonblock_demo.rb
Created October 5, 2013 17:36
Ruby methods in io/nonblock
#
# Documenting io/nonblock and how the methods (nonblock?, nonblock=, nonblock{}) there behave
#
# server.rb
require 'socket'
TCPServer.open('localhost', 3030) do |server|
while client = server.accept