Skip to content

Instantly share code, notes, and snippets.

View nevkontakte's full-sized avatar
👽
Pretending to be smart

Nevkontakte nevkontakte

👽
Pretending to be smart
View GitHub Profile
@nevkontakte
nevkontakte / ubuntu-cloud-bootable.sh
Created June 26, 2013 10:03
Make Ubuntu Cloud images bootable in virtualbox. Pre-requirements: qemu-img (package qemu-utils in Ubuntu repo), extlinux Tested under Ubuntu 13.04, might work on other linux distros. Get ubuntu image: http://cloud-images.ubuntu.com/precise/current/*.img
#!/bin/bash
##
## Usage: sudo ubuntu-cloud-bootable.sh precise-server-cloudimg-amd64-disk1.img
##
set -e
mount_point="$(mktemp -d)"
raw="$(mktemp)"
echo ">>> Converting to raw: $raw ..."
@nevkontakte
nevkontakte / binary.cc
Created December 9, 2012 13:56
Function to generate binary representation of arbitrary numeric type. Fast. Not thread-safe.
#include <iostream>
template<typename T> char* binary(T n) {
const int bits = sizeof(T)*8;
static char str[bits+1];
str[bits] = 0;
for(int i = 0; i < bits; i++) {
str[bits-i-1] = '0' + (n & 1);
n = n >> 1;
}