Skip to content

Instantly share code, notes, and snippets.

@stevepereira
stevepereira / git-recover-branch.md
Created December 17, 2015 17:47 — forked from jbgo/git-recover-branch.md
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@stevepereira
stevepereira / useful_pandas_snippets.py
Created October 20, 2015 19:13 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
@stevepereira
stevepereira / docker-machine-vmfusion.sh
Last active November 13, 2015 20:12
Basic workflow for docker-machine on Mac with VMWare Fusion
# Get everything ready on a Mac
brew install docker docker-machine docker-compose
# Create a new machine (based on the 1.8.1 boot2docker iso)
docker-machine create --driver vmwarefusion --vmwarefusion-memory-size 2048 --vmwarefusion-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v1.8.1/boot2docker.iso dev
# Bring the machine up
docker-machine start dev
# Configure Shell
curl -X POST --data-binary @payload.yaml -H "Content-type: text/x-yaml" http://localhost:4200/some-url/1024
DELIMITER $$
DROP PROCEDURE IF EXISTS add_email_address_column_to_customers_table $$
-- Create the stored procedure to perform the migration
CREATE PROCEDURE add_email_address_column_to_customers_table()
BEGIN
-- Add the email_address column to the customers table, if it doesn't already exist
#create data directory to contain any data we want persisted
sudo mkdir /var/lib/boot2docker/data && sudo chown docker:staff /var/lib/boot2docker/data
#pull busybox and set it up as a data volume container
docker run -v /var/lib/boot2docker/data:/data --name data-share busybox true
#pull svendowideit/samba and run it with the data-share container
#docker run --rm -v $(which docker):/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba data-share
#make sure the samba share runs next time boot2docker starts
@stevepereira
stevepereira / Vagrantfile
Last active August 29, 2015 14:06 — forked from gijs/Vagrantfile
So far both rsync and nfs both suck - tail -f in docker container doesn't hear the modify but the file does update (used with vagrant rsync-auto in combination with rsync)
# -*- mode: ruby -*-
# # vi: set ft=ruby :
require 'fileutils'
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")
# Defaults for config options defined in CONFIG
$num_instances = 1
# using VirtualBox version $VBOX_VERSION
FROM boot2docker/boot2docker
RUN apt-get install -y p7zip-full
RUN mkdir -p /vboxguest && \
cd /vboxguest && \
curl -L -o vboxguest.iso http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso && \
7z x vboxguest.iso -ir'!VBoxLinuxAdditions.run' && \
sh VBoxLinuxAdditions.run --noexec --target . && \
# prevent the creation of .DS_Store files on network drives
# http://hints.macworld.com/article.php?story=2005070300463515
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
#---------------------------------------------------------------------
# Disable/enable Dashboard:
# http://hints.macworld.com/article.php?story=20050723123302403
defaults write com.apple.dashboard mcx-disabled -boolean YES