Skip to content

Instantly share code, notes, and snippets.

View pablete's full-sized avatar

Pablo A. Delgado pablete

View GitHub Profile
describe 'Board', ->
describe '#mark', ->
it 'contains empty cells', ->
@board = new Board()
expect(@board.cells).toEqual(['', '', '', '', '', '', '', '', ''])
it 'contains a marked cell', ->
@board = new Board()
@board.mark(1, @board.HUMAN)
expect(@board.cells).toEqual(['', 'X', '', '', '', '', '', '', ''])
@pablete
pablete / gist:5834106
Created June 21, 2013 20:31
Add VirtualBox Guest Additions for Cloudera VM image.
cd /tmp
wget ftp://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/6.1/x86_64/updates/security/kernel-devel-2.6.32-220.23.1.el6.x86_64.rpm
rpm -ivh kernel-devel-2.6.32-220.23.1.el6.x86_64.rpm
KERN_DIR=/usr/src/kernels/2.6.32-220.23.1.el6.x86_64
cd /media/VBOXADDITIONS_4.2.12_84980
./VBoxLinuxAdditions.run
@pablete
pablete / .bash_profile
Last active March 28, 2022 14:03 — forked from porras/.bash_profile
Change iTerm2 profile (ie: background color) when SSHing into another machine
# Changing iTerm2 color in MacOSX when SSHing (so you know at a glance that you're no longer in Kansas)
# Adapted from https://gist.github.com/porras/5856906
# 1. Create a theme in your terminal setting with the name "SSH" and the desired colors, background, etc.
# 2. Add this to your .bash_profile (or .bashrc, I always forget the difference ;))
# 3. Optional but useful: in the terminal, go to Settings > Startup and set "New tabs open with" to
# "default settings" (otherwise, if you open a new tab from the changed one, you get a local tab with
# the SSH colors)
function tabc() {
NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi # if you have trouble with this, change
#/bin/bash
set -e
echo "=== Activating Firewall (only SSH allowed) ==="
ufw allow ssh
ufw --force enable
if [ ! -f /swapfile ]; then
echo "=== Activating swap ==="
fallocate -l 1G /swapfile
@pablete
pablete / gist:8326305
Last active January 2, 2016 15:49 — forked from zbal/gist:7800423
# Based on https://gist.github.com/fernandoaleman/5083680
# Guest Additions Version: 4.3.6
# VirtualBox Version: 4.3.6
$ vagrant ssh
vagrantup:~$ sudo apt-get install linux-headers-$(uname -r) build-essential
vagrantup:~$ sudo wget -c http://download.virtualbox.org/virtualbox/4.3.6/VBoxGuestAdditions_4.3.6.iso \
-O VBoxGuestAdditions_4.3.6.iso
vagrantup:~$ sudo mount VBoxGuestAdditions_4.3.6.iso -o loop /mnt
# sc is an existing SparkContext.
from pyspark.sql import SQLContext, Row
sqlContext = SQLContext(sc)
# Load a text file and convert each line to a dictionary.
lines = sc.textFile("examples/src/main/resources/people.txt")
parts = lines.map(lambda l: l.split(","))
people = parts.map(lambda p: Row(name=p[0], age=int(p[1])))
#if using CSV instead FROM https://docs.python.org/2/library/csv.html
  1. General Background and Overview
@pablete
pablete / simulate_payloads.rb
Created February 6, 2015 18:12
Little script to simulate A/B test payloads
experiments = [1]
# 0 control
# 1 experiment
probabilities = {1 => [0.01, 0.011]}
$goal_reservation={1 => [0,0]}
$belong_to_branch={1 => [0,0]}
def abFunction(conversions, sampleSize)
p = conversions/sampleSize.to_f
/**
The MIT License (MIT)
Copyright (c) 2013 Jean Helou
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
#!/bin/sh
if [ -z "$1" ]; then
echo "Need to provide an image name. Use this script as ./build.sh imagename"
exit 1
fi
set -o nounset -o errexit
TIMESTAMP=$(date +"%Y%m%d%H%M%S")