Skip to content

Instantly share code, notes, and snippets.

@adam000
adam000 / splitting_xsera_and_apollo.txt
Created March 23, 2012 07:29
description of files in Xsera repository
(repository at: github.com/adam000/xsera)
I want to split a repository by:
Apollo, the engine
Xsera, which uses Apollo
Files are prefixed by:
(b) -> file belongs to both / either
(a) -> file belongs to apollo, the soon-to-be subrepository
(x) -> file belongs to xsera, the soon-to-be super-repository (?)
#!/bin/bash
function move_sequential {
if [[ $# != 4 ]]; then
echo Usage: move_sequential <prefix> <first number to move, inclusive> <last number to move, inclusive> <suffix>
return 1
fi
PREFIX=$1
FIRST=$2
@adam000
adam000 / modelines.bash
Created October 29, 2013 23:35
How to do some basic modelines for Vim. I always forget the syntax...
#!/bin/bash
# vim: set ts=2 sw=2:
# or for Makefile:
# vim: set ts=5 sw=5 noet nolist:
@adam000
adam000 / fileToArray.bash
Created October 29, 2013 23:39
How to turn a file into an array in bash (delimited by newline, if I remember correctly).
#!/bin/bash
echo "Please enter a file to be read as an array:"
read fileName
a=( $(cat fileName) )
@adam000
adam000 / logic.txt
Last active December 26, 2015 22:39
I'm not sure what this is, but I found it floating around on my computer. It seems to be doing some sort of permutation-like logic.
It seems to be following some permutation-like math:
trees[2] = trees[0]*trees[1] + trees[1]*trees[0]
trees[3] = trees[0]*trees[2] + trees[1]*trees[1] + trees[2]*trees[0]
trees[4] = trees[0]*trees[3] + trees[1]*trees[2] + trees[2]*trees[1] + trees[3]*trees[0]
etc.
I would love to know why it is doing this, but alas, I cannot remember.
@adam000
adam000 / primes.lua
Created October 30, 2013 00:14
A fun implementation of a prime finder using metatables
-- Metatable implementation of primes
primes = { 2, 3, 5, 7, 11, 13 }
__mt = {
__index = function(table, index)
local val = table[index - 1]
repeat
val = val + 2
local isPrime = true
@adam000
adam000 / pyro.cfg
Created October 31, 2013 21:47
Team Fortress 2 config script: Pyro quick switching to flare / sg using shift. Seriously, the most handy bind ever.
alias +secondary "slot2"
alias -secondary "slot1"
bind shift "+secondary"
@adam000
adam000 / cache.lua
Created December 16, 2013 19:47
I had a cool thought: what if you used metatables to make a really cool caching scheme? If it hits the `__index` metatable, you return a function that'll add a key-value pair, otherwise you return the value. Don't have time to work on it right now, so I'm just posting this barebones gist until I get around to it.
#!/usr/bin/env lua
-- Get the cache singleton
function getCache()
-- TODO
end
-- Metatable function that returns a function to add to the cache
@adam000
adam000 / goplayground
Last active August 29, 2015 14:07
A nice little command to set up a small Go "playground" (see also: play.golang.org) in a temporary directory
#!/bin/bash
while true; do
DIR=/tmp/`printf %05d $RANDOM`
if [[ ! -e $DIR ]]; then
break
fi
done
echo Making $DIR

Keybase proof

I hereby claim:

  • I am adam000 on github.
  • I am adam_0 (https://keybase.io/adam_0) on keybase.
  • I have a public key whose fingerprint is 9C68 2F61 E3FE 7EF4 C179 9FA3 7C78 905F 5897 D6C9

To claim this, I am signing this object: