Skip to content

Instantly share code, notes, and snippets.

View alancnet's full-sized avatar
🧙
Making the magic happen

alancnet

🧙
Making the magic happen
View GitHub Profile
function helloWorld()
print("Hello World")
end
helloWorld()
@alancnet
alancnet / HashSetFile.scala
Created September 28, 2016 23:51
HashSet implemented against a file system.
import java.io.{File, RandomAccessFile}
class HashSetFile(file: File, modulus: Int = 32) {
val raf = new RandomAccessFile(file, "rw")
def filePosition = raf.getFilePointer
def fileLength = raf.length
val bytesInLong = java.lang.Long.BYTES
val indexesStart = bytesInLong
val start = System.currentTimeMillis()
if (fileLength == 0) {
@alancnet
alancnet / RandomAccessFileHashSet.scala
Created September 28, 2016 23:42
A slow, super large heirarchial hash set thing using files.
import java.io.{File, RandomAccessFile}
class RandomAccessFileHashSet(file: File) {
val raf = new RandomAccessFile(file, "rw")
def filePosition = raf.getFilePointer
def fileLength = raf.length
var recordCount: Long = 0L
raf.writeLong(recordCount)
val hashStart = filePosition
export BLACK='\033[0;30m' # Black - Regular
export RED='\033[0;31m' # Red
export GREEN='\033[0;32m' # Green
export YELLOW='\033[0;33m' # Yellow
export BLUE='\033[0;34m' # Blue
export MAGENTA='\033[0;35m' # Purple
export CYAN='\033[0;36m' # Cyan
export WHITE='\033[0;37m' # White
export BLACK_BOLD='\033[1;30m' # Black - Regular
@alancnet
alancnet / LocalWebServer.scala
Created March 7, 2016 01:55
Use Play Framework as a component
import java.io.File
import play.api.ApplicationLoader.Context
import play.api._
import play.api.routing.Router
import play.core.server.{ServerConfig, NettyServer}
abstract class LocalWebServer {
val environment = new Environment(
new File("."),
@alancnet
alancnet / alan.sh
Created February 22, 2016 23:03
Prints my face!
echo -e "\E[1m\E[48;5;255m\E[38;5;255m\u2585\E[1m\E[48;5;255m\E[38;5;255m\u2585\E[1m\E[48;5;255m\E[38;5;255m\u2585\E[1m\E[48;5;255m\E[38;5;255m\u2585\E[1m\E[48;5;255m\E[38;5;255m\u2585\E[1m\E[48;5;255m\E[38;5;255m\u2585\E[1m\E[48;5;255m\E[38;5;231m\u2585\E[1m\E[48;5;255m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;188m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;231m\E[38;5;188m\u2585\E[1m\E[48;5;231m\E[38;5;195m\u2585\E[1m\E[48;5;231m\E[38;5;231m\u2585\E[1m\E[48;5;188m\E[38;5;145m\u2585\E[1m\E[48;5;145m\E[38;5;102m\u2585\E[1m\E[48;5;102m\E[38;5;102m\u2585\E[1m\E[48;5;102m\E[38;5;138m\u2585\E[1m\E[48;5;102m\E[38;5;138m\u2585\E[1m\E[48;5;138m\E[38;5;145m\u2585\E[1m\E[48;5;102m\E[38;5;145m\u2585\E[1m\E[48;5;102m\E[38;5;102m\u2585
@alancnet
alancnet / How to Docker Swarm.md
Last active September 29, 2020 12:00
How to Docker Swarm

Temporary environment variables

# IP Address of master machine
masterip=192.168.0.101

# IP Address of node machine
nodeip=192.168.0.14

On the master

Run ETCD

@alancnet
alancnet / How to CoreOS
Created November 27, 2015 04:01
How to CoreOS on Mac
# Pre-requisits
## for mkisofs
brew install dvdrtools
## fix brew
cd /usr/local/Library/
sudo git pull origin master
## gpg
@alancnet
alancnet / How to Shipyard
Created November 26, 2015 04:40
How to install shipyard and nodes
Deploy manager:
curl -sSL http://test.shipyard-project.com/deploy | bash -s
Deploy nodes:
curl -sSL http://test.shipyard-project.com/deploy | ACTION=node DISCOVERY=etcd://<IP-OF-SHIPYARD>:4001 bash -s
function cycle(array) {
function cycleInt(array, count) {
if (count == array.length) return [];
var tmp = array.slice(0);
tmp.push(tmp.shift());
return cycleInt(tmp, count + 1).concat([tmp]);
}
return cycleInt(array, 0);
}
function flatten(col) {