Skip to content

Instantly share code, notes, and snippets.

View jodosha's full-sized avatar

Luca Guidi jodosha

View GitHub Profile
@jodosha
jodosha / 1-session.sh
Created May 31, 2012 12:42 — forked from vjt/1-session.sh
vjt's tmux RVM + ViM IDE setup
#!/bin/sh
#
# IDE Session starter - you should save this script as ~/bin/session, make it
# executable with chmod +x ~/bin/session, and then make a symlink to it for
# every application you want to start.
# E.g. ln -s session ~/bin/members creates a "members" symlink, and when you'll issue
# "members" on the command line this script will:
# Check if a tmux session named "members" exists
@jodosha
jodosha / cookie_jar_fix.gemspec
Created June 20, 2012 07:33
Support cookie jar options for all cookie stores
; Sample stunnel configuration for enabling SSL connections on localhost.
; Find me under /usr/local/etc/stunnel/stunnel.conf
;
; Usage:
; sudo stunnel
setgid = nogroup
pid = /stunnel.pid
[https]
@jodosha
jodosha / variables_string_interpolation.rb
Created November 11, 2013 08:52
Protip on Ruby's variables string interpolation. Coderwall's markdown to syntax highlight is broken right now. https://coderwall.com/p/sk13pa/edit
##
# Protip on Ruby's variables string interpolation.
# Coderwall's markdown to syntax highlight is broken right now.
#
# https://coderwall.com/p/sk13pa/edit
#
@planet = 'World'
puts "Hello, #@planet!" # => "Hello, World!"
@jodosha
jodosha / Gemfile
Last active January 4, 2016 08:19
Example of Lotus::Router usage. It includes integration and unit tests examples. Clone this gist and then run `bash setup.sh` to run the app: `rackup application.rb`.
source 'https://rubygems.org'
gem 'lotus-router'
group :test do
gem 'rspec'
gem 'capybara'
end
@jodosha
jodosha / lotus-sinatra.gemspec
Last active January 4, 2016 19:09
Building Sinatra with Lotus
Gem::Specification.new do |s|
s.name = 'lotus-sinatra'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Luca Guidi'
s.email = '[email protected]'
s.summary = 'Building Sinatra with Lotus'
s.description = 'A step by step guide about how use Lotus to build Sinatra'
s.homepage = 'http://bit.ly/1e4e58T'
s.license = 'MIT'
@jodosha
jodosha / lotus-faq.md
Last active August 29, 2015 13:56
Lotus FAQs

Lotus::Router

Why Lotus::Router uses internally http_router?

Because I consider http_router like an excellent low level adapter. I needed to start with a certain degree of code maturity, and build on top of it the public API that I wanted for Lotus.

Lotus::Utils

What's the purpose of Lotus::Utils?

@jodosha
jodosha / index.html
Last active August 29, 2015 13:56
Limit endless page loading, by wrapping long running functions invocation in a setTimeout. Run with `bash server.sh`.
<!DOCTYPE html>
<html>
<head>
<script>window.PROFILER||(PROFILER={});PROFILER.data={start:(new Date).getTime()}</script>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<title>JS Timeout</title>
</head>
<body>
<div id="loaded"></div>
<div id="long-running"></div>
@jodosha
jodosha / benchmark.rb
Last active August 29, 2015 13:57
Ruby's benchmark for regular expressions: Hash#find vs multiple case statement
#!/usr/bin/env ruby
require 'benchmark'
TIMES = (ENV['TIMES'] || 1_000_000).to_i
ENDPOINT = ->(env) { [200, {}, ['Hello, World!']] }
ROUTES = {
# '/articles(.:format)'
/\A\/articles(?-mix:[\.]*(?<format>[a-z0-9_]*))\z/ => ENDPOINT,
# '/accounts/:account_id/people/:id'
@jodosha
jodosha / Gemfile
Created March 15, 2014 13:22
Rack map vs Lotus::Router performance
source 'https://rubygems.org'
ruby '2.1.1'
gem 'lotus-router' # github: 'lotus/router', branch: 'engine-rewriting'
gem 'puma'