Skip to content

Instantly share code, notes, and snippets.

View dahlia's full-sized avatar
⚰️
Off work for the bereavement of my father

Hong Minhee (洪 民憙) dahlia

⚰️
Off work for the bereavement of my father
View GitHub Profile
@dahlia
dahlia / encrypt.py
Last active October 17, 2018 10:08
ECIES + secp256k1, using coincurve (secp256k1 ECDH) and cryptography (AES-GCM)
import os
from coincurve import PrivateKey, PublicKey # type: ignore
from cryptography.hazmat.primitives.ciphers.aead import AESGCM # type: ignore
__all__ = 'decrypt', 'encrypt'
def encrypt(public_key: PublicKey, message: bytes) -> bytes:
disposable_priv_key: PrivateKey = PrivateKey()
@dahlia
dahlia / encykorea.aks.ac.kr.xml
Last active September 29, 2018 21:40
한국민족문화대백과사전 OpenSearch
<?xml version="1.0" encoding="utf-8"?>
<!-- How to install on Firefox:
window.external.AddSearchProvider(
"https://gist.github.com/dahlia/c4b8e88c60c8b273f7ede092b2c1c86b/raw/encykorea.aks.ac.kr.xml"
);
-->
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>한국민족문화대백과사전</ShortName>
<Description>한국민족문화대백과사전 검색</Description>
<InputEncoding>UTF-8</InputEncoding>
@dahlia
dahlia / ledger.sql
Last active April 3, 2018 10:49
Experiments on integrity of ledgers using constraints
BEGIN;
CREATE TABLE transaction (
id uuid PRIMARY KEY,
time timestamptz NOT NULL DEFAULT (now()),
ledger_id uuid NOT NULL,
prev_id uuid,
prev_time timestamptz,
prev_balance decimal NOT NULL,
genesis bool, -- It cannot be false, but only true or NULL.
@dahlia
dahlia / FizzBuzz.hs
Last active January 14, 2018 07:00
FizzBuzz: algebraic data types help you represent disjoint events as disjoint sets.
#!/usr/bin/env runhaskell
module FizzBuzz where
import Control.Monad
data FizzBuzz = Otherwise Int | Fizz | Buzz | FizzBuzz deriving (Show)
fizzBuzz :: Int -> FizzBuzz
fizzBuzz i = case (i `mod` 3 == 0, i `mod` 5 == 0) of
(False, False) -> Otherwise i
@dahlia
dahlia / query_debug.py
Last active May 4, 2018 18:12
Print SQLAlchemy queries (including bind params).
"""Print SQLAlchemy queries (including bind params).
See also: http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html#faq-sql-expression-string
"""
def show_query(query):
qc = query.statement.compile(
dialect=query.session.bind.dialect,
@dahlia
dahlia / Dockerfile
Last active March 13, 2021 08:10
Running X11 GUI apps through Docker + XQuartz on macOS
FROM ubuntu:17.10
# We don't optimize the size of fslayer here...
RUN apt-get update
RUN apt-get install -y \
software-properties-common \
ttf-ubuntu-font-family \
fonts-ubuntu-title \
fonts-ubuntu-font-family-console
RUN add-apt-repository -y \
@dahlia
dahlia / README.md
Last active July 30, 2018 14:02
니름 스프린트 사전 준비
@dahlia
dahlia / README.md
Last active May 7, 2020 16:00
Wikidata Entity ID on Wikipedia

Wikidata Entity ID on Wikipedia

Screenshot

This userscript makes Wikipedia pages to show their corresponding Wikidata entity ID and link to it in the gray parentheses next to the entry title.

Install

@dahlia
dahlia / README.md
Last active December 10, 2018 01:23
Redirect to Canonical Postgres Docs

Redirect to Canonical Postgres Docs

This userscript makes you to always see the canonical ("current") version of PostgreSQL docs instead of the specific (usually outdated) version of that.

Install

Distributed under public domain.

@dahlia
dahlia / Naver_Search_OSID.user.js
Last active July 1, 2017 16:04
네이버 검색 OSID 표시기
// ==UserScript==
// @name Naver Search OSID
// @namespace https://gist.github.com/dahlia/0c9b43a72de292e2660af940ed4149ec
// @description 네이버 검색 OSID 표시기
// @include https://search.naver.com/*
// @include http://search.naver.com/*
// @include http://http://people.search.naver.com/*
// @include https://http://people.search.naver.com/*
// @version 1
// @grant none