Skip to content

Instantly share code, notes, and snippets.

View sambatyon's full-sized avatar

Alexander Rojas sambatyon

View GitHub Profile
@sambatyon
sambatyon / reload-audio
Created March 28, 2019 12:26
Reload audio
#!/usr/bin/env bash
sudo killall pulseaudio; rm -r ~/.config/pulse/* ; rm -r ~/.pulse*
sudo alsa force-reload
@sambatyon
sambatyon / panic-theme.el
Created January 10, 2019 15:33
A theme inspired by panic's Coda 2.5
;;; panic-theme.el --- A theme inspired by panic's Coda 2.5
;; Copyright (C) 2017
;; Author: Alexander Rojas
;; URL: http://github.com/sambatyon/panic-emacs
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
@sambatyon
sambatyon / future_tests.cpp
Last active January 16, 2017 19:55
Extra test that would have failed with my original version of the patch.
TEST(FutureTest, After4)
{
Future<Nothing> witness;
Clock::pause();
Future<Nothing>()
.then([](const Nothing&) { witness = Nothing(); })
.after(Milliseconds(1), [](const Future<Nothing> f) { f = Nothing(); });
@sambatyon
sambatyon / gist:3bbd8d5f81b65398c0d0
Last active March 19, 2018 01:44 — forked from wacko/gist:5577187
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

@sambatyon
sambatyon / actor-skeleton.cc
Last active May 24, 2021 17:23
A simple example of how to write actors in C++ with Asio
#include <boost/noncopyable.hpp>
#include <boost/thread/thread.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
// The following macros are vs only
//#pragma push_macro("UNICODE")
//#pragma push_macro("_UNICODE")
#undef UNICODE
@sambatyon
sambatyon / xvfb
Created June 3, 2014 16:41 — forked from jterrace/xvfb
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
@sambatyon
sambatyon / extractheaders.sh
Created May 30, 2014 07:26
Extract Headers from folder keeping structure
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: extractheaders src dest"
exit
fi
orig_dir=`pwd`
origin=$1
@sambatyon
sambatyon / .bashrc
Last active August 29, 2015 13:57
msys configuration files with git support
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \$ '
#\[\033]0;$MSYSTEM:\w\007 \033[32m\]\u@\h \[\033m\w$(__git_ps1)\033[0m\] $
# If not running interactively don't do anything
case $- in
*i*) ;;
*) return;;
esac
@sambatyon
sambatyon / redistribute.js
Last active August 29, 2015 13:56
Translates a list of numbers assumed to be distributed normally to another normal distribution with the required mean and standard deviation.
function redistribute(numbers, new_mean, new_std_deviation) {
// compute the mean of the list of numbers
// μ = (Σ x_i) / n
var sum = 0;
numbers.forEach(function (i) {sum += i});
var mean = sum / numbers.length;
// compute the std deviation of the numbers:
// σ = √(Σ (x_i - μ)² / n)
sum = 0;
@sambatyon
sambatyon / gist:9134348
Created February 21, 2014 13:37
Extracts headers from a source tree.
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: extractheaders src dest"
exit