Skip to content

Instantly share code, notes, and snippets.

View Spaceghost's full-sized avatar
👻
Building distributed and decentralized systems that run in the browser

Johnneylee Jack Rollins Spaceghost

👻
Building distributed and decentralized systems that run in the browser
View GitHub Profile
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@Spaceghost
Spaceghost / netboot.sh
Created August 4, 2021 08:48
One-shot to netboot.xyz
wget -c "https://boot.netboot.xyz/ipxe/netboot.xyz.lkrn" -O /boot/netboot.xyz.lkrn && \
cat > /etc/grub.d/40_custom <<EOF
#!/bin/sh
exec tail -n +3 \$0
menuentry 'netboot.xyz' {
set root='hd0,msdos1'
linux16 /netboot.xyz.lkrn
}
EOF
update-grub
@Spaceghost
Spaceghost / mirror_test.sh
Created January 14, 2021 07:54 — forked from lox/mirror_test.sh
A bash script to select the fastest ubuntu apt geo-mirror
#!/bin/bash -e
# mirror_test.sh
# benchmarks closest ubuntu mirrors and outputs them in speed order
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/lox/9152137/raw/mirror_test.sh)"
RELEASE=$(lsb_release -c -s 2>/dev/null || echo 14.04)
MIRRORS=$(curl -s http://mirrors.ubuntu.com/mirrors.txt)
TESTFILE="dists/$RELEASE/main/binary-amd64/Packages.bz2"
TIMEOUT=1
@Spaceghost
Spaceghost / smux.sh
Created October 3, 2020 04:01
autossh combined with tmux for a mosh like behaior
function smux {
AUTOSSH_POLL=10
AUTOSSH_PORT=$(awk 'BEGIN { srand(); do r = rand()*32000; while ( r < 20000 ); printf("%d\n",r) }' < /dev/null)
#AUTOSSH_GATETIME=30
#AUTOSSH_LOGFILE=autossh.$HOST.log
#AUTOSSH_DEBUG=yes
#AUTOSSH_PATH=/usr/local/bin/ssh
export AUTOSSH_POLL AUTOSSH_LOGFILE AUTOSSH_DEBUG AUTOSSH_PATH AUTOSSH_GATETIME AUTOSSH_PORT
@Spaceghost
Spaceghost / how to install entware on ARM.md
Last active August 29, 2015 14:26 — forked from dreamcat4/how to install entware on ARM.md
Install entware on ARM based router eg tomato / ddwrt / asus-merlin cfw
module Prelaunchr
module Twilio
class Client
def self.configure(&block)
Twilio.configure(&block)
end
def initialize
@client = Twilio::REST::Client.new
@Spaceghost
Spaceghost / functions.sh
Created January 20, 2015 04:03
Idempotence in your path.
idempotent_path_prepend() { # idempotent_path_append dir1 dir2 dir3 => dir1:dir2:dir3:$PATH
for ((i=$#; i>0; i--)); do ARG=${!i}
if [ -d "$ARG" ]; then # Only add to path if the path currently exists. Might remove.
PATH=${PATH//":$ARG"/} # delete any instances in the middle or at the end
PATH=${PATH//"$ARG:"/} # delete any instances at the beginning
export PATH="$ARG:$PATH" # prepend to beginning
fi
done
}
@Spaceghost
Spaceghost / gist:bd4a3ec584add69b99da
Created January 10, 2015 02:28
github.com host key fingerprint art
+--[ RSA 2048]----+
| . |
| + . |
| . B . |
| o * + |
| X * S |
| + O o . . |
| . E . o |
| . . o |
| . . |

Benchmarking ruby

The problem: Create a hash from an array of objects where the key is the object's #id and the value is the #stuff method.

Known/Suspected caveats:

  • Garbage collection might be happening, making the results lie.
  • Not exhaustive of ways to create a hash from an array
  • Not exhaustive of ways to call Benchmark.ips with code to test. (no strings yet)
  • Not able to manually change the number of iterations
Calculating -------------------------------------
#inject assign&return
290.000 i/100ms
merge 1.000 i/100ms
merge! 106.000 i/100ms
each_with_object 292.000 i/100ms
zenspider 298.000 i/100ms
pipework 299.000 i/100ms
-------------------------------------------------
#inject assign&return