Skip to content

Instantly share code, notes, and snippets.

View nknapp's full-sized avatar

Nils Knappmeier nknapp

View GitHub Profile
@nknapp
nknapp / detect.sh
Created October 8, 2023 13:03
Detect bluriness in frames extracts from video and copy the best 10 to another directory
# Extract frames
ffmpeg -i filename.mov -ss 30 -to 65 -vsync 0 -q:v 2 out%03d.jpg
for i in out*.jpg ; do
echo $i $( convert $i -colorspace gray -statistic StandardDeviation 5X5 - | identify -verbose - | grep deviation ) ;
done | tee deviation.txt
mkdir good
cat deviation.txt | sort -n -t ":" -k 2 | tail -20 | cut -b -10 | xargs cp -t good
@nknapp
nknapp / fraktal-turtle.py
Created April 1, 2022 15:29
fraktal-turtle
import turtle
import time
my_window = turtle.Screen()
# my_window.screensize(1000,1000)
my_window.bgcolor("white") # creates a graphics window
# my_window.setworldcoordinates(0,0, 1000,1000)
my_window.delay(0)
my_window.tracer(100,200)
my_pen = turtle.Turtle()
@nknapp
nknapp / tic-tac-toe.html
Created November 8, 2018 15:59
Tic Tac Toe
<html>
<head>
<style>
h1 {
position: absolute;
display: block;
top: 50%;
left: 50%;
transform: rotate(30deg);
@nknapp
nknapp / performance-test.js
Last active October 5, 2018 21:05
Should we really use anonymous functions as callback
function measure (description, fn) {
console.log('Running ' + description);
let start = Date.now();
fn(100000000);
console.log(`Took ${Date.now() - start}ms\n`);
}
/**
* The scenario is: We want to call a lot of callbacks.
* Which is faster: The usual anonymous callback.
@nknapp
nknapp / logger-spec.ts
Last active June 4, 2018 19:53
A logger that I didn't want to throw away, but I'm currently not needing it.
import { expect } from "chai";
import { Writable } from "stream";
import { logLevel, LogManager, toStream } from "../../src/utils/logger";
describe("The logger", () => {
describe("The 'for'-function", function() {
const logEntries: any[] = [];
const log = new LogManager();
let stream: Writable;
# Some more dependencies
git clone git@github.com:bootprint/customize.git
git clone git@github.com:bootprint/customize-engine-handlebars.git
git clone git@github.com:bootprint/customize-engine-less.git
git clone git@github.com:bootprint/customize-write-files.git
git clone git@github.com:bootprint/bootprint.git
# Clone the repos
git clone git@github.com:bootprint/bootprint-openapi.git
git clone git@github.com:bootprint/bootprint-json-schema.git
@nknapp
nknapp / _watch-cpu-freq.md
Last active February 25, 2020 14:51
Set powersave/performance governor based on ac/battery status

This setup switches to "powersave" if the battery is lower than 75% and to "performance" if it is above and charging.

Copy the files to

  • /etc/systemd/system/watch-power-cpufreq.service
  • /usr/local/bin/watch-power-cpufreq.sh

and then run

@nknapp
nknapp / phashBuffer.js
Last active March 20, 2018 23:02
searching phashs
// Precompute the number of matching bits by the xor-result of two bytes
const matchingBitsFromXor = []
for (let i = 0; i < 256; i++) {
matchingBitsFromXor[i] = countMatchingBits(i)
}
class PhashBuffer {
constructor (bytesPerHash, maxSize) {
this.buffer = Buffer.alloc(bytesPerHash * maxSize)
@nknapp
nknapp / keybase.md
Created May 24, 2017 21:19
keybase.md

Keybase proof

I hereby claim:

  • I am nknapp on github.
  • I am nknapp (https://keybase.io/nknapp) on keybase.
  • I have a public key ASBc1DN469TlP5kG_R1r8OKyyQxfxvztA9b1dkpyd8zywQo

To claim this, I am signing this object:

First Header Second Header
Content from cell 1 Content from cell 2
Content in the first column Content in the `find *