Skip to content

Instantly share code, notes, and snippets.

View Klowner's full-sized avatar
🤡
total bozo

Mark Riedesel Klowner

🤡
total bozo
View GitHub Profile
@noidexe
noidexe / RoundRobinPlayer.gd
Created September 9, 2019 07:00
RoundRobinPlayer node for Godot Engine with sequence, random, and shuffle modes extending AudioStreamPlayer
tool
extends AudioStreamPlayer #exactly the same code should work for extending 2D and 3D versions
class_name RoundRobinPlayer
export(int, "sequence", "random", "shuffle") var queue_mode = 0
export(Array, AudioStream) var playlist = [] setget _set_playlist, _get_playlist
export(bool) var round_robin_playing = false setget _set_playing, _is_playing # can't override properties so use this for animations
var playlist_index = -1 # current position in the playlist
var shuffled_indices = [] # Array<int> of shuffled playlist indices
@bkaradzic
bkaradzic / notes_on_header_files.md
Last active December 8, 2023 03:24
Notes on header files

Notes on header files

After over 20 years working with C/C++ I finally got clear idea how header files need to be organized. Most of the projects in C++ world simply dump everything in .h file, and most of my C++ code was organized this way. Lately I started to separate function declaration from implementation as it was done in C. Now .h headers are exclusevely intended for function and class declaration with doxygen documentation style comments. Inline implementation of functions, class method implementation, etc. goes into .inl headers or .cpp files.

For example .h file would contain only declaration and doxygen style documentation comment:

	/// Convert size in bytes to human readable string.
	void prettify(char* _out, int32_t _max, uint64_t _value)
@dearing
dearing / docker-nftables.conf
Created February 25, 2016 14:26
nftables with docker
# /etc/systemd/system/docker.service.d/docker-nftables.conf
# disable iptables in docker, allowing nftables to do work
[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -H fd:// --iptables=false
@mendelgusmao
mendelgusmao / btsync
Last active March 4, 2021 15:37
init.d script for btsync (based on another script built to run dropbox)
#!/bin/sh
### BEGIN INIT INFO
# Provides: btsync
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of btsync.
@scythe
scythe / bezier.lua
Created June 27, 2011 16:02
de Casteljau's algorithm in lua metatables
--[[a parametric function describing the Bezier curve determined by given control points,
which takes t from 0 to 1 and returns the x, y of the corresponding point on the Bezier curve]]
function bezier(xv, yv)
local reductor = {__index = function(self, ind)
return setmetatable({tree = self, level = ind}, {__index = function(curves, ind)
return function(t)
local x1, y1 = curves.tree[curves.level-1][ind](t)
local x2, y2 = curves.tree[curves.level-1][ind+1](t)
return x1 + (x2 - x1) * t, y1 + (y2 - y1) * t
end
# Graham Scan - Tom Switzer <thomas.switzer@gmail.com>
TURN_LEFT, TURN_RIGHT, TURN_NONE = (1, -1, 0)
def turn(p, q, r):
return cmp((q[0] - p[0])*(r[1] - p[1]) - (r[0] - p[0])*(q[1] - p[1]), 0)
def _keep_left(hull, r):
while len(hull) > 1 and turn(hull[-2], hull[-1], r) != TURN_LEFT:
hull.pop()