Skip to content

Instantly share code, notes, and snippets.

@mariochavez
mariochavez / my_app.ex
Created September 29, 2017 18:50 — forked from alanpeabody/my_app.ex
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@mariochavez
mariochavez / after.rb
Created March 25, 2017 04:20 — forked from mperham/after.rb
Thread-friendly shared connection
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@mariochavez
mariochavez / migration.md
Created February 6, 2017 17:30
RSpec to Minitest

These are the scripts that I used to migrate from RSpec to Minitest in a Rails aplication.

It is expected for the test suite to be in RSpec 3.x sintax.

  1. Install rename library from Homebrew
  2. Remove RSpec/TestUnit from Gemfile
  3. Add minitest-rails gem
  4. Rename spec forder to test
  5. Add a test_helper.rb file
@mariochavez
mariochavez / info.md
Created October 28, 2016 17:31
Postgresql
@mariochavez
mariochavez / GIF-Screencast-OSX.md
Created September 13, 2016 20:47 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@mariochavez
mariochavez / ml-ruby.md
Created May 13, 2016 19:06 — forked from gbuesing/ml-ruby.md
Resources for Machine Learning in Ruby

Resources for Machine Learning in Ruby

Gems

To circle.yml:
dependencies:
post:
- bin/cisetup
checkout:
post:
- git fetch origin --depth=1000000
@mariochavez
mariochavez / rails_load_path_tips.md
Created December 29, 2015 00:27 — forked from maxim/rails_load_path_tips.md
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/

@mariochavez
mariochavez / page_speed.md
Created September 28, 2015 20:09
Page Speed

Obelish,

Para mejorar la velocidad de descarga y render de tu sitio tengo los siguientes comentarios:

gzip css/js

No sé que versión de Ruby on Rails estas usando, pero a partir de la versión 4.2 sprockets ya no comprime y crea los archivos gzip. Sé que desde nginx puedes hacer compresión on the fly para lo cuál puedes usar la siguiente guía. Configure ngnix gzip compresion

Si usas una versión anterior a Rails 4.2 y cuando ejecutas rake assets:precompile si se crean los archivos gzip, entonces