Skip to content

Instantly share code, notes, and snippets.

View adriancuadros's full-sized avatar

Adrian Cuadros adriancuadros

View GitHub Profile
@adriancuadros
adriancuadros / hsmty1_7.erb
Last active August 29, 2015 14:21
HackerSchool 1-7 Solution (Rack)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="./read.css">
<title>Best gags</title>
</head>
<body>
@adriancuadros
adriancuadros / simpleredis.rb
Last active August 29, 2015 14:16
Simple Redis Hash <=> Ruby Object Interface
require 'redis'
require 'active_support'
require 'active_support/core_ext'
module RedisHash
delegate :redis, :redis_base, to: :class
def self.included(base)
base.extend ClassMethods
@adriancuadros
adriancuadros / bash_profile
Created January 6, 2014 18:47
bash_profile
alias profile='subl ~/.bash_profile'
alias code='cd ~/Code'
alias reserbus='cd ~/Code/innku/reserbus'
alias b='bundle exec'
alias r='rails'
alias co='git checkout'
alias pow='cd ~/.pow'
alias debug='bundle exec rdebug-c'
homebrew=/usr/local/bin:/usr/local/sbin
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
now=`date +%s`;
last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return;
seconds_since_last_commit=$((now-last_commit));
minutes_since_last_commit=$((seconds_since_last_commit/60));

Where is the app?

This are different examples of doing the same thing, "mark a notification as read", and the pros and cons that I see in each example

1. - Logic in the model

  • The user clicks the notification link
  • The system POSTs to the action "notifications/:id/mark_as_read"
  • The controller calls the method Notification#mark_as_read
  • The model updates the attribute "read" saves the Notification record
@adriancuadros
adriancuadros / chef_solo_bootstrap.sh
Last active October 7, 2015 17:48 — forked from ryanb/chef_solo_bootstrap.sh
Bootstrap Chef Solo
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6 libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xvzf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247/
./configure --prefix=/usr/local
make
make install