Skip to content

Instantly share code, notes, and snippets.

@purplejacket
purplejacket / tetris.html
Last active September 25, 2018 05:34
tetris in Javascript -- a 1999 port of the earlier qbasic tetris program. On archive.org here: https://web.archive.org/web/20180925053131/http://taraindian.com/kai/tetris.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<!-- saved from url=(0049)http://www.graycary-etraining.com/main/tetris.htm --><title>Tetris</title>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<script language="JavaScript">
<!--
// Global arrays
@purplejacket
purplejacket / foo.rake
Last active September 6, 2018 17:11
Skeleton of a rake task
# To test, type this on the command line:
# rake -T | grep foo
# To invoke:
# rake foo:first_task[1221]
namespace :foo do
desc 'Skeleton of a rake task'
task :first_task, [:num] => :environment do |_, args|
abort_reason = false
[user]
name =
email =
[core]
excludesfile = /Users/kai/.gitignore_global
editor = vim
[alias]
co = checkout
ci = commit
st = status
alias path='ruby -e "puts ENV[%{PATH}].gsub(/:/,%{\n}) # pretty print the PATH"'
alias free_space='df -H && echo'
alias gitjk="history 10 | tail -r | gitjk_cmd"
alias chess='wine "/Users/kai/.wine/drive_c/Aquarium 2015"/Aquarium.exe'
alias chess2='wine "/Users/kai/.wine/drive_c/Program Files/LucasChess"/Lucas.exe'
alias chess3='wine ~/bin/Fritz_Chess_Benchmark.exe'
alias chess4='/Applications/DOSBox.app/Contents/MacOS/DOSBox ~/.wine/drive_c/cm2100/2100.exe' # use alt-enter for full screen and ctrl-F10 for mouse capture/release
alias chess4_5='vim /Users/kai/Library/Preferences/DOSBox\ 0.74\ Preferences'
alias chess5='wine /Users/kai/.wine/drive_c/Arena/Arena.exe &'
alias chess6='/Applications/XBoard.app/Contents/MacOS/XBoard'
@purplejacket
purplejacket / inventario.txt
Created November 3, 2017 20:16
Inventario forestal - finca ecologica Guadalupe - compiled by Leonel Morazan October 2013
FRUTALES
97 Aguacate
11 Aguacate con injerto
3 Anona
4 Cacao
4 Caimito
5 Canela
100 Cocos
7 Greyfus
@purplejacket
purplejacket / sqrt.rb
Last active October 17, 2017 19:35
Find square root using Newton's Method -- Ruby version (we use a trick to get a good starting seed value)
# https://www.codewars.com/kata/square-root-without-using-library-math
# the challenge stipulates: don't require any libs, don't use ** operator (exponentiation)
# the challenge also says all inputs will already be perfect squares of integers
# This code works for very large integers as well as small ones
def square_root_me(num)
start = num.to_s(2); start = start[0,(start.length/2)].to_i(2)
retval = start
for i in 0..10000 do
@purplejacket
purplejacket / PS1_bashrc.sh
Last active June 24, 2017 05:02
Some colorized prompts - PS1 values - ANSI color escape sequences
# skyportal-experiment
PS1='${debian_chroot:+($debian_chroot)}\[\033[0;33m\]\u\[\033[1;37m\]@\[\033[0;34m\]\[\e[106m\]skyportal-experiment\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# skyportal-staging
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u\[\033[1;37m\]\[\e[100m\]@\[\033[0;34m\]\[\e[102m\]skyportal-staging\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# skyportal-production
PS1='${debian_chroot:+($debian_chroot)}\[\033[0;33m\]\u\[\033[1;37m\]@\[\033[0;34m\]\[\e[106m\]skyportal-experiment\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# local machine
#!/bin/bash
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
@purplejacket
purplejacket / mongodb.service
Created June 23, 2017 21:49
A unit file to manage the MongoDB service -- for Ubuntu 16.04 -- to be located at /etc/systemd/system/mongodb.service -- from setup steps given at https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
@purplejacket
purplejacket / mary_oliver_the_gift.txt
Created May 30, 2017 13:42
Poem by Mary Oliver about a Mockingbird who sang Mahler
Mary Oliver: The Gift
I wanted to thank the mockingbird for the vigor of his song.
Every day he sang from the rim of the field, while I picked
blueberries or just idled in the sun.
Every day he came fluttering by to show me, and why not,
the white blossoms in his wings.
So one day I went there with a machine, and played some songs of
Mahler.
The mockingbird stopped singing, he came close and seemed