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 main | |
import "fmt" | |
type A struct { | |
a, b int | |
} | |
func MapStructValAsKey(){ | |
// Notice: We are using value of `A`, not `*A` |
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 | |
# Generate RSA private key | |
openssl genrsa -out private_key.pem 1024 |
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
var EPSILON float64 = 0.00000001 | |
func floatEquals(a, b float64) bool { | |
if ((a - b) < EPSILON && (b - a) < EPSILON) { | |
return true | |
} | |
return false | |
} |
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 python | |
import itertools | |
import sys | |
import time | |
import threading | |
class Spinner(object): | |
spinner_cycle = itertools.cycle(['-', '/', '|', '\\']) |
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 python3 | |
import json | |
import os | |
import sys | |
class UserRecord(object): | |
user_id: str | |
first_name: str | |
last_name: str |
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
# Sample file | |
samplef() { | |
# set -x | |
if [ -z "${1}" ]; then | |
echo 'Error: Missing file path' | |
echo | |
echo 'Usage:' | |
echo 'samplef <FILEPATH> <SAMPLE_SIZE>' | |
echo | |
echo 'Optional paramters: <SAMPLE_SIZE>, default is 0.1' |
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
input = 'this_is_a_test_string' | |
output = '' | |
for i in range(0, len(input)): | |
char = input[i] | |
if char == '_': | |
output += '-' | |
else: | |
output += char | |
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 Data() { | |
this.data = [1, 2, 3, 4, 5]; | |
} | |
Data.prototype[Symbol.iterator] = function* () { | |
for (const e of this.data) { | |
yield e; | |
} | |
}; |
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
export class LinkedList { | |
constructor() { | |
this.head = null; | |
} | |
*iterator() { | |
let temp = this.head; | |
while (temp && temp.next) { | |
yield temp.value; | |
temp = temp.next; |
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
interface StopwatchResults { | |
startDate: Date | |
endDate: Date | |
latencyMs: number | |
} | |
class Stopwatch { | |
private startDate?: Date | |
private endDate?: Date |
NewerOlder