Skip to content

Instantly share code, notes, and snippets.

View itdaniher's full-sized avatar

itdaniher itdaniher

  • mosslandia
View GitHub Profile
@itdaniher
itdaniher / compile.py
Last active October 28, 2023 20:33
compile python script to ELF on Linux via cython and gcc
import subprocess
import sys
import tempfile
from Cython.Compiler import Main, CmdLine, Options
in_file_name = sys.argv[1]
source = open(in_file_name).read()
out_file_name = in_file_name.replace('.py', '.out')
temp_py_file = tempfile.NamedTemporaryFile(suffix='.py', delete=False)
@itdaniher
itdaniher / common_and_latin_name.json
Last active March 29, 2023 20:50
common_and_latin_name.json
{
"7 Pot Brain Strain Red Pepper": "Capsicum chinense",
"7 Pot Bubble Gum Pepper": "Capsicum chinense",
"7 Pot Pepper Barrackpore": "Capsicum chinense",
"7 Pot Pepper Brain Strain Yellow": "Capsicum chinense",
"7 Pot Pepper Orange": "Capsicum chinense",
"7 Pot Pepper Yellow": "Capsicum chinense",
"7 Pot Pink Pepper": "Capsicum chinense",
"7 Pot Rust Pepper": "Capsicum chinense",
"Abe Lincoln Tomato": "Solanum lycopersicum",
@itdaniher
itdaniher / rle.py
Last active October 23, 2021 11:26
Run Length Encoding, Two Ways
import numpy as np
import itertools
def rle(x):
where = np.flatnonzero
x = np.asarray(x)
n = len(x)
if n == 0:
return np.array([], dtype=int)
starts = np.r_[0, where(~np.isclose(x[1:], x[:-1], equal_nan=True)) + 1]
@itdaniher
itdaniher / Dockerfile
Created November 5, 2020 00:47
leveldbjni for arm32 / armv7l
FROM adoptopenjdk/openjdk11:armv7l-debian-jdk-11.0.8_10
WORKDIR /app
RUN apt update && apt install -y wget
RUN wget -O /app/Amm https://github.com/lihaoyi/Ammonite/releases/download/2.2.0/2.12-2.2.0 && chmod +x /app/Amm
RUN apt install -y git build-essential automake unzip
# grab leveldb source and patch it
RUN git clone git://github.com/chirino/leveldb.git && cd leveldb && wget https://raw.githubusercontent.com/fusesource/leveldbjni/master/leveldb.patch && git apply ./leveldb.patch
# no make install target in leveldb, so manually copy libs
RUN cd /app/leveldb && make -j3 && cp libleveldb.* /usr/lib/
# grab native source blob from maven
@itdaniher
itdaniher / getLoadedNativeLibraries.scala
Created November 4, 2020 23:10
get a list of the loaded native libraries in the current jvm, in scala / ammonite
val libs = classOf[ClassLoader].getDeclaredField("loadedLibraryNames")
libs.setAccessible(true)
libs.get(ClassLoader.getSystemClassLoader).asInstanceOf[java.util.HashSet[String]].toArray
@itdaniher
itdaniher / flockhart.json
Created March 14, 2019 06:28
flockhart.json
{
"3a457": {
"substrates": {
"alfentanil": [
"Human alfentanil metabolism by cytochrome P450 3A3/4. An explanation for the interindividual variability in alfentanil clearance? [ PMID 8484504 ] Kharasch ED, Thummel KE. Anesth Analg 1993;76:1033-1039."
],
"alprazolam": [
"Alprazolam is another substrate for human cytochrome P450-3A isoforms. [ PMID 9617989 ] Venkatakrishnan K, Greenblatt DJ, von Moltke LL, Shader RI. JClin Psychopharmacol 1998 Jun;18(3):256."
],
"amlodipine": [
@itdaniher
itdaniher / sshtunnel.conf
Created December 18, 2018 05:49
sshtunnel service
REMOTE_SSH_PORT_TO_BIND=8192
REMOTE_SSH_KEY_FULLPATH=/etc/sshtunnel.privkey
REMOTE_SSH_IP=255.255.255.255
REMOTE_SSH_USER=root
@itdaniher
itdaniher / make.sh
Last active October 26, 2018 20:07
compile sqlite4java for arm / arm64 / aarch64 / armv8
gcc -O2 -DNDEBUG -fpic -DARM -DARCH="ARM" -DLINUX -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LITTLE_ENDIAN -fno-omit-frame-pointer -fno-strict-aliasing -static-libgcc -I./sqlite -I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 -DHAVE_READLINE=0 -DSQLITE_THREADSAFE=1 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DTEMP_STORE=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OS_UNIX=1 -c ./sqlite/sqlite3.c -o sqlite3.o
gcc -O2 -DNDEBUG -fpic -DARM -DARCH="ARM" -DLINUX -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -D_LITTLE_ENDIAN -fno-omit-frame-pointer -fno-strict-aliasing -static-libgcc -I./sqlite -I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_STAT2 -DHAVE_READLINE=0 -DSQLITE_THREADSAFE=
@itdaniher
itdaniher / fail.py
Created September 21, 2018 18:02
😑
import asyncio
import sys
async def test():
1//0
loop = asyncio.get_event_loop()
def asyncio_handler(loop, context):
print("XXXX", "got", context)
@itdaniher
itdaniher / null
Created March 16, 2018 00:47
got root
PID USER TIME COMMAND
1 root 0:01 init [5]
2 root 0:00 [kthreadd]
3 root 0:00 [ksoftirqd/0]
4 root 0:00 [kworker/0:0]
5 root 0:00 [kworker/u:0]
6 root 0:00 [khelper]
7 root 0:00 [netns]
8 root 0:00 [sync_supers]
9 root 0:00 [bdi-default]