Skip to content

Instantly share code, notes, and snippets.

View jakeboxer's full-sized avatar

Jake Card jakeboxer

View GitHub Profile
function(dest, src){
// Split the src into an array of path components
srcComponents = src.split("/")
// Cut out the second to last one
srcComponents.splice(srcComponents.length - 2, 1)
// Join the path components back together into a path
newSrc = srcComponents.join("/")
@jakeboxer
jakeboxer / clean-git-repo.sh
Last active December 15, 2015 19:58
Clean superfluous files out of a Git repo.
#!/bin/sh
#/ Usage: script/clean-git-test-fixture <path.git>
set -e
path="${1%/}"
# bail out if path not specified
if [ -z "$path" ]
then
echo "$(basename $0): path not specified" 1>&2
# Public: Same as Rails' ActionView::Helpers::TextHelper#pluralize, but
# doesn't include the number in the result.
#
# Example:
# pluralize(2, 'commit') # 2 commits
# pluralize_without_number(2, 'commit') # commits
#
# count - Number to use to determine whether or not to pluralize
# singular - How the word should look when singular
# plural - How the word should look when plural. If nothing is supplied, the
Check out this test gist!
names.sort (a, b) ->
a = a.toLowerCase()
b = b.toLowerCase()
if a < b
-1
else if a > b
1
else
0
send_message(:read_objects, miss_oids, type).each do |object|
key = object_key(object['oid'])
objects[key] = object
@cache.set(key, object)
end
def read_full_blob(oid)
object = send_message(:read_full_blob, oid)
object['data'].force_encoding(object['encoding']) if encoding_support?
object
end
@jakeboxer
jakeboxer / gist:4037794
Created November 8, 2012 09:40
Factorial in C
int factorial(int number) {
if (number == 1) {
return 1;
} else {
return number * factorial(number - 1);
}
}
r = Repository.nwo('defunkt/dotjs')
u = User.find_by_login('defunkt')
30.times do
i = r.issues.build
i.user = u
i.title = 'Placeholder issue'
i.body = 'This is the body for the placeholder issue'
i.save
end
@jakeboxer
jakeboxer / gist:3941060
Created October 23, 2012 19:35
Naive string reverse implementation
function reverseString(oldString) {
var newString = "";
for (var i = oldString.length - 1; i >= 0; i--) {
// This line does exactly the same thing as: newString = newString + oldString[i];
newString += oldString[i];
}
return newString;
}