Skip to content

Instantly share code, notes, and snippets.

View croaker's full-sized avatar

Daniel Gruenthal croaker

  • Hamburg, Germany
View GitHub Profile
@croaker
croaker / 1 README.md
Last active March 12, 2020 13:30
A JsonValidator for ActiveModel using json-schema

JsonValidator

A simple validator to validate jsonb columns against a JSON schema. It's dependent on the json-schema gem, make sure to add gem 'json-schema' to your Gemfile and run $ bundle.

To use this, add json_validator.rb to app/models/concerns and json_validator_spec.rb to spec/models/concerns. By convention, schemas are stored in app/models/json_schemas.

Example

@croaker
croaker / gitmessage
Created November 13, 2018 16:45
Commit Message Template
# 50-character subject line
#
# 72-character wrapped longer description. This should answer:
#
# * Why was this change necessary?
# * How does it address the problem?
# * Are there any side effects?
#
# Include a link to the ticket, if any.
#

Keybase proof

I hereby claim:

  • I am croaker on github.
  • I am dgruenthal (https://keybase.io/dgruenthal) on keybase.
  • I have a public key ASAwQbv5obh8XfQf_2il3bbj9D0UqMIdLpFH-n_zHacLuQo

To claim this, I am signing this object:

@croaker
croaker / OSX Preferences.sh
Created October 3, 2015 10:59
Key Repeat Settings for Mac OSX
# repeat characters on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
# faster initial key repeat
defaults write NSGlobalDomain InitialKeyRepeat -int 12
# super fast key repeat
defaults write NSGlobalDomain KeyRepeat -int 0
@croaker
croaker / backup.sh
Created April 23, 2015 14:13
Simple MySQL Backup
#!/bin/bash
# What is required?
#
# - An installed MySQL Client
# - An installed and configured AWS-CLI
MYSQLDUMP=/usr/bin/mysqldump
DUMP_FILE_SUFFIX=`date +%F`.sql
BACKUP_FOLDER=/tmp/backups
BACKUP_BUCKET=a_bucket_name
@croaker
croaker / gist:5068854
Last active December 14, 2015 09:59
Download a ruby 1.9.3 version, patch it using the railsexpress patches of skaes/rvm-patchsets, and pack it up..
#!/bin/bash
set -e
echo "Which patchset of ruby 1.9.3 do you want to download and patch? (eg. 392)"
read PATCHSET
RUBY_VERSION="ruby-1.9.3-p${PATCHSET}"
FILENAME="${RUBY_VERSION}.tar.gz"
if [ -d "/tmp/${RUBY_VERSION}" ]; then
@croaker
croaker / Classes
Created December 3, 2012 12:57
Reporta Message System
+---------------+
| Conversation |0..* initiator 1+-------+1
|---------------|+---------------------+| User |+----+
|title | +-------+ |
|body | |
|started_at | |
| |0..* project 1+---------+ |
| |+---------------------+| Project | | participant
| | +---------+ |
| | |
@croaker
croaker / gist:3225628
Created August 1, 2012 10:13
Various build parameters for ruby & gems using rbenv and homebrew
# Installing ruby with homebrew's readline & xml libs
brew install readline
brew install libxml2 --with-xml2-config
CONFIGURE_OPTS="--disable-install-doc --with-readline-dir=$(brew --prefix readline) \
--with-libxml2-dir=$(brew --prefix libxml2)" rbenv install 1.9.3-p194
# Installing nokogiri with homebrew's xml libs
brew install libxslt
gem install nokogiri -- --with-xml2-include=$(brew --prefix libxml2)/include \
--with-xml2-lib=$(brew --prefix libxml2)/lib --with-xslt-dir=$(brew --prefix libxslt)
@croaker
croaker / postgresql.rb
Created May 15, 2012 12:50
Homebrew - PostgreSQL 9.2 Beta Formula
require 'formula'
class Postgresql < Formula
homepage 'http://www.postgresql.org/'
url 'http://ftp.postgresql.org/pub/source/v9.2.0beta1/postgresql-9.2beta1.tar.bz2'
md5 '7bb0b7a3a6c32a9ae153d4132fe47d01'
depends_on 'readline'
depends_on 'libxml2' if MacOS.leopard? # Leopard libxml is too old
depends_on 'ossp-uuid'
@croaker
croaker / chef_solo_bootstrap.sh
Created April 20, 2012 10:43 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo on Ubuntu or Amazon AMIs
#!/usr/bin/env bash
RUBY_VERSION=1.9.3-p194
if [ -n `which yum` ]
then
# This is necessary for the Amazon Linux AMI
perl -pi -e 's/^(Defaults\s+secure_path.*)$/\1:\/usr\/local\/bin:\/usr\/local\/sbin/g' /etc/sudoers
yum update -y
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel \