Skip to content

Instantly share code, notes, and snippets.

View neophiliac's full-sized avatar

Kurt Sussman neophiliac

View GitHub Profile
@ka8725
ka8725 / states_matcher.rb
Created December 13, 2013 12:23
Custom matcher for Rspec to test state_machine status flow
# This custom matcher can be used to test state machine
#
# Examples
#
# it { should have_event(:status, :event_name, [:state1, :state2] => [:state3, :state4]) }
# it { should have_event(:status, :event_name, {
# :state1 => :state3,
# :state1 => :state4,
# :state3 => :state3,
# :state2 => :state4
@ka8725
ka8725 / dbconfig.rake
Last active July 28, 2016 10:03
database.yml generator. Global Rake implementation
require 'yaml'
desc 'Generates database.yml, optional arguments: [adapter, user, password]'
task :dbconfig => 'database.yml'
file 'database.yml', [:adapter, :username, :password] do |t, args|
Dir.chdir('config')
args.with_defaults(:project_path => Dir.pwd)
DBConfigGenerator.new(t, args).generate
end
@pcreux
pcreux / Gemfile
Last active December 11, 2023 20:24
Fast Rails + Heroku Configuration
group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end
@amolpujari
amolpujari / modify_emails.html.erb
Last active December 24, 2015 23:29
rails user modifies email
# gem 'ckeditor_rails' # from https://github.com/tsechingho/ckeditor-rails
# allow modifying existing template
<textarea name="modified_email" class="ckeditor">
<%= File.read "#{Rails.root.to_s}/app/views/user_mailer/do_email.html.erb"%>
</textarea>
<%= javascript_include_tag "ckeditor-jquery" %>
<script type="text/javascript">
$('.ckeditor').ckeditor({
@konklone
konklone / ssl.rules
Last active October 29, 2024 07:36
nginx TLS / SSL configuration options for konklone.com
# Basically the nginx configuration I use at konklone.com.
# I check it using https://www.ssllabs.com/ssltest/analyze.html?d=konklone.com
#
# To provide feedback, please tweet at @konklone or email [email protected].
# Comments on gists don't notify the author.
#
# Thanks to WubTheCaptain (https://wubthecaptain.eu) for his help and ciphersuites.
# Thanks to Ilya Grigorik (https://www.igvita.com) for constant inspiration.
server {

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
@toretore
toretore / README.md
Last active December 19, 2015 10:49
Rails 0MQ logger

These files work together to extract useful data from a Rails application and publish it through a ZeroMQ PUSH socket as JSON.

The code in application_controller.rb will automatically log every request and exception, but you're free to log other things. If you're inside a controller, you can use log_message(atts) or emit_event(atts). These controller methods simply delegate to the global object $ZMQ_LOGGER, which responds to log(atts) and emit(atts). They add the data.http.request-id key if not already present.

The difference between logging and emitting is somewhat blurry, but I like to think of log messages as something that will be saved somewhere and emitted events as ephemeral.

All attributes are expected to use strings as keys. If you use symbols, you may experience issues.

You may use these files as you wish, with one exception: You may not package them into a reusable library and publish it. This is not easily reusable code, and any attempt to make it into a pre-packaged library will result

@terrafied
terrafied / maybe_match.rb
Last active December 16, 2015 20:29
RSpec matcher to allow for possible, not required, conditions
require 'rspec/expectations'
# It would be better if we could change this to pending on the fly, but that happens in a higher scope,
# so there's nothing but "pass" or "fail"
RSpec::Matchers.define :maybe_match do |expected|
match do |actual|
true
end
description do |actual|
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@stan
stan / 1.9.3-p385-falcon
Last active December 12, 2015 12:09
Performance patch for rbenv ruby 1.9.3-p385 (funny-falcon with backport-gc)
build_package_combined_patch() {
local package_name="$1"
{
curl https://github.com/funny-falcon/ruby/compare/p385...p385_falcon_gc.diff | patch -p1
autoconf
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS
make -j 8
make install
} >&4 2>&1