Skip to content

Instantly share code, notes, and snippets.

Marko Makistos

Block or report user

Report or block Makistos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Makistos
Makistos / dumpprof.py
Created May 3, 2019
Script to handle output from cProfile. #python #profiling
View dumpprof.py
import pstats
pstats.Stats('prof').strip_dirs().sort_stats("cumulative").print_stats()
@Makistos
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
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)
LDFLAGS = -lz
psf: $(obj)
$(CC) -o $@ $^ $(LDFLAGS)
.PHONY: clean
clean:
@Makistos
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
Makistos / del-old-snapshots.sh
Last active Apr 9, 2018
How to use btrfs to speed up Android development with a crontab job.
View del-old-snapshots.sh
#!/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 Oct 6, 2017
How to format json in Vim. #json #vim
View new_gist_file_0
:%!python -m json.tool
@Makistos
Makistos / create_2disk_lvm.sh
Last active Sep 27, 2017
How to create a simple 2-disk LVM ext4 partition
View create_2disk_lvm.sh
# 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 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. */
View tpf.py
#!/usr/bin/python
import sys
from prettytable import PrettyTable
from collections import defaultdict
import pprint
# Columns
HOME_TEAM = 1
AWAY_TEAM = 4
@Makistos
Makistos / validate.py
Last active Apr 20, 2017
Check if a string only has valid words. #python
View validate.py
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):
You can’t perform that action at this time.