Skip to content

Instantly share code, notes, and snippets.

View Leedehai's full-sized avatar
:octocat:
Undefined behavior

Leedehai

:octocat:
Undefined behavior
View GitHub Profile
@Leedehai
Leedehai / vm.sh
Last active July 13, 2019 05:30
Control VirtualBox from terminal command line: VirtualBox CLI shortcuts script (set alias vm='vm.sh')
#!/usr/bin/env sh
DEFAULT_VM=your_default_vm_name # fill it yourself
SSH_USERNAME=your_username_to_ssh # fill it yourself
VM_PROPERTY_IP=/VirtualBox/GuestInfo/Net/1/V4/IP
VM_PROPERTY_OS=/VirtualBox/GuestInfo/OS/Product
function print_usage() {
echo " vm -h|--help -- display this help message"
echo " vm on|off [VM] -- turn on/off VM"
echo " vm ssh [VM] -- ssh to VM"
@genedwards
genedwards / pre-commit
Last active September 20, 2021 14:04
Git pre-commit hook to prevent fdescribe et al.
#!/bin/sh
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
# uncomment next line for debugging, will print all expanded bash commands
#set -x
# Yes, if you put "fdescribe" in a comment block, this will still abort the
@madhums
madhums / base64-image-upload.js
Created September 14, 2014 17:37
save base64 encoded image
/*
* Taken from http://stackoverflow.com/questions/5867534/how-to-save-canvas-data-to-file/5971674#5971674
*/
var fs = require('fs');
// string generated by canvas.toDataURL()
var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0"
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO"
+ "3gAAAABJRU5ErkJggg==";
// strip off the data: url prefix to get just the base64-encoded bytes
@emiller
emiller / git-mv-with-history
Last active April 17, 2024 21:06
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@tuzz
tuzz / github.css
Last active May 20, 2024 11:57
Github Markdown Stylesheet
/*
Copyright (c) 2017 Chris Patuzzo
https://twitter.com/chrispatuzzo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@landonf
landonf / stackoverflow.m
Created June 17, 2011 22:51
Explanation of why backtrace(3) and stack overflow don't mix.
#import <Foundation/Foundation.h>
#import <pthread.h>
#import <execinfo.h>
#import <string.h>
#import <stdint.h>
/*
* A signal handler that is broken in two ways:
* 1) The handler calls APIs that are not declared to be async-safe and may deadlock or otherwise fail.
@marcetcheverry
marcetcheverry / mapread.c
Created May 25, 2011 14:05
mmap and read/write string to file
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
int main(int argc, const char *argv[])
{
@ishikawa
ishikawa / dominance_frontiers.rb
Created February 18, 2011 07:19
A Simple, Fast Dominance Algorithm
# Cooper, Keith D.; Harvey, Timothy J.; and Kennedy, Ken (2001). A Simple, Fast Dominance Algorithm
# http://www.cs.rice.edu/~keith/EMBED/dom.pdf
#
# Computing minimal SSA using dominance frontiers
# http://en.wikipedia.org/wiki/Static_single_assignment_form#Computing_minimal_SSA_using_dominance_frontiers
#
# Dominator (graph theory)
# http://en.wikipedia.org/wiki/Dominator_(graph_theory)
#
require 'set'