Skip to content

Instantly share code, notes, and snippets.

View LeoNogueira's full-sized avatar

Leonardo Nogueira LeoNogueira

View GitHub Profile
@joshnuss
joshnuss / checkout.exs
Last active August 6, 2017 01:08
High speed e-commerce checkout using Elixir & Task.async
# Parallel Checkout
# --------------------------------------------------------------
# Example of performance gained by using a parallel checkout in an e-commerce store,
#
# to run 500 checkouts in series: time elixir checkout.exs 500 serial
# to run 500 checkouts in parallel: time elixir checkout.exs 500 parallel
#
# Typical E-commerce checkout flow uses a bunch of network bound tasks, that are generally
# computed synchronously. This wastes time and requires larger server clusters to handle peak times
#
@voter101
voter101 / Gulpfile.js
Last active November 29, 2021 01:17
Gulpfile for Rails application with replaced Sprockets with Gulp
'use strict'
var gulp, sass, babelify, browserify, watchify, source, util;
gulp = require('gulp');
sass = require('gulp-sass');
babelify = require('babelify')
browserify = require('browserify');
watchify = require('watchify');
source = require('vinyl-source-stream');
@avdgaag
avdgaag / gist:c66ad5868d8e699dd639
Last active September 22, 2015 11:56
Example setup API for ROM::Lotus
# Lotus has different applications in a single project, optionally with different configurations and/or mappings.
# ROM::Lotus should/could conigure a different setup per application, rather than a single global setup.
# Relations could be global (defined in ./lib) while mappings might live in both (./apps/web/ and ./lib).
# This would resemble how Lotus::Model is organised.
#
# The only problem here is that Lotus has no hooks for loading framework (it's all hard-coded)s, and
# therefore we can't easily extend the application load process with our custom setup code without
# resorting to monkeypatching.
# apps/web/application.rb
@eccegordo
eccegordo / intro-to-ember-cli-node.md
Created March 21, 2015 11:14
Introduction to Ember CLI, Node and NPM

Introduction To Node, NPM and Ember CLI

This guide is for developers who are new Node, NPM, and Ember CLI. This guide is designed to get you started with ember cli development and provide some general background info on what Node is and how it works with Ember CLI.

Overview

  • What is Node?
  • What is NPM?
  • How do I setup my environment if I don't have node js or npm installed?
  • I accidently installed something wrong how can I start over?

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

Polymorphism

Sometimes relationships need to be flexible, and that's where we look to polymorphism. Say we want to implement:

  • A Person
  • A Company
  • A PhoneNumber that can connect to a Person or a Company

At the Database Level

@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@zapnap
zapnap / iam_fog.rb
Created March 2, 2011 20:24
Using Amazon IAM with Fog (example)
require 'fog'
username = 'testuser'
bucket = 'uniquebucketname1234'
aws_credentials = {
:aws_access_key_id => 'YOUR-ACCESS-KEY-ID',
:aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY'
}
@fnando
fnando / token.rb
Created November 10, 2010 02:10
Generate readable tokens
class Token
VOWELS = %w[a e i o u]
CONSONANTS = ("a".."z").to_a - VOWELS
NUMBERS = (0..9).to_a
def self.readable(size = 12)
String.new.tap do |s|
half = size / 2
1.upto(size) do |i|
@lucashungaro
lucashungaro / links.textile
Created August 14, 2010 16:36
Links de referência utilizados em minha palestra