Skip to content

Instantly share code, notes, and snippets.

Loic Nageleisen lloeki

Block or report user

Report or block lloeki

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lloeki
lloeki / git_merge_repos.sh
Last active May 27, 2018
Merge repos and keep whole history by creating a single multi-parent merge commit
View git_merge_repos.sh
#!/bin/bash
set -e
set -u
set -o pipefail
prefix="git@gitlab.somewhere.com:mygroup"
target="$1"
shift
@lloeki
lloeki / arch-xhyve.sh
Created Aug 27, 2015
Run Arch Linux in xhyve
View arch-xhyve.sh
#!/bin/bash
tmp=$(mktemp -d)
pushd "$tmp"
iso=/Users/lloeki/Downloads/archlinux-2015.08.01-dual.iso
echo "fixing disk"
dd if=/dev/zero bs=2k count=1 of=tmp.iso
dd if=$iso bs=2k skip=1 >> tmp.iso
echo "mounting disk"
@lloeki
lloeki / debian-xhyve.sh
Created Aug 27, 2015
Running debian 8.1 in xhyve
View debian-xhyve.sh
#!/bin/bash
# unfortunately debian currently panics in xhyve
tmp=$(mktemp -d)
pushd "$tmp"
iso="$HOME"/Downloads/debian-8.1.0-amd64-netinst.iso
#iso="$HOME"/Downloads/debian-8.1.0-i386-netinst.iso
echo "fixing disk"
dd if=/dev/zero bs=2k count=1 of=tmp.iso
@lloeki
lloeki / clean_up_boot.sh
Last active May 14, 2018
Clean up /boot of unused Ubuntu (and Debian?) kernels
View clean_up_boot.sh
# Ubuntu has a stupid policy of not cleaning up boots because they deem
# unknowable whether a kernel is valid or not (even if booted). Combined with
# the default Ubuntu setup that creates a ridiculously small /boot that is
# bound to be filled in a few months worth of updates, you have a recipe for a
# failure during upgrade, leading to being unable to update or remove anything
# and having to mess with apt and dpkg innards by hand.
# This may work for Debian too.
# This one liner keeps /boot fresh and clean by removing the currently
# running kernel version as well as the latest one (which may not be
@lloeki
lloeki / main.go
Created May 1, 2015
Using GopherJS and Electron together
View main.go
// Electron's quick start sample, naively ported to Go
// https://github.com/atom/electron/blob/master/docs/tutorial/quick-start.md
//
// go get -u gopherjs
// gopherjs build main.go
// electron $(pwd)
package main
import (
@lloeki
lloeki / gist:62239da19ec25f90f215
Created Dec 16, 2014
open-vm-tools with clipboard and drag and drop on Ubuntu 14.04 Trusty Tahr
View gist:62239da19ec25f90f215
# You should be using open-vm-tools instead of vmware tools, because package manager.
# Also I hate third parties that write out of /opt and /usr/local.
# open-vm-tools-desktop is badly packaged though, here are the missing links:
sudo apt-get install open-vm-tools open-vm-tools-desktop
# Reboot, and resize works, but no DnD nor clipboard
sudo mkdir /var/run/vmblock-fuse
sudo su -l -c "vmware-vmblock-fuse -o subtype=vmware-vmblock,default_permissions,allow_other /var/run/vmblock-fuse"
# Now we have /run/vmblock-fuse populated.
# Adding an upstart rule in /etc/init is left as an exercise to the reader.
@lloeki
lloeki / brutalize_openssl.rb
Created Dec 2, 2014
Violently disable OpenSSL cert validation (dangerous!)
View brutalize_openssl.rb
require 'openssl'
class OpenSSL::SSL::SSLContext
def verify_mode
OpenSSL::SSL::VERIFY_NONE
end
def verify_mode=(_)
@verify_mode = OpenSSL::SSL::VERIFY_NONE
end
@lloeki
lloeki / class_diagram.rake
Last active Aug 29, 2015
Rails class diagram (e.g models) with graphviz
View class_diagram.rake
# (c) Loic Nageleisen
# License: MIT
Node = Struct.new(:type, :name, :attributes)
Edge = Struct.new(:type, :from, :to, :name)
class DiagramGraph
def initialize
@nodes = []
@edges = []
@lloeki
lloeki / monad_id.rb
Created Sep 1, 2014
Identity monad in Ruby
View monad_id.rb
# http://moonbase.rydia.net/mental/writings/programming/monads-in-ruby/01identity
# Identity monad
class Identity
def initialize(value)
@value = value
end
# unit operation: Haskell 'return'
def self.munit(value)
View lua.go
package main
/*
#cgo LDFLAGS: -lluajit-5.1
#include <stdlib.h>
#include <stdio.h>
#include <luajit-2.0/lua.h>
#include <luajit-2.0/lualib.h>
#include <luajit-2.0/lauxlib.h>
You can’t perform that action at this time.