touch ~/.aliases
mkdir ~/.nvm
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
| [pull] | |
| rebase = true | |
| [user] | |
| name = full_name | |
| email = email | |
| signingkey = GPG_SIGNING_KEY | |
| [core] | |
| editor = vim | |
| autocrlf = input | |
| [commit] |
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
| # | |
| # Calculate the median value of a list | |
| def median(list) | |
| sorted = list.sort | |
| length = list.length | |
| (sorted[(length - 1) / 2] + sorted[length / 2]) / 2 | |
| end | |
| # | |
| # Get the spread, mean, and median from a list of race results |
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 | |
| PROJECT=`cd $PWD && git rev-parse --show-toplevel` | |
| STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php` | |
| SFILES=${SFILES:-$STAGED_FILES_CMD} | |
| echo "Checking PHP Lint..." | |
| for FILE in $SFILES | |
| do | |
| php -l -d display_errors=0 $PROJECT/$FILE |
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 powerset(set) | |
| 0.upto(set.size) do |a| | |
| set.combination(a) do |v| | |
| print(v, "\n") | |
| end | |
| end | |
| end | |
| powerset([1, 2, 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
| def calc_time(arr) | |
| mm = arr.each_with_index.minmax | |
| "#{arr} :: Buy at t=#{mm[0][1]} and sell at t=#{mm[1][1]}" | |
| end | |
| puts(calc_time([3, 1, 7, 10, 5])) | |
| puts(calc_time([1, 2, 1, 3, 5, 6, 4])) |
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 get_prev_next(bed, index) | |
| length = bed.count - 1 | |
| prv = nxt = 1 | |
| prv = bed[index - 1] if index > 0 | |
| nxt = bed[index + 1] if index < length | |
| nxt = 0 if index == length | |
| [prv, nxt] | |
| end | |
| def plant_flower(bed) |
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
| # StringMix class | |
| class StringMix | |
| def mix(str1, str2) | |
| setup(str1, str2) | |
| @unique_chars.each do |char| | |
| count1, count2 = count_occurrences(char) | |
| next if count1 < 2 && count2 < 2 | |
| @output << make_fragment(count1, count2, char) | |
| 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
| class FindMin | |
| @@min_diff = Float::INFINITY | |
| @@index = -1 | |
| # Find the minimum value from a set of data given 2 columns | |
| # | |
| # @param [Object] data - The data to use | |
| # @param [Integer] col1 - The first column to compare | |
| # @param [Integer] col2 - The second column to compare | |
| # |
NewerOlder