WARNING: be careful what you do with this.
- Create a
scripts
directory in your Rails app root (if it doesn't already exist) and put the script inside
# 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 |
source 'https://rubygems.org' | |
gem 'rake' | |
gem 'lotus-router' | |
gem 'lotus-controller' | |
gem 'lotus-view' | |
group :test do | |
gem 'rspec' | |
gem 'capybara' |
# 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 |
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!
The article that inspired the talk: The Startup Trap.
Mac | |
3N6EAJLH649N | |
M7RM3HYF9HLE | |
KK4TN46LEAPF | |
NKP6K4YFEWTN | |
6NK9L3W3R9M9 | |
E3HW464L77WR | |
RHY9XXNRL793 | |
HWNF6RPXTPY9 | |
W7M373W7KXP7 |
;(function ($) { | |
var $elementsToCatchUp = $(), | |
followBased = false, | |
bound = false; | |
function startCatchingUp($catchup) { | |
$catchup | |
.before($('<div>', | |
{ 'class': 'catching-up-placeholder', 'height': $catchup.outerHeight() })) | |
.addClass('catching-up') |
# Strip leading and trailing bytes | |
def self.decode data, &blk | |
while msg = data.slice!(/\000([^\377]*)\377/) | |
msg.gsub!(/^\x00|\xff$/, '') | |
yield msg | |
end | |
end |
// approach one: simply assign function to prototype | |
// it works, but you still need to use "apply" to make the method | |
// work as needed | |
function smallest1(array){ | |
Array.prototype.min = Math.min; | |
return array.min.apply(array, array); | |
} | |
// approach two: use apply in the function assigned to Array's prototype | |
function smallest2(array){ |
(function($) { | |
function print_array(obj, opts) { | |
var result = []; | |
for (var i = 0; i < Math.min(opts.max_array, obj.length); i++) | |
result.push($.print(obj[i], $.extend({}, opts, { max_array: 3, max_string: 40 }))); | |
if (obj.length > opts.max_array) | |
result.push((obj.length - opts.max_array) + ' more...'); | |
if (result.length == 0) return "[]" |