Skip to content

Instantly share code, notes, and snippets.

View cfstras's full-sized avatar

Claus F. Strasburger cfstras

  • Düsseldorf, Germany
  • 14:26 (UTC +02:00)
View GitHub Profile
@cfstras
cfstras / background
Last active October 3, 2015 01:08
Background-changer script for GNOME 3
#!/bin/bash
# background-changer
# 2012-04-06
# use to switch gnome background to a random one
# uses every file in bg_path and follows the first symlinks in that directory
# outputs the selected file
# author: cfstras <c@cfs.im>
# license: beerware
#
# use for example in a crontab:
@cfstras
cfstras / tcp-chat.js
Last active December 18, 2015 01:39
Chatserver
// Bib's
var net = require('net');
// Fettes Array
var clients = [];
// create teh server!
var srv = net.createServer();
// connection handler, das Argument ist ein Socket mit der neuen Verbindung
@cfstras
cfstras / sekanten.coffee
Created January 22, 2014 13:22
Demonstration of the Secant method (Sekantenmethode) with an initial Newton step.
# functions
f = (x) ->
2 - x*x - Math.exp(x)
fd = (x) ->
-2*x - Math.exp(x)
newt = (x) ->
x - f x / fd x
@cfstras
cfstras / toLower.bat
Last active January 4, 2016 19:19
The reason why nobody should use batch files. Found in an old batch file.
:toLower str -- converts uppercase character to lowercase
:: -- str [in,out] - valref of string variable to be converted
if not defined %~1 EXIT /b
for %%a in ("A=a" "B=b" "C=c" "D=d" "E=e" "F=f" "G=g" "H=h" "I=i"
"J=j" "K=k" "L=l" "M=m" "N=n" "O=o" "P=p" "Q=q" "R=r"
"S=s" "T=t" "U=u" "V=v" "W=w" "X=x" "Y=y" "Z=z" "Ä=ä"
"Ö=ö" "Ü=ü") do (
call set %~1=%%%~1:%%~a%%
:: it's nice how this line manages to represent the horrors of syntax in under 30 characters.
)
@cfstras
cfstras / Makefile
Last active August 29, 2015 13:55
Hash Join with linear probing -- For details, go to http://codematch.muehe.org/challenges/29 -- For big.txt, go to http://www-db.in.tum.de/~muehe/exampleinput.txt
CXX := clang++
CXXFLAGS := -std=c++0x -xc++ -march=native -O3 -Wall -g
DPROFILE := -DPROFILE
CXXVERBOSE := -ftree-vectorizer-verbose=0
LIBS := -lprofiler
TIME := time
export CPUPROFILE=join.prof
export CPUPROFILE_FREQUENCY=10000000000
export CPUPROFILE_REALTIME=0
@cfstras
cfstras / 0 YtLight.md
Last active January 30, 2024 17:27
Lightweight YouTube Oneboxer for Discourse.

Note (2024): This was relevant in 2014, when the YouTube OneBoxer integrated with Discourse was not exactly behaving how I liked it, so I made this one.
It probably doesn't work anymore.

YtLight

Replace those nasty YouTube iframes with static images for ultimate loading time in threads with lots of videos

When clicked, they get replaced by the actual iframe.

@cfstras
cfstras / status.html
Last active February 6, 2023 03:24
Simple Minecraft Server status box using http://api.syfaro.net/
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<script>
var rq = '//api.syfaro.net/server/status';
var error = 'unknown';
var classes = {
error: "fa-question",
false: "fa-times",
true: "fa-check",
};
@cfstras
cfstras / gist:be3cfa95b2e2637577a4
Last active August 29, 2015 14:00
git tips for big repos on windows

Git tips for big repositories on Windows

Performance

core.fscache

core.fscache = true

to enable uber-speed git status.

pack.*

@cfstras
cfstras / panic-recover.go
Created September 12, 2014 09:45
Panic & Recover for long fail-fast methods
package main
import (
"errors"
"fmt"
"math/rand"
"runtime"
"time"
)
@cfstras
cfstras / 0 Ultimate Go build tool.md
Last active January 30, 2024 14:44
Ultimate Golang Build Tool, v2

Note (2024): This was written before Go had modules and workspaces, and even before tools like go dep and go vendor were mainstream. Nowadays, I don't think there's a good reason to use this, but it's still interesting to read for history purposes (IMO).


Intro

I like Go, especially the build system. But what I don't like is the build system: