Skip to content

Instantly share code, notes, and snippets.

View joho's full-sized avatar
At harbour

John Barton joho

At harbour
View GitHub Profile
@mtcmorris
mtcmorris / gist:3082609
Created July 10, 2012 10:42
20 top films in the past 5 years
The Artist
Senna
Hanna
Headhunters (Hodejegerne)
The Help
Best Exotic Marigold Hotel
District 9
Crazy Stupid Love
The Social Network
Black Swan
@joho
joho / deploy.rb
Created September 13, 2012 01:30
How to serve emergency "signed out" views from page cache without affecting signed in users in rails.
set :path_to_repo, "/path_to_repo/"
set :running_app_user, "appusername"
namespace :webscale do
desc "Cache a signed out version of the path. Usage: cap webscale:signed_out_cache_page -s path_to_cache=/films/on_netflix"
task :signed_out_cache, roles: :app do
cache_base_path = "#{path_to_repo}/public/signed_out"
cached_destination_path = "#{cache_base_path}#{path_to_cache}.html"
working_path = "#{cached_destination_path}.tmp"
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 3, 2024 09:24
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active May 31, 2024 18:32
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@toolmantim
toolmantim / Makefile
Last active December 5, 2022 23:14
An example of using Make instead of Grunt for fast, simple and maintainable front-end asset compilation.
# A simple Makefile alternative to using Grunt for your static asset compilation
#
## Usage
#
# $ npm install
#
# And then you can run various commands:
#
# $ make # compile files that need compiling
# $ make clean all # remove target files and recompile from scratch
@bmizerany
bmizerany / http.go
Last active December 22, 2015 16:39
Graceful shutdown example in regards to https://groups.google.com/forum/#!topic/golang-nuts/vLHWa5sHnCE
package main
func main() {
// ... setup ...
l, err := net.Listen("tcp", *laddr)
if err != nil {
log.Fatal(err)
}
@benhoskings
benhoskings / gist:7192000
Created October 28, 2013 05:59
sublime config.py
{
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 30,
"bold_folder_labels": true,
"caret_style": "wide",
"color_scheme": "Packages/User/Ben's Solarized (light).tmTheme",
"detect_indentation": false,
"detect_slow_plugins": false,
"dictionary": "Packages/Language - English/en_GB.dic",
"drag_text": false,
@lox
lox / soa_thoughts.md
Last active December 28, 2015 10:49
Thinking on SOA

Aggregating multiple top-level web applications

Ideally we'd be able to compose 99designs.com out of several top-level web applications. There are many challenges with this, for instance:

  • How do we manage routing and route generation, cross-application?
  • How do we manage sessions without shared db access?
  • How do we handle shared UI like alert bars and unified headers?

On the whole, these problems are solvable. For routing we could just use Varnish, with some custom code to read routemaps from the apps, or we could use something like Mongrel2. Alternately, a Go-lang HTTP/SPDY terminator would be pretty damn quick and flexible.

@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).
@hughevans
hughevans / Procfile
Last active December 31, 2015 02:39
web: bundle exec puma -p $PORT -C config/puma.rb