Nathan Sutton nate

View rubby.rb
1 2 3 4 5 6 7 8 9 10
def extract_components(filename)
segments = filename.split(" ")
last_segment, *extensions = segments.pop.split(".")
basename = (segments << last_segment).join(" ")
 
[basename, extensions]
end
 
extract_components("a.b c.a")
# => ["a.b c", ["a"]]
View gist:3758090
1 2 3 4 5 6 7 8 9 10
read_pipe, write_pipe = IO.pipe
input_file = File.open("input_video.mp4", "r")
output_file = File.open("output_video.mp4", "w")
 
Thread.new do
loop do
begin
write_pipe.write(input_file.read_nonblock(1024))
rescue EOFError => e
write_pipe.close
View hack.sh
1 2 3 4 5 6 7 8 9
#!/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/2260182/87abace383ef4321d6e9174c29105f66300331d7/hack.sh | sh
#
View gist:3608072
1 2 3 4 5 6 7 8 9 10
api_concern :public_browser_base do |t|
t.add :id
t.add :title
end
 
api_accessible :v1_public_browser do |t|
t.concern :public_browser_base
t.add :current_state
t.add :start_date_unixtime
end
View install_package_manager.sh
1 2 3
echo;echo;echo
echo "YOUR MACHINE WAS JUST OWNED. OR IT WOULD BE, IF I WANTED IT TO BE. IMPLICIT TRUST IS A BAD THING."
echo;echo;echo
View timestamping_cassandra.rb
1 2 3 4 5 6 7 8 9 10
# If you insert a column using a timestamp that is before the current value's
# timestamp, your insert will be rejected. The timestamps come from the client
# not the server unless you're using CQL (apparently).
 
require 'rubygems'
require 'cassandra-cql'
require 'cassandra/1.0'
 
# Freezes time so we can mock it out for the duration of a block
require 'timecop'
View mapping_the_hashes.rb
1 2 3 4 5 6 7 8 9 10
# The data.
array_of_hashes = [{:foo => "bar"},
{:foo => "baz"},
{:foo => "quux"}]
 
# The problem: how to get the values of each key :foo.
 
# The way we do it now. In a chain of methods this looks rather
# busy and takes up a lot of room with ceremony. '|h|' and 'h' are
# not needed, and in the case of longer variable names they become
View roflskizzles.patch
1 2 3 4 5 6 7 8 9 10
diff --git a/benchmarks/uuid.rb b/benchmarks/uuid.rb
index a256a6d..5032bb2 100644
--- a/benchmarks/uuid.rb
+++ b/benchmarks/uuid.rb
@@ -5,6 +5,8 @@ require 'bundler/setup'
require 'celluloid'
require 'benchmark/ips'
+ROFLSCALE = 1000
+
View build.sh
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
 
# Expects the directory structure:
# .
# └── projectname
# ├── build.sh
# └── src
# ├── custompackage
# │   └── custompackage.go
# └── main
View gist:1473552
1 2 3 4 5 6 7 8 9
#!/usr/bin/env ruby
# Setup:
# 1) run: $EDITOR /some/bin/dir/scratch
# My path is /Users/nate/bin/scratch
# 2) Paste this into the file
# 3) run: chmod +x /some/bin/dir/scratch
# 4) run: scratch -h
 
class Scratch
Something went wrong with that request. Please try again.