Skip to content

Instantly share code, notes, and snippets.

@ROFISH
ROFISH / Gemfile
Last active August 29, 2015 14:00
#ruby '2.1.0'
source 'https://rubygems.org'
gem 'rack', '~>1.5.2'
gem 'actionpack', '~> 4.1.0.beta1'
gem 'railties', '~> 4.1.0.beta1'
@tommybotten
tommybotten / interfaces.rb
Created August 23, 2012 13:31
Example to replace string search in facter in favor of system calls
#!/usr/bin/ruby
require 'socket'
# From bits/ioctls.h
SIOCGIFNETMASK = 0x891b # Netmask address
SIOCGIFHWADDR = 0x8927 # hardware address
SIOCGIFADDR = 0x8915 # PA address
SIOCGIFCONF = 0x8912 # iface list
@juanje
juanje / Rakefile
Created April 12, 2012 07:46
Example of Rake tasks for dealing with Vagrant
load 'rake/helper.rb'
desc "Set up the VM"
task :up do
vm = VM.new
vm.cli('up')
end
desc "Shutdown the VM"
task :graceful_down do
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@franciscocpg
franciscocpg / install.sh
Last active April 9, 2018 17:38
docker completion for CoreOS
# Run this as CoreOS user at home folder
set -e
toolbox dnf -y install bash-completion wget \
&& toolbox wget https://raw.githubusercontent.com/docker/docker/master/contrib/completion/bash/docker -O /usr/share/bash-completion/completions/docker \
&& toolbox cp /usr/share/bash-completion /media/root/var/ -R \
&& source /var/bash-completion/bash_completion
cp $(readlink .bashrc) .bashrc.new && mv .bashrc.new .bashrc
echo "source /var/bash-completion/bash_completion" >> ~/.bashrc
@choplin
choplin / process_pool.rb
Created August 21, 2012 15:14
Process Pool in Ruby
require 'msgpack'
require 'thread'
class ProcessPool
def initialize(num_process, args={})
queue_size, worker_class = parse_args([
:queue_size, nil,
:worker_class, Worker,
], args)
def execute(cmd, flag_file=None, msg_id='', debug=False):
"""
# http://stackoverflow.com/questions/1606795/catching-stdout-in-realtime-from-subprocess
:param cmd: should never inlcude pipe or redirection, which would requires
a new shell process
This execute logs all stdout and stderr, which could look funny, especially
when it comes to tools like aspc and wget
"""
logger.info('executing: {0}'.format(cmd))
# todo: should check whether cmdsp includes pipe or redirection here
#!/bin/bash
##################################################################################
# 1 - Create the base container
SUITE=squeeze
RELEASE=$SUITE
sudo lxc-create -n ${RELEASE}-base -t debian
rootfs="/var/lib/lxc/${RELEASE}-base/rootfs"
@jasoncodes
jasoncodes / gist:1223731
Created September 17, 2011 07:45
Installing Ruby 1.9.3 with rbenv on OS X
# The latest version of this script is now available at
# https://github.com/jasoncodes/dotfiles/blob/master/aliases/rbenv.sh
VERSION=1.9.3-p286
brew update
brew install rbenv ruby-build rbenv-vars readline ctags
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
@asmeurer
asmeurer / What happens when you mess with hashing.ipynb
Last active May 20, 2020 06:17
What happens when you mess with hashing in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.