Skip to content

Instantly share code, notes, and snippets.

View sidonath's full-sized avatar
🐈
Petting cats

Damir Zekic sidonath

🐈
Petting cats
View GitHub Profile
Mac
3N6EAJLH649N
M7RM3HYF9HLE
KK4TN46LEAPF
NKP6K4YFEWTN
6NK9L3W3R9M9
E3HW464L77WR
RHY9XXNRL793
HWNF6RPXTPY9
W7M373W7KXP7
@sidonath
sidonath / aging.md
Last active December 15, 2015 11:38
Resources relevant to the "Prepare your application for the old age" talk given at Sarajevo Ruby Meetup (21 March 2013)

Prepare your application for the old age

Since I didn't have any slides during the talk, here are some resources that cover similar topics and/or were mentioned during the talk itself.

Happy hacking!

Various articles related to the talk

The article that inspired the talk: The Startup Trap.

Heroku Postgresql credentials retriever

WARNING: be careful what you do with this.

Installation

  • Create a scripts directory in your Rails app root (if it doesn't already exist) and put the script inside

Usage

# register services
Application.register :session do
SessionStore.new(store: Application.lookup(:database_store))
end
Application.register :database_store do
# code to initialize database storage for session
end
# inject session service into every action
@sidonath
sidonath / Gemfile
Last active August 29, 2015 13:59 — forked from jodosha/Gemfile
source 'https://rubygems.org'
gem 'rake'
gem 'lotus-router'
gem 'lotus-controller'
gem 'lotus-view'
group :test do
gem 'rspec'
gem 'capybara'
@sidonath
sidonath / flash.rb
Last active August 29, 2015 14:00
An implementation of flash feature on top of Lotus::Action::Session
# A basic Rails-like Flash implementation built upon Lotus::Action::Session.
# Based upon Rack-flash:
# https://github.com/nakajima/rack-flash
module Flash
def self.included(action)
action.class_eval do
# We rely on features provided by Lotus::Action::Session so let's include
# it right here
include Lotus::Action::Session
@sidonath
sidonath / initialize-instance-method-example.rb
Last active August 29, 2015 14:01
Why is it bad to call instance method in initializers
class Logger
def info(*args)
puts(*args)
end
end
class Auditor
def log(action)
puts "Following action was performed: #{action}"
end
class Create
include Lotus::Action
expose :booking, :errors
def call(params)
@booking = Booking.new
# BookingForm validates datetime entered and converts the values into a single Time object
form = BookingForm.new(booking)
# Syncs the form values to the entity
#r "/Users/damir/packages/MathNet.Numerics.3.0.2/lib/net40/MathNet.Numerics.dll";;
#r "/Users/damir/packages/MathNet.Numerics.FSharp.3.0.2/lib/net40/MathNet.Numerics.FSharp.dll";;
open MathNet.Numerics.LinearAlgebra
let splitRows (matrix:string) =
matrix.Split([|'\n'|])
|> List.ofArray
let parseRow (row:string) =
lines = [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Sed vitae sapien dignissim, volutpat leo consectetur, iaculis magna.",
"In quis lacus tincidunt, vehicula ipsum in, euismod elit.",
"Quisque a elit in odio consequat mattis.",
"Fusce condimentum eros in mauris pharetra, vel accumsan mi vehicula.",
"Phasellus tincidunt neque eget lobortis fringilla.",
"In sit amet mi ut turpis dapibus commodo.",
"Sed non tellus non libero hendrerit iaculis.",
"Ut dictum dolor nec lectus cursus, at eleifend urna varius.",