Skip to content

Instantly share code, notes, and snippets.

require 'rspec'
describe 'flip flop ragerts' do
it 'matches stuff between the same thing' do
text = %{here's some {code} text that is gross {code} and shouldn't be done}
res = text.split.inject([]) { |a, t| a << t if t =~ /{code}/ ... t =~ /{code}/; a }.join(' ')
expect(res).to eq(%{{code} text that is gross {code}})
end
end
@da3mon
da3mon / latency.txt
Last active September 12, 2015 04:34 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
#!/bin/bash
volume=$(osascript -e "get output volume of (get volume settings)")
muted=$(osascript -e "get output muted of (get volume settings)")
if [[ $volume -lt 30 ]]; then
osascript -e "set volume output volume 30"
fi
afplay ~/snd/$1.mp3
osascript -e "set volume output volume $volume"

Keybase proof

I hereby claim:

  • I am da3mon on github.
  • I am da3mon (https://keybase.io/da3mon) on keybase.
  • I have a public key whose fingerprint is 9A06 D25D BCB0 3549 A551 5A74 7D13 7C3A F48D A276

To claim this, I am signing this object:

Factor factor
Fancy fancy, fy
Io io
Lua lua
MiniD minid
MoonScript moon, moonscript
Perl perl, pl
Python 3 python3, py3
Python 3 tracebacks py3tb
Python 3 console pycon
#!/usr/bin/env ruby -wKU
# encoding: UTF-8
class Flip
# sɹǝɔuɐʃɐqpɐoʃ ƃuıʞɔnɟノ(ಠ 益ಠ ノ) -> (ノಠ益ಠ)ノ彡fucking loadbalancers
# add arg support for flipping, reverse flipping, copying to clipboard, text, table, face style
TABLE = {
"a" => "\220\311", "b" => "q", "c" => "\224\311", "d" => "p", "e" => "\235\307", "f" => "\237\311", "g" => "\203\306", "h" => "\245\311", "i" => "\261\304",
"j" => "\276\311", "k" => "\236\312", "l" => "\203\312", "m" => "\257\311", "n" => "u", "r" => "\271\311", "t" => "\207\312", "v" => "\214\312", "w" => "\215\312",
"y" => "\216\312", "." => "\231\313", "[" => "]", "(" => ")", "{" => "}", "?" => "\277\302", "!" => "\241\302", "\"" => ",", "<" => ">", "_" => "\276\200\302",
@da3mon
da3mon / Gemfile
Created September 14, 2012 22:07
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@da3mon
da3mon / slapdash.rb
Created April 12, 2012 23:09
defiling science
class AttributeError < RuntimeError; end
def foo
return @foo if defined?(@foo)
raise AttributeError
end
foo
@foo = :foo
@da3mon
da3mon / hack.sh
Created April 1, 2012 01:41 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@da3mon
da3mon / gist:1077063
Created July 11, 2011 23:41
‽‽‽
ree:044 > 1800.seconds
=> 1800 seconds
ree:045 > 1800
=> 1800
ree:046 > 3 * 600.seconds
=> 1800
ree:047 > 1800.seconds.class
=> Fixnum
ree:048 > 1800.seconds.ago
=> Mon, 11 Jul 2011 23:07:01 UTC +00:00