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
// HexToRGB converts a 24 bit hex number into its corresponding RGB color | |
// with 100% alpha | |
// | |
// clr := HexToRGB(0xFFAA00) | |
// fmt.Printf("%+v\n", clr) // {R:255 G:170 B:0 A:255} | |
func HexToRGB(hex uint32) color.RGBA { | |
r := uint8((hex & 0xFF0000) >> 16) | |
g := uint8((hex & 0xFF00) >> 8) | |
b := uint8(hex & 0xFF) |
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
/** | |
* Simple class for managing callable observers. | |
*/ | |
export class Observable<Fn extends (...args) => any> { | |
private observers: Set<Fn> = new Set(); | |
add(o: Fn): void { | |
this.observers.add(o); | |
} |
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
// ParseFieldName takes a reflected struct field and returns the JSON name for the field, | |
// as well if the field is ignored by JSON (using `json:"-"`). | |
func ParseFieldName(f reflect.StructField) (name string, ignore bool) { | |
tag := f.Tag.Get("json") | |
if tag == "" { | |
return f.Name, false | |
} | |
if tag == "-" { |
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" | |
"github.com/skratchdot/open-golang/open" | |
"net" | |
"net/http" | |
) | |
func main() { |
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 | |
""" | |
Django SECRET_KEY generator. | |
""" | |
from django.utils.crypto import get_random_string | |
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' | |
print(get_random_string(50, chars)) |