Skip to content

Instantly share code, notes, and snippets.

View johncf's full-sized avatar

John Charankattu johncf

View GitHub Profile
@johncf
johncf / find.sh
Last active April 20, 2024 20:32 — forked from gr1ev0us/find.sh
Cheatsheet for find linux
# Based on: https://alvinalexander.com/unix/edu/examples/find.shtml
# basic 'find file' commands
# --------------------------
find / -name foo.txt -type f -print # find regular files under / with name foo.txt
find / -name foo.txt -type f # -print is the default action, and may be omitted
find . -name foo.txt # search under the current dir, and all types
find . -name "foo*" -type d # wildcard name-matching, and only directories
find /opt /usr /var -name foo.scala -type f # search multiple dirs
find . -iname foo # case-insensitive: foo, Foo, FOo, FOO, etc.
@johncf
johncf / onnx-inspect.py
Created November 15, 2023 18:41
Inspect an ONNX model file for sanity
import sys
import traceback
import onnx
if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} /path/to/model.onnx")
sys.exit(1)
model_path = sys.argv[1]
@johncf
johncf / imagenet-extract-val.py
Last active November 15, 2023 19:20
Extract validation set from IMAGENET into another zip file, with label-directories
import os.path
import gzip
import pickle
from zipfile import ZipFile
# from https://github.com/onnx/models/blob/8d50e3f/vision/classification/imagenet_val_maps.pklz
with gzip.open('imagenet_val_maps.pklz', 'rb') as f:
dirs, mappings = pickle.load(f)
src_dir = "ILSVRC/Data/CLS-LOC/val"
target_dir = "ILSVRC/val"
unmap j
unmap k
unmap h
map j scrollLeft
map k scrollDown
map h scrollUp
unmap J
unmap H
map J goBack
P: Parts
C: Confusable
Ex: Example
Mn: Mnemonic
adv. -- adverb
n. -- noun
i-adj. -- I-adjective
na-adj. -- NA-adjective
prop. n. -- proper noun
@johncf
johncf / torr-details.py
Created March 28, 2018 19:24
Torrent: download specific pieces with libtorrent
#!/bin/env python3
import libtorrent as lt
with open("/path/to/file.torrent", "rb") as f:
e = lt.bdecode(f.read())
info = lt.torrent_info(e)
print(info.num_pieces(), 'pieces')
files = info.files()
def humanize(size_bytes):
# Maintainer: John C F <john.ch.fr [at] gmail [dot] com>
pkgname=woff2-bin
pkgver=1.0.2
_debver=1.0.2-1
pkgrel=1
pkgdesc="Utilities for converting TTF fonts to the compressed WOFF 2.0 format, and vice versa."
url="https://github.com/google/woff2"
arch=(x86_64)
license=(MIT)
@johncf
johncf / mui2-custompage-nsd.nsi
Last active August 29, 2023 06:28
NSIS Example using MUI2 with a custom page built with NsDialogs.
!include nsDialogs.nsh
!include LogicLib.nsh
!include MUI2.nsh
Name nsDialogs
OutFile nsDialogs.exe
RequestExecutionLevel user
ShowInstDetails show
Var Dialog
@johncf
johncf / vimium.json
Last active December 9, 2017 17:28
Vimium config backup (colemak)
{
"settingsVersion": "1.62",
"exclusionRules": [
{
"pattern": "https?://mail.google.com/*",
"passKeys": ""
}
],
"filterLinkHints": false,
"waitForEnterForFilteredHints": true,
set path=%path%;C:\Program Files\7-Zip
7z x jdk8.exe -ojdk8
cd jdk8
7z x tools.zip
for /r %%w in (*.pack) do bin\unpack200 "%%w" "%%~dpnw.jar"
for /r %%w in (*.pack) do del "%%w"
del tools.zip javafx-src.zip
rmdir /S /Q db lib\missioncontrol lib\visualvm