Skip to content

Instantly share code, notes, and snippets.

View jtomaszewski's full-sized avatar

Jacek Tomaszewski jtomaszewski

View GitHub Profile
@nragaz
nragaz / unicorn.rb
Created July 12, 2010 03:34
unicorn.rb
# unicorn_rails -c /srv/myapp/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
working_directory (rails_env == 'production' ? "/srv/myapp/current" : `pwd`.gsub("\n", ""))
worker_processes (rails_env == 'production' ? 10 : 4)
preload_app true
timeout 30
if rails_env == 'production'
@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@jasoncodes
jasoncodes / _form.html.haml
Created October 18, 2011 05:42
Using ActiveRecord optimistic locking with Inherited Resources
/ ...
- f.inputs do
= f.hidden_field :lock_version
/ ...
@oodavid
oodavid / README.md
Last active February 27, 2024 12:44 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@maxim
maxim / spec_helper.rb
Created June 9, 2012 18:14
Making after_commit play nice with use_transactional_fixtures.
# This is an example of how to use database_cleaner gem and
# RSpec tags to make `after_commit` hook play nice with
# `use_transactional_fixtures`.
# Simply mark the specs that use after_commit with
# `:uses_after_commit` tag.
# ...
require 'database_cleaner'
@robertjwhitney
robertjwhitney / activeadmin_sortable.js.coffee
Created July 3, 2012 03:37
Simple drag/drop reordering of records in an ActiveAdmin view table
# http://stackoverflow.com/a/8936202
#
# ActiveAdmin already includes the necessary jquery in active_admin/base,
# so just add this to javascripts/active_admin.js after //= require active_admin/base
#
#
# Serialize and Sort
#
# model_name - you guessed it, the name of the model we are calling sort on.
# This is the actual variable name, no need to change it.
@slindberg
slindberg / convert_charset
Created September 26, 2012 19:42
Bash script for converting the charset of all tables in a database
#!/bin/bash
# Convert all tables in a specified database to a different charset
#
# NOTE: this will NOT preserve data if it was stored improperly to begin with,
# e.g. UTF8 encoded strings saved as latin1 charset will get munged by this
# script when the table is converted. To preserve data you must export it, change
# the charset, then re-import.
#
# Command taken from:
@alexjs
alexjs / cors-nginx.conf
Created November 28, 2012 22:42 — forked from michiel/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@nicjansma
nicjansma / ie89-console-apply-support.js
Created January 29, 2013 17:42
Adds .apply() and .call() support to IE8/9's console object, which treates .log()/etc as Objects and not Functions. Requires jQuery for $.each().
if (Function.prototype.bind && typeof console == "object" && typeof console.log == "object") {
var logFns = ["log", "info", "warn", "error", "assert", "dir", "clear", "profile", "profileEnd"];
$.each(logFns, function (i, method) {
console[method] = Function.prototype.call.bind(console[method], console);
});
}