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
package main | |
import "fmt" | |
func main() { | |
// create list | |
l := new(List) | |
// append to list | |
for i := 0; i < 100; i++ { | |
l.Append(i) |
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
from functools import reduce, lru_cache | |
fib_bad = lambda n:reduce(lambda x,n:[x[1],x[0]+x[1]], range(n),[0,1])[0] | |
def fib_naive(n): | |
""" fib_naive - naive solution to the fibonacci """ | |
a,b = 1,1 | |
for i in range(n-1): | |
a,b = b,a+b |
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/bash | |
PASS_NAME=$1 | |
KEY_FILENAME=$2 | |
# start ssh-agent | |
eval `ssh-agent -s` | |
# decrypt the rsa private key, using the password from the `pass` command by means of a named pipe | |
openssl rsa -inform PEM -passin file:<(pass show ${PASS_NAME}) -in ${KEY_FILENAME} -text | ssh-add - |
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 digital_root(n): | |
""" digital_root - recursively figure out the digital root of a number""" | |
s = 0 # s -> running sum | |
while n > 0: | |
# take each digit from the number by running mod 10 (ones position in base 10 number) | |
s += int(n%10) | |
# reduce the number by a factor of 10 to remove the ones position | |
n = int(n/10) | |
if s >= 10: | |
# if the num is greater than or equal to 10 recursively call self |
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
package main | |
import ( | |
"fmt" | |
) | |
func reverseStr(s string) string { | |
input := []byte(s) | |
for i := 0; i < len(input)/2; i++ { | |
input[i], input[(len(input)-1)-i] = input[(len(input)-1)-i], input[i] |
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
package main | |
import ( | |
"fmt" | |
) | |
func reverse(input int) int { | |
var result int | |
for ; input != 0; input = input / 10 { | |
result = input%10 + 10*result |
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
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
"time" | |
) |
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/bash | |
function progress { | |
cattail='=' | |
cat1=' ,------, ' | |
cat2=' | /\_/\ ' | |
cat3=' |__( ^ .^) ' | |
cat4=' "" "" ' | |
echo;echo;echo;echo;echo;echo |
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
package main | |
import ( | |
"crypto/tls" | |
"encoding/json" | |
"fmt" | |
"log" | |
"net" | |
"net/http" | |
) |
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
#include <stdlib.h> | |
#include <ncurses.h> | |
#include <unistd.h> | |
/* our cat */ | |
const char nyan_cat[4][12] = { | |
",------, \n", | |
"| /\\_/\\\n", | |
"|__( ^ .^) \n", | |
"\"\" \"\" \n"}; |