Skip to content

Instantly share code, notes, and snippets.

View asimihsan's full-sized avatar

Asim Ihsan asimihsan

View GitHub Profile
@kaxing
kaxing / install-python-3.10.x-on-M1-with-asdf.md
Last active September 29, 2022 22:28
Install latest python with asdf on macOS on Apple Silicon

References:

https://qiita.com/que9/items/28a9f7978fd34a620193
https://github.com/pyenv/pyenv/issues/1066#issuecomment-630939869
https://github.com/pyenv/pyenv/issues/2042#issuecomment-1131463276
https://stackoverflow.com/questions/51551557/pyenv-build-failed-installing-python-on-macos

The error:

@john-science
john-science / chess_training.md
Last active February 13, 2025 08:15
Training for Chess

Chess Training

My current goals:

  1. Go through my checklist before EVERY move.
  2. Stop playing hope chess: if you can find a single weakness in an idea, abandon it and find a new idea.

The Checklist

@mimoo
mimoo / fpe.md
Last active June 15, 2021 12:57
History of Format-Preserving Encryption

Introduction

Format Preserving Encryption (FPE) seems to have been invented principally to encrypt credit card numbers into something that looks like a credit card number. Effectively, FPE is a permutation over the domain of the input.

It seems like the main reason is legacy: a lot of databases where created with size and alphabet restrictions on the field of credit card numbers, other systems and applications were probably built to deal with similar restrictions in order to process or transport these credit card numbers. Since it was deemed (I'm guessing) too costly to improve things so that a ciphertext, an IV and an authentication tag could have been stored in there instead; instead rich banks threw money at the problem and cryptographers took the bait.

It seems like there are three ways to do it:

  • Prefix. Your input domain is very small: write the permutation yourself (01 => 10, 00 => 11, etc.). If you don't have imagination, use AES to encrypt your input domain, and truncate. Hopefully it crea
@juliendargelos
juliendargelos / imagemagick-trim-transparent.sh
Last active August 16, 2024 01:33
Imagemagick command that trims transparent pixels from an image.
convert input.png -trim +repage output.png
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active May 7, 2025 16:00
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@eshelman
eshelman / latency.txt
Last active March 4, 2025 03:41 — forked from jboner/latency.txt
HPC-oriented Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference/hit 1.5 ns 4 cycles
Floating-point add/mult/FMA operation 1.5 ns 4 cycles
L2 cache reference/hit 5 ns 12 ~ 17 cycles
Branch mispredict 6 ns 15 ~ 20 cycles
L3 cache hit (unshared cache line) 16 ns 42 cycles
L3 cache hit (shared line in another core) 25 ns 65 cycles
Mutex lock/unlock 25 ns
L3 cache hit (modified in another core) 29 ns 75 cycles
@daredude
daredude / docker-clear.bat
Created June 5, 2016 10:53
delete all docker container and images on windows
@echo off
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i
FOR /f "tokens=*" %%i IN ('docker images --format "{{.ID}}"') DO docker rmi %%i
@simon04
simon04 / gist:6865179
Last active February 15, 2022 06:14
Gradle, Java plugin, Jar MANIFEST, Class-Path is empty

Gradle, Java plugin, Jar MANIFEST, Class-Path is empty

I struggled with with the jar MANIFEST file built with Gradle containing an empty Class-Path. I traced down the problem to the order of the dependencies and jar blocks in the build.gradle file:

Wrong (jar before dependencies):

jar {
    manifest.attributes(
@mvliet
mvliet / flock_decorator.py
Created June 5, 2013 17:34
A python decorator that blocks execution by getting an exclusive lock on the specified file.
import sys
import os
from fcntl import LOCK_EX
from fcntl import LOCK_NB
from fcntl import flock
from time import sleep
NO_BLOCK = 'nb'
BLOCK = 'block'
@rafaelss
rafaelss / build.sh
Last active October 2, 2015 20:18
Script to build nginx with some modules configured
#!/usr/bin/env bash
version="1.5.10"
pcre_version="8.34"
set -e
rm -rf nginx-$version*
# download nginx