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 node | |
"use strict" | |
class TimeConvert { | |
constructor(str, type = "regex", debug = false) { | |
if (debug) console.log("Original time: " + str) | |
this.str = str | |
this.type = type | |
this.debug = debug | |
} |
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 node | |
"use strict" | |
let fib = function(n, memo={}) { | |
if (n < 2) return n | |
memo[n] = memo[n] || fib(n-2, memo) + fib(n-1, memo) | |
return memo[n] | |
} | |
for(var i=1; i < 11; i++) { |
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 node | |
"use strict" | |
// Create graph/tree type structure | |
class Node { | |
constructor(name) { | |
this._name = name | |
this._children = [] | |
} |
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
function isPrime(n) { | |
if (n <= 1) return false | |
var prime = true | |
var sqrtN = parseInt(Math.sqrt(n)) | |
for (var i = sqrtN; i > 1; i--) { | |
if (n % i == 0) { | |
prime = false | |
break | |
} | |
} |
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
// There are 2 non-negative integers: i and j. Given the following equation, | |
// find an (optimal) solution to iterate over i and j in such a way that the output is sorted. | |
// 2^i * 5^j | |
// So the first few rounds would look like this: | |
// 2^0 * 5^0 = 1 | |
// 2^1 * 5^0 = 2 | |
// 2^2 * 5^0 = 4 | |
// 2^0 * 5^1 = 5 | |
// 2^3 * 5^0 = 8 |
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 | |
export GIT_SSH='dynamic_git_command.sh' | |
swapgitmail() { | |
local email=$(git config --global user.email) | |
if [ "$email" = "[email protected]" ];then | |
git config --global user.email "[email protected]" | |
echo "$(git config --global user.email)" | |
else |
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
docker rmi $(docker images -a | grep "^<none>" | awk '{print $3}') | |
docker images -q --filter "dangling=true" | xargs docker rmi | |
docker rmi $(docker images -q --filter "dangling=true") | |
docker rmi $(docker images -a | grep "^<none>" | awk "{print $3}") | |
docker ps -q -a | xargs docker rm |
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
package testhelpers | |
import ( | |
"fmt" | |
"net/http" | |
"net/http/httptest" | |
"net/url" | |
"github.com/jmcvetta/neoism" | |
) |
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
/^[\w\-\.]+\@[\w\.\-]+\.\w{2,4}$/ | |
# matches | |
# [email protected] | |
# [email protected] | |
# [email protected] | |
# [email protected] | |
# [email protected] | |
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
# Write a function f(a, b) which takes two character string arguments and returns | |
# a string containing only the characters found in both strings in the order of a. | |
# Write a version which is order N-squared and one which is order N. | |
string_a = "abcdefg" | |
string_b = "afcbedf" | |
def common_char_n_squared(string1, string2) | |
common_chars = "" | |
string1.each_char do |i| |