Skip to content

Instantly share code, notes, and snippets.

View jodosha's full-sized avatar

Luca Guidi jodosha

View GitHub Profile
@kachayev
kachayev / concurrency-in-go.md
Last active January 6, 2025 22:43
Channels Are Not Enough or Why Pipelining Is Not That Easy
@arthurgeek
arthurgeek / lotus.patch
Created August 19, 2014 20:14
Lotus Patch 2
diff --git a/lib/lotus/loader.rb b/lib/lotus/loader.rb
index e038d7f..9221840 100644
--- a/lib/lotus/loader.rb
+++ b/lib/lotus/loader.rb
@@ -23,7 +23,6 @@ module Lotus
load_configuration!
load_frameworks!
load_application!
- finalize!
end
@runlevel5
runlevel5 / gist:76a0535c88c06f753d9a
Last active August 29, 2015 14:02
Generate sdoc of lotus
git clone [email protected]:lotus/lotus.git
git clone [email protected]:lotus/model.git
git clone [email protected]:lotus/controller.git
git clone [email protected]:lotus/view.git
git clone [email protected]:lotus/router.git
git clone [email protected]:lotus/helpers.git
git clone [email protected]:lotus/utils.git
sdoc -o doc/lotus -T direct --exclude="CHANGELOG.md" --exclude="LICENSE.txt" --exclude="LICENSE.md" --exclude="CONTRIBUTING.md" --exclude="test" --exclude="Gemfile*" --exclude=".*gemspec" --exclude="Rakefile" --no-dry-run -t lotus -a lotus
sdoc -o doc/model -T direct --exclude="CHANGELOG.md" --exclude="LICENSE.txt" --exclude="LICENSE.md" --exclude="CONTRIBUTING.md" --exclude="test" --exclude="Gemfile*" --exclude=".*gemspec" --exclude="Rakefile" model
# 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
require 'rubygems'
require 'redis'
r = Redis.new
r.config("SET","maxmemory","2000000")
r.config("SET","maxmemory-policy","allkeys-lru")
r.config("SET","maxmemory-samples",1000)
r.config("RESETSTAT")
r.flushall
###
# Execute tests in parallel using multiple processes. Uses DRb to communicate
# between processes over a unix socket.
gem 'minitest', '~> 5.1.0'
require 'minitest'
require 'minitest/spec'
require 'minitest/mock'
require 'drb'
require 'drb/unix'
@mattetti
mattetti / rails_json_session.rb
Last active September 23, 2020 07:04
This is a monkey patch to change Rails 4's default session/signed cookie serializer from Marshal to JSON for security and compatibility reasons. Note that this is a hack, a pretty terrible one and you should only use it if you know what you're doing. Also, I only wrote this patch for my own personal use, so don't be surprised if it doesn't work …
# Hack to change the Rails cookie serializer from Marshal to JSON and therefore allow the session
# to be shared between different languages but also avoid that someone knowing the
# cookie secret key could execute arbitrary code on the server by unmarshalling
# modified Ruby code added to the session/permanent cookie.
#
# Note that all users will beed to login again since both the remember me cookie and the session cookies
# won't be valid. Note also that the remember me cookie is tested multiple times per request even when it fails.
# for performance reasons you might want to delete it if these extra cycles are too costly for you.
#
# Rails 4 (not tested on Rails 3).
require 'action_dispatch/middleware/session/redis_store'
module ActionDispatch
module Session
class SignedRedisStore < ActionDispatch::Session::RedisStore
def load_session(env)
stale_session_check! do
get_session(env,
cookie_jar(env)[@key]
)
@plentz
plentz / nginx.conf
Last active April 19, 2025 04:46
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@justincarroll
justincarroll / bootstrap-masonry-template.htm
Last active August 15, 2020 16:48
This is my template for using Masonry 3 with Bootstrap 3. For those of you who follow this gist a lot has changed since Bootstrap 2.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap Masonry Template</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700">