Skip to content

Instantly share code, notes, and snippets.

View tbmreza's full-sized avatar
🎯
Focusing

Reza tbmreza

🎯
Focusing
View GitHub Profile
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
@tbmreza
tbmreza / fbt.agda
Created December 14, 2023 09:58
draft
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong; sym)
open import Data.Nat
open import Data.Bool.Base
data Tree : Set where
tempty : Tree
tnode : ℕ -> Tree -> Tree -> Tree
@tbmreza
tbmreza / helpers.rkt
Last active November 7, 2023 08:21
a growing snippet
#lang racket
(provide (all-defined-out))
(define any? any/c)
(define (until p f)
(define (go x)
(match x
[(? p x) x]
[_ (go (f x))]))
@tbmreza
tbmreza / tricks
Last active October 6, 2024 23:02
unsorted snippets
load .env inline:
env $(cat .env | xargs) mix release
sqlite ls tables:
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public’;
SELECT * FROM sqlite_master where type='table'; -- d1 ok
PRAGMA table_info(table_name);
postgres ls tables:
SELECT * FROM pg_catalog.pg_tables WHERE schemaname='public';
@tbmreza
tbmreza / helpers.go
Last active June 22, 2023 09:11
a growing snippet
func Deref(s *string) string {
if s != nil {
return *s
}
return ""
}
func ParseInt64OrDefault(s string) int64 {
n, strconvErr := strconv.ParseInt(s, 10, 64)
if strconvErr != nil {
-- https://www.ma.imperial.ac.uk/~buzzard/xena/natural_number_game/
-- 1. TUTORIAL
-- world=1&level=1 "using refl"
example : forall x : Nat, x = x := by
intro x
exact Eq.refl x
-- world=1&level=2 "using rw"
example
export function objectCopy(obj) {
if (typeof obj === "object") {
return JSON.parse(JSON.stringify(obj));
} else {
console.log(obj);
}
}
@tbmreza
tbmreza / Modal.svelte
Last active April 4, 2020 15:04
Svelte modal component that can be drawn on top of another.
<script>
export let display;
import ModalInternals from "./ModalInternals.svelte";
let closeModal = false;
const handleClose = () => {
display = false;
};
</script>
from collections import namedtuple
import re
''' TXT structure sample:
"PROVINSI"(489,185),(652,185),(652,219),(489,219)
"JAWA"(658,185),(747,185),(747,219),(658,219)
"BARAT"(758,185),(866,185),(866,219),(758,219)
"KABUPATEN"(508,220),(704,220),(704,252),(508,252)
"BEKASI"(724,220),(848,220),(848,252),(724,252)
@tbmreza
tbmreza / augment_image.py
Created May 4, 2019 07:07
Image augmentation using imgaug that loads JPG files in working directory and saves to result folder.
# Modified from a stackoverflow answer. https://stackoverflow.com/a/52147997
import imgaug as ia
from imgaug import augmenters as iaa
import numpy as np
import imageio
import os
number_of_output = 4
result_folder = 'imgaug/'