Skip to content

Instantly share code, notes, and snippets.

@ignacy
ignacy / async_no_link.ex
Created March 15, 2016 10:51
Example of using Task.Supervisor.async_nolink with Elixir Tasks
@fxn
fxn / problem-solving-games.md
Last active June 11, 2023 17:21
Problem-Solving Games
@likethesky
likethesky / elixirphoenix.bash
Last active January 5, 2022 10:00
Installing Elixir & the Phoenix framework with Homebrew on OS X
$ 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: http://www.phoenixframework.org/docs/installation -- currently this is 1.0.3
# ** Answer y to any Qs **
$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v1.0.3/phoenix_new-1.0.3.ez
@afcapel
afcapel / assets.rake
Last active August 29, 2015 14:01
rake assets:precompile_if_needed
# lib/tasks/assets.rake
namespace :assets do
task :precompile_if_needed do
require_relative '../assets_version'
next unless AssetsVersion.needs_precompile?
Rake::Task["assets:precompile"].invoke
AssetsVersion.current.save_to_yaml
end
@wycats
wycats / app.js
Last active February 11, 2016 16:08
App.Router.map(function() {
this.resource('post', { path: '/posts/:post_id' });
});
App.PostRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('post', params.post_id);
}
});
@coryschires
coryschires / moment-timezone-data.js
Created August 14, 2013 22:04
TZInfo mapping between Rails and moment.js
moment.tz.add({
"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
oriolgual / elastic_search_indexer.rb
Created March 22, 2013 11:01
Companion gist for my talk about using ElasticSearch with Ruby.
# 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
klovadis / gist:5170446
Created March 15, 2013 14:59
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v
@mattetti
mattetti / tracepoint_middlware.rb
Created March 6, 2013 06:34
test middleware for Ruby 2.0 logging the method dispatches going on when a request is being handled.
class TracePoint
class Middleware
def initialize(app)
@app = app
end
def call(env)
stats = {}
trace = TracePoint.new(:call) do |tp|
@afcapel
afcapel / how-the-web-works.md
Last active November 15, 2016 21:23
Article for the amazing practicing ruby Tech Writing Clinic. http://elmcitycraftworks.org/post/36678454423/technical-writing-clinic-winter-2013 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