Skip to content

Instantly share code, notes, and snippets.

Makistos /
Created May 3, 2019
Script to handle output from cProfile. #python #profiling
import pstats
Makistos / drbob.c
Last active Sep 5, 2018
Step dampener by Dr Bob. #c #dampen
View drbob.c
float actual = 0.0f;
float target = 100.0f;
for ( int step=0; step<500; step++ ){
actual += (target - actual)/16
printf("%f\n", actual);
Makistos / Makefile
Last active Jun 28, 2018
Render psf fonts to terminal. #c #linux #psf #fonts #libz
View Makefile
src = $(wildcard *.c)
obj = $(src:.c=.o)
psf: $(obj)
$(CC) -o $@ $^ $(LDFLAGS)
.PHONY: clean
Makistos / omnisharp.json
Created Feb 19, 2018
Omnisharp settings for C# / Unity3d. Put in <userdir>\.omnisharp\. #csharp #unity3d #code-format
View omnisharp.json
"FormattingOptions": {
"NewLine": "\n",
"UseTabs": false,
"TabSize": 4,
"IndentationSize": 4,
"SpacingAfterMethodDeclarationName": false,
"SpaceWithinMethodDeclarationParenthesis": false,
"SpaceBetweenEmptyMethodDeclarationParentheses": false,
"SpaceAfterMethodCallName": false,
Makistos /
Last active Apr 9, 2018
How to use btrfs to speed up Android development with a crontab job.
# Delete old snapshots except the newest one
# Replace product and variant as needed
del_product () {
read -a FILES <<< `ls -dt $1_BUILD_$2_*`
unset FILES[0] # Do not delete newest
for dir in ${FILES[*]}
Makistos / new_gist_file_0
Created Oct 6, 2017
How to format json in Vim. #json #vim
View new_gist_file_0
:%!python -m json.tool
Makistos /
Last active Sep 27, 2017
How to create a simple 2-disk LVM ext4 partition
# A very comprehensive document:
# Assuming both disks have a partition created already. Think they should be already lvm2 pv?
sudo pvcreate /dev/sdc1 /dev/sdd1
sudo vgcreate workvg /dev/sdc1 /dev/sdd1
sudo lvcreate -l 100%FREE -n worklv workvg
sudo mkfs.ext4 /dev/workvg/worklv
sudo echo '/dev/workvg/worklv /work ext4 defaults 0 2' >> /etc/fstab
Makistos / ioctl-errno.c
Created Jun 26, 2017
A proper way of using ioctl() and errno. #linux #c #errno #ioctl
View ioctl-errno.c
static unsigned char commit_ioctl()
int block_dev = -1;
int error_code = 0;
int retval = 0;
unsigned retry_count = 0;
errno = 0; /* Clear errno - successfull function calls might leave old value. */
block_dev = open(block_dev_name, O_RDWR);
/* Need to save errno as it might be reset by library calls. */
import sys
from prettytable import PrettyTable
from collections import defaultdict
import pprint
# Columns
Makistos /
Last active Apr 20, 2017
Check if a string only has valid words. #python
import sys
valid_words = ('opsub', 'opequal', 'opadd', 'opmult', 'oprdiv', 'opidiv')
def is_valid(str):
return all(word in valid_words for word in str.split())
not_validated = sys.argv[1]
if is_valid(not_validated):