Skip to content

Instantly share code, notes, and snippets.

View 0-README.md

This is a proof-of-concept of a couple of concurrent data structures written in Ruby.

The implementations are heavily commented for those interested. There are benchmarks (with results) included below. The results are interesting, but, as always, take with a grain of salt.

Data structures

AtomicLinkedQueue is a lock-free queue, built on atomic CAS operations.

@jstorimer
jstorimer / hilong.rb
Last active Jul 30, 2020
hilong -- A simply utility to show character counts for each line of input and highlight lines longer than 80 characters.
View hilong.rb
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
#
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
#
# Examples:
#
# $ hilong Gemfile
View .muttrc
set imap_user = 'user@gmail.com'
set imap_pass = 'pass'
set spoolfile = imaps://imap.gmail.com:993/INBOX
set folder = imaps://imap.gmail.com:993
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed=”imaps://imap.gmail.com/[Gmail]/Drafts”
set message_cachedir=”~/.mutt/cache/bodies”
set certificate_file=~/.mutt/certificates
set smtp_url = "smtp://user@smtp.gmail.com:587/"
@jstorimer
jstorimer / tclient.rb
Created Jun 25, 2013
These scripts were the result of the "Faster Rails test runs...with Unix!" screencast at https://www.youtube.com/watch?v=RSehcT4MnRM.
View tclient.rb
#!/usr/bin/env ruby
require 'socket'
test_file = ARGV[0]
socket = UNIXSocket.new('testing.sock')
socket.write(test_file)
socket.close_write
View check_then_set_with_sheep_lock.rb
class Sheep
def initialize
@shorn = false
# Here the sheep owns the mutex. But now the
# shearing logic is muddied up by synchronization
# logic. This doesn't seem like the right place for
# this.
@mutex = Mutex.new
end
@jstorimer
jstorimer / port_scanner.rb
Created Aug 30, 2012
Simple, parallel port scanner in Ruby built with connect_nonblock and IO.select.
View port_scanner.rb
require 'socket'
# Set up the parameters.
PORT_RANGE = 1..512
HOST = 'archive.org'
TIME_TO_WAIT = 5 # seconds
# Create a socket for each port and initiate the nonblocking
# connect.
sockets = PORT_RANGE.map do |port|
@jstorimer
jstorimer / gist:364295
Created Apr 13, 2010
Most used shell aliases from dotfiles repos
View gist:364295
alias ls='ls --color=auto' [230]
alias ll='ls -l' [226]
alias ..='cd ..' [151]
alias la='ls -A' [147]
alias grep='grep --color=auto' [144]
alias l='ls -CF' [101]
alias gb='git branch' [95]
alias ls='ls -G' [95]
alias gd='git diff' [92]
alias egrep='egrep --color=auto' [91]
@jstorimer
jstorimer / -
Last active Dec 25, 2015
Vim plugins + vimrc
View -
git_bundles = [
"git://github.com/ervandew/supertab.git",
"git://github.com/godlygeek/tabular.git",
"git://github.com/hallison/vim-rdoc.git",
"git://github.com/pangloss/vim-javascript.git",
"git://github.com/timcharper/textile.vim.git",
"git://github.com/tpope/vim-cucumber.git",
"git://github.com/tpope/vim-fugitive.git",
"git://github.com/tpope/vim-git.git",
"git://github.com/tpope/vim-haml.git",
View gist:6337721
require 'socket'
client = TCPSocket.new('localhost', 4481)
payload = "Lorem ipsum" * 100_000
total_bytes_written = 0
remaining_payload = payload
begin
puts 'looping'
View gist:5314556
require 'benchmark'
require 'thread'
require 'disruptor'
require_relative 'atomic_linked_queue'
$thread_count = 50
$iterations = 10
Thread.abort_on_exception = true
You can’t perform that action at this time.