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
import ( | |
"sort" | |
"strings" | |
) | |
func frequencySort(s string) string { | |
abcfreq := make([]struct { | |
chr rune | |
cnt int | |
}, 128) |
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
func strStr(haystack string, needle string) int { | |
foundpos := -1 | |
if len(needle) < 1 { | |
return 0 | |
} | |
if len(needle) > len(haystack) { | |
return foundpos | |
} | |
/* Find unique char nearest the end of 'needle' to skip with */ |
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" | |
"reflect" | |
) | |
func reverse(slice interface{}) interface{} { | |
/* Completely inefficient but syntactically "convenient" */ | |
s := reflect.ValueOf(slice) |
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" | |
) | |
type Optional(type T) struct { | |
p *T | |
} |
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
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMqrj2Ea7EsGHR5v6I9Trk7K2Y/52uvuMXGUvKBkIUF4 ash@MacBook-Pro |
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 ( | |
"testing" | |
"time" | |
) | |
type TokenRequest struct { | |
Key string | |
Value string |
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
func gobMarshal(v interface{}) ([]byte, error) { | |
var buf bytes.Buffer | |
enc := gob.NewEncoder(&buf) | |
err := enc.Encode(v) | |
return buf.Bytes(), err | |
} | |
func gobUnmarshal(data []byte, v interface{}) error { | |
dec := gob.NewDecoder(bytes.NewReader(data)) | |
return dec.Decode(v) |
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
// NDjsonTojsonArr converts newline-delimited json (indented or minified) | |
// to a json array. Caller should handle cleanup on error. | |
func NDjsonTojsonArr(r io.Reader, w io.WriteCloser) error { | |
w.Write([]byte("[")) | |
var m json.RawMessage | |
dec := json.NewDecoder(r) | |
err := dec.Decode(&m) | |
for { | |
if _, err = w.Write(m); err != nil { |
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" | |
"strconv" | |
"strings" | |
) | |
var testASN = []string{ | |
"AS 6541", |
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
# Glues 4 files into one | |
ffmpeg -i 1xtra.wav.mp4 -i radio1.wav.mp4 -i radio2.wav.mp4 -i radio4.wav.mp4 -filter_complex " | |
nullsrc=size=640x480 [base]; | |
[0:v] setpts=PTS-STARTPTS, scale=320x240 [upperleft]; | |
[1:v] setpts=PTS-STARTPTS, scale=320x240 [upperright]; | |
[2:v] setpts=PTS-STARTPTS, scale=320x240 [lowerleft]; | |
[3:v] setpts=PTS-STARTPTS, scale=320x240 [lowerright]; | |
[base][upperleft] overlay=shortest=1 [tmp1]; | |
[tmp1][upperright] overlay=shortest=1:x=320 [tmp2]; |