Skip to content

Instantly share code, notes, and snippets.

@kaelig
kaelig / Gemfile
Created September 7, 2011 00:20
Sass & CoffeeScript automated compiling and minifying with Guard
source "http://rubygems.org"
group :development do
gem 'rake'
gem 'guard'
gem 'coffee-script'
gem 'rb-fsevent'
gem 'rb-inotify'
gem 'compass', '0.11.5'
gem 'sass', '3.1.5'
gem 'guard-compass'
@wtaysom
wtaysom / where_is.rb
Created September 23, 2011 08:57
A little Ruby module for finding the source location where class and methods are defined.
module Where
class <<self
attr_accessor :editor
def is_proc(proc)
source_location(proc)
end
def is_method(klass, method_name)
source_location(klass.method(method_name))
@tankchintan
tankchintan / gist:1335220
Last active November 30, 2019 00:17
Procedure for installing and setting Sun JDK Java on Default Amazon Linux AMI
# First verify the version of Java being used is not SunJSK.
java -version
# Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html
wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.rpm
# Rename the file downloaded, just to be nice
mv jdk-7u1-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u1-linux-i586.rpm
# Install Java
# [Mon Jan 16 11:23:14 2012] Protocol: http, Server: 192.168.5.10:9200
curl -XPUT 'http://127.0.0.1:9200/users/?pretty=1' -d '
{
"mappings" : {
"info" : {
"_all" : {
"type" : "string",
"analyzer" : "uax_url_email"
},
"properties" : {
@ruckus
ruckus / gist:2293434
Created April 3, 2012 16:36
Basic setup of WAL-E for continuous archiving and recovery

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
@simoncoulton
simoncoulton / nginx-uwsgi-python3
Created May 7, 2012 04:39
Setting up Nginx, uWSGI & Python3
======================================
Setting up Nginx, uWSGI and Python3
======================================
First off, I'm traditionally a PHP developer, but am looking at moving across to Python. I really struggled to find decent documentation on how to get a server up and running for deploying Python web applications from the point of view of someone coming from PHP. The main problems I came across with documentation were:
1) Only showed you how to run the server for a single web application.
2) Only showed you how to configure the app, not the server it was running on.
My preferred workflow for development is by setting up a new VM in VMware Fusion and then forwarding through all requests to that VM via /etc/hosts. This might not be the optimal way to get things up and running, but it works for me.
@roberto
roberto / _flash_messages.html.erb
Created August 13, 2012 22:47
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@ryandotsmith
ryandotsmith / agg.sql
Created January 23, 2013 05:19
Postgres array concatenation aggregate function.
CREATE AGGREGATE array_accum (anyarray)
(
sfunc = array_cat,
stype = anyarray,
initcond = '{}'
);
@maxim
maxim / rails_load_path_tips.md
Last active April 13, 2023 13:28
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/

@suryart
suryart / application.html.erb
Last active October 26, 2023 00:16
Rails 4 flash messages using Twitter Bootstrap(bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass). An improved version of https://gist.github.com/roberto/3344628
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>