Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / git-repo-statuses.sh
Last active December 18, 2022 07:01
Get a nice list of git repository statuses using the repo tool. #repo #git #git-status
# Get a list of all the repos
repo forall -c 'echo $REPO_PROJECT; git status -s'
# Just list the changed repos
repo forall -c 'if [ "$(git status --porcelain)" != "" ]; then echo $REPO_PROJECT; fi'
# Print the contents, also only include projects from given list
repo forall $(cat projects) -c 'if [ "$(git status --porcelain)" != "" ]; then echo $REPO_PROJECT; git status -s; fi'
# Check both branch and (un)staged commits
@Makistos
Makistos / csac.sh
Created October 28, 2013 08:03
A script to help run Coverity Static Analysis. Script should be run from the root directory of the SW package under analysis. Package related paths are relative to this path. The configuration file should have the following common settings: # General settings COVERITY_BIN_DIR="/location/of/coverity/bin/dir" CONFIG_FILE="/location/of/coverity/con…
#!/bin/bash
###############################################################################
#
# csac - Coverity Static Analysis Control
#
# A script for easier handling of Coverity Static Analysis process. This
# script can be used to build, analyze and/or commit source code for
# Coverity Integrity Manager.
#
@Makistos
Makistos / round-robin.java
Created October 28, 2013 07:56
This is a round-robin algorithm implemented in Java. #round-robin #scheduling #algorithm #java
import java.util.*;
public class Scheduler {
/** The schedule list. */
private Matches matches = new Matches();
public Scheduler(Teams participants) {
createSchedule(participants);
}
@Makistos
Makistos / roundRobin.py
Created October 28, 2013 07:40
A round-robin algorithm implementation written in Python. #round-robin #scheduling #algorithm #python
#!/usr/bin/python
div1 = ["Lions", "Tigers", "Jaguars", "Cougars"]
div2 = ["Whales", "Sharks", "Piranhas", "Alligators"]
div3 = ["Cubs", "Kittens", "Puppies", "Calfs"]
def create_schedule(list):
""" Create a schedule for the teams in the list and return it"""
s = []
@Makistos
Makistos / .vimrc
Last active December 16, 2019 11:37
My .vimrc. #vim #vimrc #viml
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible " be iMproved
filetype off " required!
filetype plugin on
filetype plugin indent on
set clipboard=unnamedplus,autoselect
@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 / socket.md
Last active September 5, 2018 08:10
A simple Linux socket example. #c #socket #linux

Socket example

Compile with

gcc -Wall -pedantic -Wextra -Werror client.c socket.c -o client && gcc server.c socket.c -o server -lpthread

(Should produce no warnings.)

This simple socket example demonstrates how to run a server and multiple clients. Client can be started with or without a parameter. If a parameter is