Skip to content

Instantly share code, notes, and snippets.

View mreinsch's full-sized avatar

Michael Reinsch mreinsch

View GitHub Profile
require 'net/http'
require 'base64'
require 'cgi'
require 'json'
class CoBot
HEADERS = {
'Accept' => 'application/json',
'Content-Type' => 'application/json; charset=utf-8',
'User-Agent' => 'Harvest Twitter Script' }
require 'rubygems'
require 'shoulda'
class SimpleTest < Test::Unit::TestCase
context 'with 100' do
setup { @total = 100 }
should("return 100") { assert_equal(100, @total.to_i) }
end
end
@mreinsch
mreinsch / brew doctor
Created July 27, 2012 03:41
homebrew postgresql compile log
Your system is raring to brew.
@mreinsch
mreinsch / simple_assets.rb
Last active December 10, 2015 00:28
Speed up asset compilation by simply coping assets if nothing changed (based on git). Also works fine with turbo_sprockets. Load this with: load 'simple_assets' in your deploy.rb
load 'deploy' unless defined?(_cset)
_cset :asset_env, "RAILS_GROUPS=assets"
_cset :assets_prefix, "assets"
_cset :assets_role, [:web]
_cset :normalize_asset_timestamps, false
after 'deploy:update_code', 'deploy:assets:precompile'
@mreinsch
mreinsch / rescue_from_defaults.rb
Last active June 3, 2023 00:05
the way we are catching errors and rendering custom error pages for http://www.doorkeeperhq.com/
# encoding: UTF-8
#
# This file is in: lib/rescue_from_defaults.rb
#
# To use it, include the RescueFromDefaults in the ApplicationController (see below for example)
#
# To test it we are using rspec and steak. See below for examples.
#
class AccessDenied < RuntimeError
end
@mreinsch
mreinsch / aliases
Last active December 6, 2016 03:57
relaying email from Postfix to a Rails application, using normal HTTP API endpoints
doorkeeper_contact: |"/srv/doorkeeper/current/script/email_handler contact_emails production"
doorkeeper_event_signup: |"/srv/doorkeeper/current/script/email_handler signup_emails production"
doorkeeper_bounce: |"/srv/doorkeeper/current/script/email_handler bounced_emails production"
@mreinsch
mreinsch / contact_mailer.rb
Last active August 29, 2015 14:01
Sample code for how to attach an email when generating an email in Rails 3/4
class ContactMailer < ActionMailer::Base
def receive(email)
ContactMailer.contact_admins(email).deliver
end
def contact_admins(orig_email)
m = mail(to: 'info@doorkeeper.jp', subject: 'Received email') do |format|
format.text { render }
format.html { render }
@mreinsch
mreinsch / elasticsearch10.rb
Created January 22, 2015 16:09
brew file for elasticsearch 10
# put this in /usr/local/Library/Taps/homebrew/homebrew-versions/elasticsearch10.rb
# $ ln -s ../Taps/homebrew/homebrew-versions/elasticsearch10.rd /usr/local/Library/Formula/elasticsearch10.rb
# $ brew install elasticsearch10
require 'formula'
class Elasticsearch10 < Formula
homepage 'http://www.elasticsearch.org'
url 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.1.tar.gz'
sha1 '26bcf8e36576b2f3809ab84432ea005f893836b9'
#!/bin/bash
ES_VERSION="1.1.1"
ES_PORT="9333"
PWD=`pwd`
mkdir -p ~/elasticsearch/
cd ~/elasticsearch/
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ES_VERSION}.zip
Verifying I am +mreinsch on my passcard. https://onename.com/mreinsch