Skip to content

Instantly share code, notes, and snippets.

if ! $(psql template1 -c 'SHOW SERVER_ENCODING' | grep -q UTF8); then
psql postgres -c "update pg_database set datallowconn = TRUE where datname = 'template0';"
psql template0 -c "update pg_database set datistemplate = FALSE where datname = 'template1';"
psql template0 -c "drop database template1;"
psql template0 -c "create database template1 with template = template0 encoding = 'UTF8';"
psql template0 -c "update pg_database set datistemplate = TRUE where datname = 'template1';"
psql template1 -c "update pg_database set datallowconn = FALSE where datname = 'template0';"
fi
# :reminder_ribbon: Adjust as necessary
export DEV="/dev/nvme0n1"
export SWAP_S="8G"
export SYSTEM_S="20%FREE"
export HOME_S="80%FREE"
# These are for LVM
flavour="$( sed -n 's/.*cdrom:\[\([^ ]*\).*/\1/p' /etc/apt/sources.list )"
release="$( lsb_release -sr | tr -d . )"
if [ ${release} -ge 2204 ]; then VGNAME="vg${flavour,,}"; else VGNAME="${flavour}--vg"; fi
@fgrehm
fgrehm / gist:4489503
Last active November 30, 2020 16:25
knockout.js + handlebars
class HandlebarsTemplateEngine extends ko.templateEngine
renderTemplateSource: (compiledTemplate, bindingContext, options) ->
data = bindingContext.$data
htmlResult = compiledTemplate(data)
ko.utils.parseHtmlFragment(htmlResult)
makeTemplateSource: (template, templateDocument) ->
throw "Could not find a template named: '#{template}'" unless JST[template]
JST[template]
@fgrehm
fgrehm / ree-1.8.7-2011.03
Created August 14, 2012 01:46
ruby-build REE definitions for Ubuntu 12.04
build_package_patched() {
# These three patches are included when RVM builds REE
cd source
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/tcmalloc.patch'
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/stdout-rouge-fix.patch'
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/no_sslv2.diff'
patch -p1 < tcmalloc.patch
patch -p1 < stdout-rouge-fix.patch
patch -p1 < no_sslv2.diff
cd ..
@fgrehm
fgrehm / keybase.md
Created June 20, 2020 20:41
keybase.md

Keybase proof

I hereby claim:

  • I am fgrehm on github.
  • I am fgrehm (https://keybase.io/fgrehm) on keybase.
  • I have a public key ASD-JvHBz59Ab66GlN-q-C06vc7mhnuh4-1qLt2AAYZitgo

To claim this, I am signing this object:

#!/bin/bash
##################################################################################
# 1 - Create the base container
SUITE=squeeze
RELEASE=$SUITE
sudo lxc-create -n ${RELEASE}-base -t debian
rootfs="/var/lib/lxc/${RELEASE}-base/rootfs"
@fgrehm
fgrehm / keybase.md
Created November 21, 2018 15:33
keybase.md

Keybase proof

I hereby claim:

  • I am fgrehm on github.
  • I am fgrehm (https://keybase.io/fgrehm) on keybase.
  • I have a public key ASBS1R4n4du4znaDFvsreIfQr3mJ3x4mT_veoY4o3qUDfgo

To claim this, I am signing this object:

@fgrehm
fgrehm / deploy.rake
Last active July 27, 2018 23:31 — forked from njvitto/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
# Deploy and rollback on Heroku in staging and production
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP'
STAGING_APP = 'YOUR_STAGING_APP'
REMOTE = ENV["REMOTE_HOST"] || "git@heroku.com"
def heroku_cmd(cmd)
Bundler.with_clean_env do
sh "heroku #{cmd}"
@fgrehm
fgrehm / cocoon-chosen.coffee
Created February 19, 2013 18:15
Cocoon + Chosen
jQuery ($) ->
$('.add_fields').each ->
$this = $(this)
insertionNode = $this.data('association-insertion-node')
insertionTraversal = $this.data('association-insertion-traversal')
if (insertionNode)
if (insertionTraversal)
insertionNode = $this[insertionTraversal](insertionNode)
else
@fgrehm
fgrehm / Dockerfile
Created June 5, 2013 01:44
OpenJDK 7 JRE Dockerfile
# OpenJDK 7 JRE
#
# VERSION 0.0.1
FROM base
MAINTAINER Fabio Rehm "fgrehm@gmail.com"
RUN apt-get update
RUN apt-get install -y openjdk-7-jre-headless