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 / malaysia.districts.geojson
Created March 31, 2017 11:22
geojson of malaysia's districts (mukim) converted from gadm.org for convenience
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@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
@angch
angch / knapsack.go
Last active February 21, 2018 02:14
Code kata. Go. Knapsack problem, "dynamic programming". https://forum.lowyat.net/topic/3765924/+0
// https://forum.lowyat.net/topic/3765924/+0
package main
import "fmt"
/*
1. A vase that weights 3 pounds and is worth 50 dollars.
2. A silver nugget that weights 6 pounds and is worth 30 dollars.
3. A painting that weights 4 pounds and is worth 40 dollars.
4. A mirror that weights 5 pounds and is worth 10 dollars.
package main
import (
"os"
"strings"
"github.com/nlopes/slack"
)
func main() {