Skip to content

Instantly share code, notes, and snippets.

View orend's full-sized avatar

Oren Dobzinski orend

View GitHub Profile
# I don't really see any services here. What I see is:
# - Normal HTTP boundary stuff (params flash, redirect).
# - Model creation and retrieval.
# - Warden manipulation, which is an odd done but smells like boundary.
#
# I left all of the HTTP boundary stuff in the controller (and only the
# controller). I moved the model creation/retrieval into simple class methods
# in the models. I moved the warden manipulation stuff into
# ApplicationController (with caveats that I'll discuss inline).
#
@maxim
maxim / rails_load_path_tips.md
Last active January 9, 2025 00:59
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@atmos
atmos / heaven.md
Last active November 23, 2020 22:35
Response to a dude who asked about heaven. https://github.com/holman/feedback/issues/422

@holman got a request about our deployment system, heaven

I know it's not a high priority, but has there been any activity on open-sourcing the core Heaven gem?

There is. I've been working on extracting the non-GitHub specific parts into two gems. This first is a CLI portion called hades. The second is an HTTP API portion called heaven.

When you open source something previously used as in internal tool like Heaven, Hubot, Boxen, etc., how do you manage and hook in the parts that need to stay internal?

Normally I focus around four questions:

@bgswan
bgswan / mailing_list_spec.rb
Last active December 24, 2015 15:19
Alternative version of test described here http://re-factor.com/blog/2013/09/27/slow-tests-are-the-symptom-not-the-cause/ using domain model rather than "service object"
describe MailingList do
let(:notifications) { double('notifications') }
let(:user) { User.new }
it 'registers a new user' do
expect(notifications).to receive(:call).with(user, 'list_name')
mailing_list = MailingList.new('list_name', notifications)
mailing_list.add(user)
@jhrr
jhrr / Functional Core, Imperative Shell
Last active January 8, 2018 16:11
Notes and links for ideas about Gary Bernhardt's "functional core, imperative shell"
http://www.infoq.com/presentations/Simple-Made-Easy
http://www.infoq.com/presentations/integration-tests-scam
http://blog.thecodewhisperer.com/2010/09/14/when-is-it-safe-to-introduce-test-doubles
http://youtu.be/yTkzNHF6rMs
http://pyvideo.org/video/1670/boundaries
http://skillsmatter.com/podcast/ajax-ria/enumerators
http://alistair.cockburn.us/Hexagonal+architecture
http://c2.com/cgi/wiki?PortsAndAdaptersArchitecture
http://www.confreaks.com/videos/977-goruco2012-hexagonal-rails
http://www.confreaks.com/videos/1255-rockymtnruby2012-to-mock-or-not-to-mock
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active December 30, 2025 11:27
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end

Let me explain what we're trying to do, which may be crazy. But if it's not crazy, perhaps someone can tell us how to use AMQP to do it.

We have a Rails app that talks to a growing number of backend Clojure services.

It could talk to them via HTTP, but many of the messages don't need to be synchronous. They're "fire and forget". Hence AMQP.

For the synchronous messages, we observed two things:

  • Serializing and deserializing HTTP is surprisingly annoying, especially given Rails conventions.

  • Most of the time when we send a message that updates a resource, we don't need a synchronous acknowledgement right away. We only need to know that the update has happened at some point before we next read the resource.

@thatrubylove
thatrubylove / gol.rb
Last active August 29, 2015 14:01
Functional Game of Life (spike)
require 'curses'
module Seeder
extend self
def generate_matrix
rand(40..200).times.map { [rand(24), rand(48)] }
end
end
class Universe