Skip to content

Instantly share code, notes, and snippets.

@vyder
vyder / override_styles.css
Created November 6, 2012 08:06
CSS for Little Black Book
body {
background: none;
background-color: white;
font-family: Georgia, Times, serif;
}
div.post-outer {
background-color: #ffffff;
color: #000;
font-size: 16pt;
@vyder
vyder / build_dictionary.rb
Created January 25, 2013 19:18
Returns a dictionary hash built from the system dictionary.
def build_dictionary
# from http://stackoverflow.com/a/3480849/834459
dictionary = {}
File.open("/usr/share/dict/words") do |file|
file.each do |line|
dictionary[line.strip] = true
end
end
return dictionary
@vyder
vyder / magic-git-publishing-script.sh
Last active December 17, 2015 10:48
Script to setup publishing a website via git
#!/bin/bash
user=`whoami`
server=`hostname`
path_to_repo_dir="/var/git/"
path_to_www_dir="/var/www/"
project_name=$1
# Init Git repository
@vyder
vyder / multi-dice.rb
Created February 2, 2014 21:08
Any-sided multiple dice, multiple rolls
class Dice
def self.roll( dice = [ "1d6" ], rolls = 1 )
output = "---\n"
rolls.times do |roll|
outcome = []
dice.each do |die|
number_of_dice = die.split('d')[0].to_i
sides = die.split('d')[1].to_i
@vyder
vyder / mouse_wiggle.sh
Last active August 29, 2015 14:02
Wiggle the mouse/cursor every now and then to prevent the screen saver from activating
#!/usr/bin/env bash
#
# 1. Install 'xdotool' - http://www.semicomplete.com/projects/xdotool/
# sudo apt-get install xdotool
# 2. Open a screen session:
# screen -S mouse_wiggle
# 3. Exec this script
# 4. Background the session with Ctrl+A+D
#
exit_cmds = [
"q", "x"
]
voice = ARGV[0] || "whisper" # Defaults to creeper voice
Thread.new do
loop do
sentence = gets.chomp
@vyder
vyder / Rakefile
Last active August 29, 2015 14:09
Octopress - :mass_edit rake task
editor = "iA Writer" # Editor to open markdown posts with
# usage rake mass_edit["category-name"]
desc "Edit all posts with the given category"
task :mass_edit, :category do |t, args|
args.with_defaults(:category => nil)
posts = Dir.glob("#{source_dir}/#{posts_dir}/*.*")
if :category.nil?
puts "No posts found with that category"
@vyder
vyder / nr.sh
Last active August 29, 2015 14:09
A ~/bin script to pre-create a ruby script and open it in nano
filename=$1
touch $filename
cat <<EOM > $filename
#!/usr/bin/env ruby
EOM
chmod +x $filename
nano +3 $filename
@vyder
vyder / latency.txt
Last active August 29, 2015 14:09 — forked from jboner/latency.txt
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
@vyder
vyder / script
Last active August 29, 2015 14:12
OSX - Disk image to USB drive
# Convert iso to img
hdiutil convert -format UDRW -o ~/Desktop/target.img ~/Desktop/ubuntu.iso
# Find the USB drive
diskutil list
# Unmount the drive
diskutil unmountDisk /dev/disk<N>
# Write the file