Skip to content

Instantly share code, notes, and snippets.

View johnjohndoe's full-sized avatar

Tobias Preuss johnjohndoe

View GitHub Profile
require 'addressable/uri'
# Source: http://gist.github.com/bf4/5320847
# Accepts options[:message] and options[:allowed_protocols]
# spec/validators/uri_validator_spec.rb
class UriValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
uri = parse_uri(value)
if !uri
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render json: user.as_json(auth_token: user.authentication_token, email: user.email), status: :created
return
else
@johnjohndoe
johnjohndoe / colorize-maven.sh
Last active July 22, 2018 16:28 — forked from DanielThomas/colorize-maven.sh
A color script for the console output of maven.
#!/bin/sh
# Written by Mike Ensor (mike@ensor.cc)
# Copywrite 2012
# Use as needed, modify, have fun!
# This is intended to be used for Maven3 + Mac OSX
#
# To use:
# in your ".bashrc" or ".bash_profile" add the following line:
# source ~/<path to script>/colorize-maven.sh
@johnjohndoe
johnjohndoe / download.rb
Created December 16, 2012 17:46 — forked from leecade/download.rb
Replace hard coded file name with environment variable.
#!/usr/bin/env ruby
# An HTTP/HTTPS/FTP file downloader library/CLI based upon MiniPortile's
# HTTP implementation.
#
# Author: Jon Maken
# License: 3-clause BSD
# Revision: 2012-03-25 21:18:59 -0600
require 'net/http'
require 'net/https' if RUBY_VERSION < '1.9'
@johnjohndoe
johnjohndoe / gist:3754453
Created September 20, 2012 07:36 — forked from gnunicorn/gist:3748738
Git for Beginners: Call for Coaches

The OpenTechSchool has set up and hosted a few tech workshops and meetups here in Berlin now. Aside from the monthly Beginners Meetup and hosting the Udacity Global Meetup we hosted workshops for program beginners in Python and Javascript on our own and on the premise of CampusParty.

One thing that was extraordinary popular on CampusParty was the Workshop on Git for beginners. And we decided to do it again, this time with a closer focus on version control as a major benefit in code sharing (by using git and github) for beginners - free of charge.

So if you are interested in