Skip to content

Instantly share code, notes, and snippets.

View lofaldli's full-sized avatar

André Løfaldli lofaldli

View GitHub Profile

How to slack off

  1. zcat /var/log/*.gz | bash -c 'while read line; do echo $line; sleep "0.$((1+$RANDOM%6))"; done'
  2. cat $(find /var/log/ -exec file {} \; | grep text | cut -d: -f1)
  3. sed -re s/'[0-9]{4}(-[0-9]{2}){2} [0-9]{2}(:[0-9]{2}){2}'/"$(date +'%Y-%m-%d %H:%M:%S')"/g
  4. cat /dev/urandom | hexdump -C | grep "ca fe"
  5. hexdump -C /dev/urandom
@lofaldli
lofaldli / Makefile
Last active March 1, 2016 13:26
a self-documenting makefile
build: ## build all object files
@echo "building..."
@g++ -o test.o test.cc
clean: ## remove all object files
@echo "removing object files"
@rm *.o
.PHONY: help
help:
@lofaldli
lofaldli / .bash_aliases
Created April 6, 2016 15:19
some useful aliases for bash
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias h='history'
alias j='jobs -l'
alias path='echo -e ${PATH//:/\\n}'
alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
alias pypath='echo -e ${PYTHONPATH//:/\\n}'
@lofaldli
lofaldli / startup_script.sh
Last active October 10, 2016 22:10
copy to .local/bin and add to Settings -> Session and Startup -> Application Autostart
#!/bin/sh
# wait a litte while
sleep 5
# enable natural scrolling
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Scrolling Distance" -109, -109
# start dropbox daemon
/home/$USER/.dropbox-dist/dropboxd
#!/usr/bin/python
import sys
import datetime
# Calculates death probabilities based on Social Security
# actuarial tables for a given group of people.
# Run with a list of ages/genders and an optional timespan (or year in the future):
# python actuary.py 63m 80m 75f 73m 10
@lofaldli
lofaldli / simple-http.py
Created July 11, 2017 06:25
r/dailyprogrammer challenge 7/7/17
import os
import socket
STATUS_CODES = {
200: 'ok',
400: 'bad request',
404: 'file not found',
500: 'internal server error'
}
@lofaldli
lofaldli / simulator.grc
Created July 13, 2017 13:49
gnuradio mpsk + cc simulator
<?xml version='1.0' encoding='utf-8'?>
<?grc format='1' created='3.7.9'?>
<flow_graph>
<timestamp>Thu Jul 13 09:27:07 2017</timestamp>
<block>
<key>options</key>
<param>
<key>author</key>
<value></value>
</param>
@lofaldli
lofaldli / wav2mmv
Last active December 2, 2024 09:06
convert wave files to custom format used by MMSSTV (http://hamsoft.ca/pages/mmsstv.php)
#!/usr/bin/env bash
[ $# -eq 0 ] && { echo "no inputfile given"; exit 1; }
[ ! -f $1 ] && { echo "file $1 not found"; exit 1; }
printf "\x55\xaa\x00\x00" > /tmp/header.mmv
ffmpeg -ac 1 -ar 11025 -f s16le -acodec pcm_s16le -loglevel quiet -y -i $1 /tmp/data.mmv
cat /tmp/header.mmv /tmp/data.mmv > $1.mmv
#!/usr/bin/env python3
import ephem
from math import degrees
from datetime import datetime
class Observer(ephem.Observer):
def __init__(self, name, lat, lon, elevation):
super().__init__()
self.name, self.lat, self.lon, self.elevation = (
ffmpeg -f image2 -r 24 -start_number XXXX -i G%07d.JPG -r 15 -s hd720 -vcodec libx264 OUTFILE