Skip to content

Instantly share code, notes, and snippets.

likethesky / elixirphoenix.bash
Last active Jul 14, 2021
Installing Elixir & the Phoenix framework with Homebrew on OS X
View elixirphoenix.bash
$ brew update && brew doctor # Repeat, until you've done *all* the Dr. has ordered!
$ brew install postgresql # You'll need postgres to do this... you may also need to 'initdb' as well. Google it.
$ brew install elixir
$ mix local.hex # Answer y to any Qs
$ createuser -d postgres # create the default 'postgres' user that Chris McCord seems to like -- I don't create mine w/a pw...
# Use the latest Phoenix from here: -- currently this is 1.0.3
# ** Answer y to any Qs **
$ mix archive.install
afcapel / assets.rake
Last active Aug 29, 2015
rake assets:precompile_if_needed
View assets.rake
# lib/tasks/assets.rake
namespace :assets do
task :precompile_if_needed do
require_relative '../assets_version'
next unless AssetsVersion.needs_precompile?
View app.js {
this.resource('post', { path: '/posts/:post_id' });
App.PostRoute = Ember.Route.extend({
model: function(params) {
return'post', params.post_id);
coryschires / moment-timezone-data.js
Created Aug 14, 2013
TZInfo mapping between Rails and moment.js
View moment-timezone-data.js{
"zones": {
"Africa/Algiers": [
"0:12:12 - LMT 1891_2_15_0_1 0:12:12",
"0:9:21 - PMT 1911_2_11 0:9:21",
"0 Algeria WE%sT 1940_1_25_2",
"1 Algeria CE%sT 1946_9_7 1",
"0 - WET 1956_0_29",
"1 - CET 1963_3_14 1",
"0 Algeria WE%sT 1977_9_21 1",
oriolgual / elastic_search_indexer.rb
Created Mar 22, 2013
Companion gist for my talk about using ElasticSearch with Ruby.
View elastic_search_indexer.rb
# Public: A module to be mixed in another class with common methods to index
# records in ElasticSearch.
# The host object needs to respond to 'indexed_attributes', which will return
# an array of the attributes names to be indexed.
# It's also recommended to override the 'save?' method to make sure only
# records that match some specifications are indexed.
# The type used for the ElasticSearch index will be extracted from the name of
klovadis / gist:5170446
Created Mar 15, 2013
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
View gist:5170446
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk ='HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
result[nextkey] = v
mattetti / tracepoint_middlware.rb
Created Mar 6, 2013
test middleware for Ruby 2.0 logging the method dispatches going on when a request is being handled.
View tracepoint_middlware.rb
class TracePoint
class Middleware
def initialize(app)
@app = app
def call(env)
stats = {}
trace = do |tp|
afcapel /
Last active Nov 15, 2016
Article for the amazing practicing ruby Tech Writing Clinic. One assignment was to write an article explaining a technical concept to non technical readers. Here is my article.

My job, explained so my mom can understand it

"I am a freelance Ruby and Rails developer". When I talk with my geek friends, everyone understands what I do and they have a reasonable understanding of how I spend my day. But sometimes, less technical people ask me what I do for a living and then I tend to dumb down the answer: "I am a programmer, I usually build websites.". Oh -they say- my nephew also make websites, he even built me a blog in Blogger.

Err... yes, but that hardly has anything to do with what I do for a living.

There are many different kinds of websites, built with different technologies, and depending on the site and the technology used to build it, they are made by one kind of professional or another. The craft of building a website comprises many different disciplines, and professionals usually specialize in just one part of the process. Although I do many different things, my specialization is mainly programming dynamic websites using Ruby and Rails.

In this article I want to

martijnvg /
Created Jan 28, 2013
Nested type and nested facets
curl -s -XPUT 'localhost:9200/test1' -d '{
"mappings" : {
"records" : {
"properties" : {
"coords" : {
"type" : "nested",
"properties" : {
jbgo /
Created Jan 9, 2013
debug SystemStackError in ruby 1.9

This is how I debug SystemStackError when there is no stack trace.

My first attempt was:

rescue SystemStackError
  puts caller