Skip to content

Instantly share code, notes, and snippets.

View jonathanccalixto's full-sized avatar

Jonathan C. Calixto jonathanccalixto

  • Yanotec Sistemas e serviços
  • Belo Horizonte, MG, BR
View GitHub Profile
@jonathanccalixto
jonathanccalixto / usuario_convenio.rb
Last active August 26, 2016 00:56
Um exemplo simples de utilização de um FormObject
class UsuarioConvenio
include ActiveModel::Modelze
attr_accessor :id, :nome, :senha, :estabelecimento_id
validates :nome, :email, :senha, :estabelecimento, presence: true
validate :garantindo_que_o_estabelecimento_eh_de_um_convenio_valido
def self.create(params)
object = new(params)
@jonathanccalixto
jonathanccalixto / backbone.handlebars.adapter.js
Created June 5, 2016 02:24
A shim to use Handlebars in Backbone template.
Backbone.Marionette.Renderer.render = function (template, data) {
if (_.isObject(template) && template.type === "handlebars") {
return template.template(_.extend(data, template.data), template.options);
}
return template(data);
};
@jonathanccalixto
jonathanccalixto / radio.shim.js
Created June 5, 2016 00:44
A shim to replace Backbone.Wreqr with Backbone.Radio in Marionette. Requires Marionette v2.1+
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(['backbone.marionette', 'backbone.radio', 'underscore'], function(Marionette, Radio, _) {
return factory(Marionette, Radio, _);
});
}
else if (typeof exports !== 'undefined') {
var Marionette = require('backbone.marionette');
var Radio = require('backbone.radio');
var _ = require('underscore');
@jonathanccalixto
jonathanccalixto / gist:133175320a1ed2d44890
Created March 28, 2015 12:23
Install Rbenv on Ubuntu
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
#!/bin/bash
set -e
set -x
provision_command="wget -O- https://gist.github.com/sobrinho/4774041 | sh"
ssh root@server1 "$provision_command"
ssh root@server2 "$provision_command"

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@jonathanccalixto
jonathanccalixto / email.php
Created October 30, 2014 00:04
Configuração de email na kinghost
<?
class Email{
private $serverConfig;
private $errors;
private $log;
public function __construct ($serverConfig = array()) {
$this->serverConfig = array_merge_recursive(array(
"host" => "smtp.seuapp.com.br",
"port" => "25",

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
# .railsrc for Rails 3, encoding: utf-8
# see http://rbjl.net/49-railsrc-rails-console-snippets
if !Rails.application then warn "Rails isn't loaded, yet... skipping .railsrc" else
# # #
def ripl?; defined?(Ripl) && Ripl.instance_variable_get(:@shell); end
# # #
# loggers
module FactoryGirl
module Strategy
class Cache
def association(runner)
runner.run(:cache)
end
def result(evaluation)
repository.read(evaluation) || repository.store(evaluation)
end