Skip to content

Instantly share code, notes, and snippets.

View palexander's full-sized avatar

Paul R Alexander palexander

View GitHub Profile
@palexander
palexander / gist:2975305
Last active January 21, 2022 14:03
Compiling and running mosh on Dreamhost
# Thanks to @samsonjs for the cleaned up version:
# https://gist.github.com/samsonjs/4076746
PREFIX=$HOME
VERSION=1.2.3
# Install Protocol Buffers
wget http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.bz2
tar -xf protobuf-2.4.1.tar.bz2
cd protobuf-2.4.1
@palexander
palexander / ruby_data_object_comparison.rb
Created January 24, 2014 05:49
Benchmark to compare hash, OpenStruct, struct, and classes in Ruby
require 'ostruct'
require 'benchmark'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "test@example.org"
class Person
attr_accessor :name, :email
end
@palexander
palexander / gist:1375271
Created November 18, 2011 01:35
Remove a password from Git's history
# Sync with the remote master
git pull
# Force your clone to look like HEAD
git reset --hard
# AGAIN, A WARNING: This can really break stuff!
# Run your filter branch command, replacing all instances of "password" with "your_password"
# The example looks for Ruby files ("*.rb"), you can change this to match your needs
@palexander
palexander / .profile
Created March 25, 2020 23:12 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@palexander
palexander / GPG and git on macOS.md
Created March 25, 2020 23:10 — forked from danieleggert/GPG and git on macOS.md
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@palexander
palexander / gpg-signing.md
Created March 25, 2020 23:10 — forked from xavierfoucrier/gpg-signing.md
GPG signing with Git and Github Desktop

Hi Github users,

You can now signed your commits on Github using at least Git 2.18.0 and Github Desktop 1.6.1.

  1. Generate a GPG key and add it to Github: https://help.github.com/articles/generating-a-new-gpg-key (if you don't want to type a passphrase on every commit, you need to press "Enter" when the console will prompt you to type a passphrase)

  2. Configure Git properly by editing the .gitconfig file using the command line git config --global --edit in a terminal, then replace YOUR_GITHUB_EMAIL, YOUR_SIGNING_KEY and GPG_BINARY_PATH with your data

@palexander
palexander / install_spark_centos7.sh
Created July 29, 2016 01:52 — forked from darcyliu/install_spark_centos7.sh
Install Spark on CentOS 7
#!/bin/bash
# Install Spark on CentOS 7
yum install java -y
java -version
yum install wget -y
wget http://downloads.typesafe.com/scala/2.11.7/scala-2.11.7.tgz
tar xvf scala-2.11.7.tgz
sudo mv scala-2.11.7 /usr/lib
sudo ln -s /usr/lib/scala-2.11.7 /usr/lib/scala
@palexander
palexander / ruby_optional_arguments_benchmark.rb
Last active January 4, 2016 07:59
Benchmark to compare hash and keyword arguments in method invocations
require 'benchmark'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "test@example.org"
class Person
attr_accessor :name, :email
def set_with_hash(options = {})
1000 MA
1001 GRO-CPGA
1005 BTO
1006 CL
1007 CHEBI
1008 DDANAT
1009 DOID
1010 EMAP
1011 IEV
1012 ECO
namespace :docker do
desc "Run tasks in parallel using docker"
task :test do
forks = 4
begin
# Start docker containers (serially, docker seems to have problems with concurrency)
ports = {}
forks.times do |i|
# Start redis and get the mapped port
`docker run -d -p 6379 -name redis#{i} yourdockeruser/redis`