I like to work using a separate tmux session for each active project/folder that I'm juggling. This script will either create or attach to a project based on it's name, using fasd to jump to the directory directly. The project will be named based on the basename of the folder, for easy switching using TMUX-s.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
devs = %w{ Andrew Anthony Ben Matt Tom Zac } | |
devs << nil if devs.length.odd? | |
top, bottom = devs.each_slice(devs.length/2).to_a | |
pivot, *top = top | |
result = [] | |
(devs.length-1).times do | |
top.unshift(bottom.shift) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'haml' | |
def line_counter(node) | |
decendants = node.children.map{|n| line_counter(n)} | |
if node.type == :filter && %w{ javascript erb plain }.include?(node.value[:name]) | |
me = node.value[:text].split("\n").length | |
else | |
me = 0 | |
end | |
sum(decendants) + me |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 'map', 'transform', 'select', or 'project' function. Iterate over a list, | |
// performing a function on each item, and collecting the new items. Each | |
// function takes an item as a first argument and returns a transformed item. | |
// You can pass additional arguments to the function too, which is a decent poor | |
// man's function composition. | |
// (I didn't call this f-map because the term 'map' is already used in Sass to | |
// denote a hash or dictionary.) | |
@function f-apply($func, $list, $args...) { | |
$new-list: (); | |
@each $item in $list { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def int(mid) | |
meth = instance_method(mid) | |
define_method(mid) { |*args, &bk| | |
val = meth.bind(self).call(*args, &bk) | |
raise TypeError, "#{mid} did not return an Integer" unless val.is_a? Integer | |
val | |
} | |
mid | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The Grid ---------------------- */ | |
.lt-ie9 .row { width: 940px; max-width: 100%; min-width: 768px; margin: 0 auto; } | |
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; } | |
.lt-ie9 .row.large-collapse .column, | |
.lt-ie9 .row.large-collapse .columns { padding: 0; } | |
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; } | |
.lt-ie9 .row .row.large-collapse { margin: 0; } | |
.lt-ie9 .column, .lt-ie9 .columns { float: left; min-height: 1px; padding: 0 15px; position: relative; } | |
.lt-ie9 .column.large-centered, .columns.large-centered { float: none; margin: 0 auto; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Wraps curl with a custom-drawn progress bar. Use it just like curl: | |
# | |
# $ curl-progress -O http://example.com/file.tar.gz | |
# $ curl-progress http://example.com/file.tar.gz > file.tar.gz | |
# | |
# All arguments to the program are passed directly to curl. Define your | |
# custom progress bar in the `print_progress` function. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'thread' | |
server = TCPServer.open(8080) | |
HEADER = <<-EOH | |
HTTP/1.1 200 OK | |
Content-Type: text/html; charset=ISO-8859-1 | |
EOH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
An introduction to curl
using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
NewerOlder