Skip to content

Instantly share code, notes, and snippets.

Lego Jimmy: The Sequel

Background Information:

  • Who are the headless?
  • What happened to their home?
    • Some badguys survived after the end of the previous movie.
  • Why do they hate Lego Jimmy?
  • How did they get powerfull after they lost their home?
    • The capture villagers and force them to build a new castle for them
  • Scene Ideas:
#!/usr/bin/env bash
##
# This script installs docker and docker-compose on an ubuntu host
# Additionally it:
# - Adds a user to the docker group (to simplify permissions in development)
# - Configures docker to run with bridged networking by default
##
set -e
@hattwj
hattwj / docker-compose-to-etc-hosts
Last active August 22, 2022 16:29
Quickly add hostname aliases for running docker-compose containers
#!/usr/bin/env bash
# Run this file on the host machine that is running dockerd
# It will allow you to access your docker containers via hostname aliases
# Remove old lines with suffix
sed -i -e "/#docker-temp/d" /etc/hosts
# Collect ip-addresses and hostnames of running docker-compose containers
ADDR=$(docker-compose ps -q | xargs --no-run-if-empty -I --- docker exec --- hostname -I| sed -e 's/ /-/')
@hattwj
hattwj / cross_tabs.js.coffee
Created July 8, 2015 16:51
Cross tab communication in CoffeeScript
event_prefix = 'cross-tabs:'
##
# Global function allows for triggering cross browser events
@cross_tabs_trigger = (ename, msg) ->
data = JSON.stringify(msg, null, 2)
localStorage.setItem(event_prefix + ename, data)
cross_tabs_handler = (e) ->
if e.key.startsWith(event_prefix)
@hattwj
hattwj / rails_cache_effects.rb
Created May 27, 2015 15:11
rails cache unexpected side effects.rb
def get_data_no_marshal
cache_key = 'Some random cache key'
result = Rails.cache.fetch(cache_key, race_condition_ttl: 10) do
# Load resource and pre-load associations
Survey.includes(:survey_meta,
:q_groups=>[
:q_questions=>[
:q_answers,
:q_attributes
]
@hattwj
hattwj / mysql_backup.sh
Created April 29, 2014 19:50
MySQL Automated Backup Script
#!/bin/bash
# MySQL Backup util
# Automatic backup utility, run in cron job under root database user
# Example cron line:
# 53 * * * * /data/scripts/backup_mysql_database.sh
# Defaults - I
PREFIX='hourly_'
HOUR=`date +%H`
@hattwj
hattwj / postgresql_backup.sh
Last active August 29, 2015 14:00
PostgreSQL Automated Backup Script
#!/bin/bash
# PostgreSQL Backup util
# Automatic backup utility, run in cron job under postgres user
# Example cron line:
# 53 * * * * /data/scripts/backup_database.sh
# Defaults - I
PREFIX='hourly_'
HOUR=`date +%H`
@hattwj
hattwj / spoofer.sh
Last active January 2, 2016 17:49
Mac Address Spoofer
# http://www.commandlinefu.com/commands/view/745/generat-a-random-mac-address
MAC=`(date; cat /proc/interrupts) | md5sum | sed -r 's/^(.{10}).*$/\1/; s/([0-9a-f]{2})/\1:/g; s/:$//;'`
# http://blog.thecodecracker.com/hacks/spoof-mac-address-in-android/
busybox iplink set eth0 $MAC
@hattwj
hattwj / text_to_voice.sh
Last active December 23, 2015 06:49
Playing around with text to voice in Ubuntu 13.04
# Install festival
sudo apt-get install festival festlex-cmu festlex-poslex festlex-oald libestools1.2 unzip
# List installed voices
for d in `ls /usr/share/festival/voices` ; do ls "/usr/share/festival/voices/${d}" ; done
# or festival> (voice.list)
# Create a ~/.festivalrc file and set the default voice
# (set! voice_default 'voice_rab_diphone)
@hattwj
hattwj / csv_to_sql.rb
Last active December 22, 2015 11:39
Ruby: Convert a CSV file into SQL (PostgreSQL tested)
#!/usr/bin/env ruby
require 'csv'
require 'cgi'
require 'rubygems'
require 'ruby-debug'
def usage
puts 'Usage:'