Skip to content

Instantly share code, notes, and snippets.

Tested Environment

  • Ubuntu 20.04 LTS
  • CUDA 11.6
  • GCC 9.4.0
  • Mono 6.12.0

Be careful with your driver and runtime version! For example, when I tried to run a binary compiled with CUDA 9.2 on a machine with CUDA runtime 9.0, it said 'DeviceCount = 0'.

@shakna-israel
shakna-israel / Prose.md
Last active January 6, 2025 17:00
Obfuscating Python

Obfuscating Python

Obfuscation isn't difficult in most programming languages. It's why we have "good practices" because it is so easy to hide what you mean in badly written code.

Obfuscation tends to be even easier in dynamic languages because of how forgiving they tend to be - and because they tend to give you direct access to the environment so that you can manipulate it.

Today, for fun, I'm going to obfuscate this code:

def _(n):

if n <= 0:

@bbarad
bbarad / mrc_to_pngs.py
Created October 3, 2019 21:50
Convert Class Average MRC File to PNGs
import imageio
import mrcfile
import os
import sys
def make_photos(basename, working_directory="."):
"""
Convert MRC file with stack of classes to series of scaled PNGs for web viewing.
Args:
basename (str): name of desired folder within class_images - usually the same name as the mrc file.
@thomasaarholt
thomasaarholt / velox_dcfi.py
Last active November 22, 2025 03:42
Get DCFI shifts from a velox STEM file, then apply them to all the raw signals in the dataset.
# Script should be applied to a single Velox emd file, where the file contains a single DCFI dataset
# that has been applied to the detector signal that one wishes to apply to the other detector signals
# A good example is using DCFI on a DF image, and then applying this correction to HAADF, BF and ABF.
import hyperspy.api as hs
import json
import h5py
import numpy as np
def get_nonDCFI_signals(list_of_signals):

Links

  • CMakeSL RSS - I'm going to reuse my page feed. I'm not going to post every article at r/cpp or r/cmake, so if you want to be notified about new CMakeSL arts, the RSS is the only reliable way.
  • CMakeSL repo

CMakeSL - abseil-cpp scripts

This article is meant to present what's going on with the CMakeSL project. If you don't know what the CMakeSL is, check out this gist or the readme.

CMakeSL changes

@asarnow
asarnow / ctf.py
Created March 23, 2019 19:50
Function for evaluating the CTF on a grid of spatial frequencies
def eval_ctf(s, a, def1, def2, angast=0, phase=0, kv=300, ac=0.1, cs=2.0, bf=0, lp=0):
"""
:param s: Precomputed frequency grid for CTF evaluation.
:param a: Precomputed frequency grid angles.
:param def1: 1st prinicipal underfocus distance (Å).
:param def2: 2nd principal underfocus distance (Å).
:param angast: Angle of astigmatism (deg) from x-axis to azimuth.
:param phase: Phase shift (deg).
:param kv: Microscope acceleration potential (kV).
:param ac: Amplitude contrast in [0, 1.0].
@deyixtan
deyixtan / sublime_text_patch.md
Last active March 23, 2026 00:51
Sublime Text Patching Guide

Automated Patching

Download slt.py python script (supports multiple build) from this repository.

Usage

python slt.py <"sublime_text file path">


Manual Patching

@pcornier
pcornier / love&droidEdit.txt
Last active November 12, 2022 10:27
External command for DroidEdit that runs a project w/ Löve. Termux & Löve2D are required.
- project directory in /storage/emulated/0/Download/projects/...
- sshd is running in termux and storage mounted
- files are edited with DroidEdit through ssh: ~/storage/downloads/projects/...
- external Löve command:
cd ${path} && zip -r test.love * -x test.love && am start -t org.love2d.android -a android.intent.action.VIEW -d "file://${path}/test.love"
@whour
whour / Sublime Text Licence Key Build 3156
Created December 12, 2017 02:49 — forked from dr3772/Sublime Text Licence Key Build 3156
Sublime Text Dev Build 3156 Serial Key
----- BEGIN LICENSE -----
eldon
Single User License
EA7E-1122628
C0360740 20724B8A 30420C09 6D7E046F
3F5D5FBB 17EF95DA 2BA7BB27 CCB14947
27A316BE 8BCF4BC0 252FB8FF FD97DF71
B11A1DA9 F7119CA0 31984BB9 7D71700C
2C728BF8 B952E5F5 B941FF64 6D7979DA
B8EB32F8 8D415F8E F16FE657 A35381CC
@f0k
f0k / cuda_check.py
Last active September 29, 2025 21:06
Simple python script to obtain CUDA device information
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Outputs some information on CUDA-enabled devices on your computer,
including current memory usage.
It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1
from C to Python with ctypes, so it can run without compiling anything. Note
that this is a direct translation with no attempt to make the code Pythonic.