Skip to content

Instantly share code, notes, and snippets.

View angch's full-sized avatar

Ang Chin Han angch

  • Kuala Lumpur, Malaysia
View GitHub Profile
@angch
angch / main.go
Created July 8, 2020 09:49
A quickie Go script to populate a database with two tables with test data
package main
// A quickie script to populate a database with two tables with test data
import (
"log"
"reflect"
"github.com/bxcodec/faker/v3"
"github.com/icrowley/fake"
@angch
angch / sum.go
Created June 24, 2020 01:55
quick hack attempting sumtypes in Go
package main
import "log"
// enum ShapeKind { Square, Rectangle, Circle };
// struct Shape {
// int centerx;
// int centery;
// enum ShapeKind kind;
// union {
@angch
angch / angchMacOS.xml
Created April 9, 2020 10:18
sane intellij MacOS keymap
<keymap version="1" name="angchMacOS" parent="Mac OS X 10.5+">
<action id="CollapseAll">
<keyboard-shortcut first-keystroke="meta subtract" />
</action>
<action id="CollapseExpandableComponent">
<keyboard-shortcut first-keystroke="shift enter" />
<keyboard-shortcut first-keystroke="meta subtract" />
</action>
<action id="CollapseRegion">
<keyboard-shortcut first-keystroke="meta subtract" />
@angch
angch / colouraccent.go
Last active February 24, 2020 06:30
Finding and displaying a colour accent from an image https://forum.lowyat.net/topic/4908702/+0&#entry95561089
package main
// https://forum.lowyat.net/index.php?act=ST&f=12&t=4908702&st=0
import (
"fmt"
"image/jpeg"
"log"
"math"
"os"
Sorry, folks, gonna brain dump on my thoughts on FB's zstd compression here. context: http://www.zdnet.com/article/facebook-open-sources-zstandard-data-compression-algorithm-aims-to-replace-technology-behind-zip/
The algo seems very similar to google's brotli, in that they have a decent dictionary or prev common terms even before they start looking at the input to be compressed.
In Mark Nelson's Data Compression Book's terminology, they have a generate and use a better Data Model of the data to be compressed, even before they started. In FB's zstd, they use "learning" to precompute this data model, where as in brotli, I think they hardcoded it.
See rfc17932 on brotli, where the bulk of it is a section on the
Appendix A. Static Dictionary Data they used.
https://www.ietf.org/rfc/rfc7932.txt
package main
import (
"os"
"strings"
"github.com/nlopes/slack"
)
func main() {
@angch
angch / bot.py
Last active March 19, 2023 15:56
I'm bored. Python telegram bot for posting desktop screenshots.
#!/usr/bin/env python3
# FIXME: requirements.txt
# pip3 install python-telegram-bot --upgrade
# pip3 install pyscreenshot
# pip3 install pillow
from telegram.ext import Updater
from telegram.ext import CommandHandler
package main
import (
"database/sql"
"encoding/csv"
"io"
"log"
"os"
// We don't really need gorm, but it's a fast coding shorthand to throw random structs to a DB
@angch
angch / eos.go
Last active June 30, 2017 06:30
package main
import (
"bufio"
"fmt"
"io"
"os"
)
func main() {