Skip to content

Instantly share code, notes, and snippets.

View invad0r's full-sized avatar
🌐

daniel invad0r

🌐
  • Hamburg
View GitHub Profile
@gdamjan
gdamjan / namespaces.c
Created March 7, 2011 12:40
a small C program to start a process in a Linux namespace
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@hmic
hmic / hash.h
Created January 25, 2012 14:03
php hash function "from the source"
/*
* DJBX33A (Daniel J. Bernstein, Times 33 with Addition)
*
* This is Daniel J. Bernstein's popular `times 33' hash function as
* posted by him years ago on comp.lang.c. It basically uses a function
* like ``hash(i) = hash(i-1) * 33 + str[i]''. This is one of the best
* known hash functions for strings. Because it is both computed very
* fast and distributes very well.
*
* The magic of number 33, i.e. why it works better than many other
@prashants
prashants / lwnfs.c
Created August 28, 2012 10:07
Updated lwnfs
/*
* Demonstrate a trivial filesystem using libfs.
*
* Copyright 2002, 2003 Jonathan Corbet <corbet@lwn.net>
* This file may be redistributed under the terms of the GNU GPL.
*
* Chances are that this code will crash your system, delete your
* nethack high scores, and set your disk drives on fire. You have
* been warned.
*/
@kgriffs
kgriffs / vlc
Last active February 23, 2024 17:57
Run VLC from the command line on Mac OS X and stream internet radio (such as Radio Paradise).
#!/usr/bin/env bash
/Applications/VLC.app/Contents/MacOS/VLC -I rc "$@"
@otobrglez
otobrglez / yaml_to_json.sh
Created June 3, 2016 13:37
YAML to JSON - one-liner with Ruby
# Single line of Ruby <3.
ruby -rjson -ryaml -e "puts YAML.load_file('my_file.yml').to_json"
# You can also pipe it to Python to get pretty ouput
ruby -rjson -ryaml -e "puts YAML.load_file('my_file.yml').to_json" | \
python -mjson.tool
# Thats all. :)
@ursuad
ursuad / kafka-cheat-sheet.md
Last active June 25, 2024 13:23
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@timtadh
timtadh / queue.sh
Last active March 12, 2023 07:44
BASH Job Queue. This is a example of how to make a job queue in GNU Bash. It may not work for other shells as it relies on the bash built in `read`. You will need to see the man pages for your shell to determine if this will work for you.
#!/usr/bin/env bash
rep() {
i=$1
data=$2
## run the replicate ....
}
# make the files
START=$(mktemp -t start-XXXX) ## signals the workers are starting
@cherti
cherti / alert.sh
Created December 9, 2016 13:47
send a dummy alert to prometheus-alertmanager
#!/bin/bash
name=$RANDOM
url='http://localhost:9093/api/v1/alerts'
echo "firing up alert $name"
# change url o
curl -XPOST $url -d "[{
\"status\": \"firing\",
@jkullick
jkullick / build-docker-image-without-dockerfile.md
Created December 22, 2016 08:35
Build Docker Image without Dockerfile
docker build -t $IMAGE_NAME - << EOF
FROM alpine:latest
...
EXPOSE 80
EOF
@cjbarker
cjbarker / Makefile
Created June 21, 2017 22:10
Makefile for cross-compiling Golang. Just update BINARY var in Makefile and create empty vars in main.go for Version and Build
# ########################################################## #
# Makefile for Golang Project
# Includes cross-compiling, installation, cleanup
# ########################################################## #
# Check for required command tools to build or stop immediately
EXECUTABLES = git go find pwd
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH)))