Skip to content

Instantly share code, notes, and snippets.

View kotp's full-sized avatar
enjoying life

Victor Goff kotp

enjoying life
View GitHub Profile

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.

@fweep
fweep / .vimrc
Last active August 23, 2017 11:08
Vim configuration for interacting with cscope databases (focus on Ruby).
if has("cscope")
"TODO: turn this all into a plugin.
set nocscopetag
set cscopequickfix=s-,c-,d-,i-,t-,e-
set nocscopeverbose
if filereadable(".git/cscope.out")
cscope add .git/cscope.out
endif
set cscopeverbose
@kotp
kotp / global_var.rb
Last active December 12, 2015 12:29
Exploring modules, constants and methods
puts "Loading global_var.rb"
GlobalConstant = 'GlobalConstant'
$GlobalConstant_WithDollarSign = 'Global Constant with Dollar Sign'
module SharedVar
NAMESPACED_CONSTANT = 'Named spaced constant'
def your_method
"Whatever your method would be."
end
@DouglasAllen
DouglasAllen / bad_method.rb
Last active October 12, 2015 15:28
An irb session with self so help yorselves rhyms with elves doesn't it?
class << self!
end
# => NoMethodError: undefined method `self!' for main:Object
class << self
end
# => nil
self.class
# => Object
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 16, 2025 22:55
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@AudreyJean
AudreyJean / arrays2.rb
Created February 20, 2012 06:57
an edit to my arrays2 program
# a little program to accept a list of words, sort them without using the sort method, and output them in alphabetical order
j = 0
words = []
words2 = []
a_word = 'a' # dummy initialization to get into the until loop below
i = 0
puts "Type a word and press <Enter> (Enter a blank line to quit):"
# Loop to accept an unspecified number of words-- creates original array
until a_word.empty?
a_word = gets.chomp
Gem::Specification.new do |s|
s.name = 'bang'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Jeff Kreeftmeijer'
s.email = '[email protected]'
s.summary = 'Bang!'
s.description = 'Bangs existing model methods'
s.files = ['bang.rb']
@peterc
peterc / irb3.rb
Created September 19, 2011 14:17
irb3 - Run an IRB-esque prompt over multiple Ruby implementations at once using RVM
#!/usr/bin/env ruby
# encoding: utf-8
# irb3 - Runs an IRB-esque prompt (but it's NOT really IRB!) over multiple
# versions of Ruby at once (using RVM)
#
# By Peter Cooper, BSD licensed
#
# Main dependency is term-ansicolor for each impl:
# rvm exec gem install term-ansicolor
@IndianGuru
IndianGuru / jruby01.rb
Created August 28, 2011 00:56
JRuby programs
# First get the current local time
t = Time.now
# to get day, month and year with century
# also hour, minute and second
puts t.strftime("%d/%m/%Y %H:%M:%S")
# You can use the upper case A and B to get the full
# name of the weekday and month, respectively
puts t.strftime("%A")
puts t.strftime("%B")
@mjackson
mjackson / blocks.rb
Created August 11, 2011 18:30
Demonstrates the difference between Ruby's two different block styles.
def a(*args, &block)
puts "a got a block" if block_given?
end
def b(*args, &block)
puts "b got a block" if block_given?
end
# In this call, `b' is called with the block and the
# return value is given to `a' as an argument.