Skip to content

Instantly share code, notes, and snippets.

View nicolai86's full-sized avatar
🏠
Working from home

Raphael Randschau nicolai86

🏠
Working from home
View GitHub Profile
@marcan
marcan / linux.sh
Last active July 21, 2024 14:00
Linux kernel initialization, translated to bash
#!/boot/bzImage
# Linux kernel userspace initialization code, translated to bash
# (Minus floppy disk handling, because seriously, it's 2017.)
# Not 100% accurate, but gives you a good idea of how kernel init works
# GPLv2, Copyright 2017 Hector Martin <marcan@marcan.st>
# Based on Linux 4.10-rc2.
# Note: pretend chroot is a builtin and affects the current process
# Note: kernel actually uses major/minor device numbers instead of device name
From f5908efac9f55216d5aabdee72687b2b47f1c89c Mon Sep 17 00:00:00 2001
From: Chang Liu <cliu712@aucklanduni.ac.nz>
Date: Mon, 13 Apr 2015 09:36:31 +0000
Subject: [PATCH] Add support for linux-musl in build system. Fix glibc
assumptions in code.
---
autoconf/config.sub | 7 +++++--
lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp | 2 +-
lib/Support/DynamicLibrary.cpp | 4 ++--
@dideler
dideler / upgrade-postgres-9.3-to-9.4.md
Last active June 8, 2020 03:24
Upgrading PostgreSQL from 9.3 to 9.4 when upgrading Ubuntu 14.04 to 14.10

TL;DR

Create a backup:

pg_dumpall > mybackup.sql

Perform the upgrade:

sudo pg_dropcluster 9.4 main --stop
@mattetti
mattetti / rails_json_session.rb
Last active September 23, 2020 07:04
This is a monkey patch to change Rails 4's default session/signed cookie serializer from Marshal to JSON for security and compatibility reasons. Note that this is a hack, a pretty terrible one and you should only use it if you know what you're doing. Also, I only wrote this patch for my own personal use, so don't be surprised if it doesn't work …
# Hack to change the Rails cookie serializer from Marshal to JSON and therefore allow the session
# to be shared between different languages but also avoid that someone knowing the
# cookie secret key could execute arbitrary code on the server by unmarshalling
# modified Ruby code added to the session/permanent cookie.
#
# Note that all users will beed to login again since both the remember me cookie and the session cookies
# won't be valid. Note also that the remember me cookie is tested multiple times per request even when it fails.
# for performance reasons you might want to delete it if these extra cycles are too costly for you.
#
# Rails 4 (not tested on Rails 3).
@jeffbyrnes
jeffbyrnes / config.rb
Created May 9, 2013 01:31
Capistrano recipe for Hubot deployments + Forever
# Lifted from this blog article & modified heavily:
# http://blog.nicolai86.eu/posts/2011-11-03/deploying-hubot-with-capistrano
set :application, "hubot"
set :repository, "repository"
set :scm, :git
set :ssh_options, { :forward_agent => true }
set :branch, "master"
@Protonk
Protonk / prng.js
Last active April 7, 2023 09:30
Various PRNGs, implemented in javascript.
// Linear Congruential Generator
// Variant of a Lehman Generator
var lcg = (function() {
// Set to values from http://en.wikipedia.org/wiki/Numerical_Recipes
// m is basically chosen to be large (as it is the max period)
// and for its relationships to a and c
var m = 4294967296,
// a - 1 should be divisible by m's prime factors
a = 1664525,
// c and m should be co-prime
@sentientmonkey
sentientmonkey / test-logging.rb
Last active December 15, 2015 04:09
hourly log rotation in ruby logger via rotatelogs
#!/usr/bin/env ruby
require 'logger'
# rotatelogs required...
# http://httpd.apache.org/docs/2.2/programs/rotatelogs.html
logger = Logger.new("|rotatelogs ./foo.log.%Y-%m-%d-%H 3600", 0, 0)
10.times do
logger.error "testing..."
@jspahrsummers
jspahrsummers / macroview.sh
Last active December 10, 2015 07:38
This simple script will preprocess one or more source files, and try to indent them nicely such that expanded macros are made readable. This is useful for debugging the logic of rampant macros.
#!/bin/sh
#
# Example usage:
# ./macroview.sh -IThirdPartyHeadersToInclude file.m
clang -E -nostdinc -nobuiltininc "$@" 2>/dev/null | indent -bl -nce -nei
@hannestyden
hannestyden / gist:3897757
Created October 16, 2012 07:24
OS X 10.8 Mountain Lion: Remove Notification Center and Spotlight from menu bar.
# [Notification Center](http://osxdaily.com/2012/08/06/disable-notification-center-remove-menu-bar-icon-os-x/)
## Disable
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
killall NotificationCenter # optional?
## Enable
launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
# Spotlight
@rcrowley
rcrowley / go-deb.sh
Last active October 10, 2015 17:48
Go binary distribution Debian packaging
VERSION="1.4.2"
BUILD="slack1"
set -e -x
cd "$(mktemp -d)"
trap "rm -rf \"$PWD\"" EXIT INT QUIT TERM
curl -O "https://storage.googleapis.com/golang/go$VERSION.linux-amd64.tar.gz"
tar xf "go$VERSION.linux-amd64.tar.gz"