This file contains hidden or 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
| 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("/") | |
This file contains hidden or 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
| #!/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 |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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
| Check out this test gist! |
This file contains hidden or 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
| names.sort (a, b) -> | |
| a = a.toLowerCase() | |
| b = b.toLowerCase() | |
| if a < b | |
| -1 | |
| else if a > b | |
| 1 | |
| else | |
| 0 |
This file contains hidden or 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
| send_message(:read_objects, miss_oids, type).each do |object| | |
| key = object_key(object['oid']) | |
| objects[key] = object | |
| @cache.set(key, object) | |
| end |
This file contains hidden or 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
| def read_full_blob(oid) | |
| object = send_message(:read_full_blob, oid) | |
| object['data'].force_encoding(object['encoding']) if encoding_support? | |
| object | |
| end |
This file contains hidden or 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
| int factorial(int number) { | |
| if (number == 1) { | |
| return 1; | |
| } else { | |
| return number * factorial(number - 1); | |
| } | |
| } |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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; | |
| } |