Skip to content

Instantly share code, notes, and snippets.

View x77686d's full-sized avatar

William H. Mitchell x77686d

View GitHub Profile
@x77686d
x77686d / showseq2.rb
Created March 7, 2016 17:09
Demonstrates exponential slowdown with string[n] = "x" as n grows.
=begin
It seems that Ruby 2.2.4, string[n] = "x" is not O(1). It was suggested that
this was due to UTF-8 encoding, but I see the same performance with US-ASCII.
Any ideas?
$ ruby --version
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
$ time ruby -E US-ASCII:US-ASCII storeseq2.rb 1000 1000
@x77686d
x77686d / cb
Last active August 29, 2015 14:07
cb script
#!/bin/bash
#
# cases:
# cb ARGS -- if any args, put them on the clipboard
# cb | wc -- stdin is a tty, send clipboard to stdout
# date | cb -- stdin is not a tty, put stdin on clipboard
#
if [ $# -ne 0 ]
then
echo -n $* | cb