Skip to content

Instantly share code, notes, and snippets.

@Makistos
Makistos / Dockerstuff
Last active June 14, 2023 10:10
Some useful docker commands
* Build docker compose without cache:
docker build --no-cache
* Clean all:
docker system prune -a
* Force docker compose to rebuild:
docker compose rm -f
* Clean various stuff:
@Makistos
Makistos / dumpprof.py
Created May 3, 2019 19:51
Script to handle output from cProfile. #python #profiling
import pstats
pstats.Stats('prof').strip_dirs().sort_stats("cumulative").print_stats()
@Makistos
Makistos / drbob.c
Last active September 5, 2018 12:56
Step dampener by Dr Bob. #c #dampen
float actual = 0.0f;
float target = 100.0f;
for ( int step=0; step<500; step++ ){
actual += (target - actual)/16
printf("%f\n", actual);
}
@Makistos
Makistos / Makefile
Last active December 8, 2023 13:38
Render psf fonts to terminal. #c #linux #psf #fonts #libz
src = $(wildcard *.c)
obj = $(src:.c=.o)
LDFLAGS = -lz
psf: $(obj)
$(CC) -o $@ $^ $(LDFLAGS)
.PHONY: clean
clean:
@Makistos
Makistos / omnisharp.json
Created February 19, 2018 22:13
Omnisharp settings for C# / Unity3d. Put in <userdir>\.omnisharp\. #csharp #unity3d #code-format
{
"FormattingOptions": {
"NewLine": "\n",
"UseTabs": false,
"TabSize": 4,
"IndentationSize": 4,
"SpacingAfterMethodDeclarationName": false,
"SpaceWithinMethodDeclarationParenthesis": false,
"SpaceBetweenEmptyMethodDeclarationParentheses": false,
"SpaceAfterMethodCallName": false,
@Makistos
Makistos / del-old-snapshots.sh
Last active April 9, 2018 09:49
How to use btrfs to speed up Android development with a crontab job.
#!/bin/bash
# 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[*]}
do
@Makistos
Makistos / new_gist_file_0
Created October 6, 2017 10:41
How to format json in Vim. #json #vim
:%!python -m json.tool
@Makistos
Makistos / create_2disk_lvm.sh
Last active September 27, 2017 06:58
How to create a simple 2-disk LVM ext4 partition
# A very comprehensive document: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html-single/Logical_Volume_Manager_Administration/index.html
# 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
Makistos / ioctl-errno.c
Created June 26, 2017 10:07
A proper way of using ioctl() and errno. #linux #c #errno #ioctl
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. */
@Makistos
Makistos / tpf.py
Last active April 27, 2017 16:46
#python
#!/usr/bin/python
import sys
from prettytable import PrettyTable
from collections import defaultdict
import pprint
# Columns
HOME_TEAM = 1
AWAY_TEAM = 4