Skip to content

Instantly share code, notes, and snippets.

View squiter's full-sized avatar

Brunno dos Santos squiter

View GitHub Profile
@squiter
squiter / example.rb
Created October 4, 2012 13:03
Exemplos de aplicação para o Helder
# encoding: utf-8
class User < AcriveRecord::Base
has_many :suggestions
end
class Product < AcriveRecord::Base
has_many :suggestions
end
class Suggestion < AcriveRecord::Base
gistsource 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'mysql2'
gem 'devise'
gem 'devise-i18n'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
@squiter
squiter / Gemfile
Created April 19, 2013 14:02
Changed to work with Zeus
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'mysql2'
gem 'devise'
gem 'devise-i18n'
group :assets do
gem 'sass-rails', '~> 3.2.3'
@squiter
squiter / gist:5462091
Created April 25, 2013 18:46
Your friend is a gay? Spam him with this AppleScript to send multiple messages to your gay friend using Adium! Remeber to export this script as App :P
tell application "Adium"
set eu to "[email protected]"
set gay to text returned of ¬
(display dialog ¬
"Quem é o Gay?" with title ¬
"Putz! Que viadão!" with icon stop ¬
default answer ¬
"" buttons {"Vai…"} ¬
default button 1)
tell account eu to set theChat to make new chat with contacts {contact gay} with new chat window
@squiter
squiter / _flash_render.html.erb
Last active June 8, 2018 05:07 — forked from potomak/_flash.html.erb
Little snippet to render flash messages using twitter bootstrap in Rails.
<% [:notice, :error, :alert].each do |level| %>
<% unless flash[level].blank? %>
<div class="alert <%= flash_class(level) %>">
<a class="close" href="#">×</a>
<%= content_tag :p, flash[level] %>
</div>
<% end %>
<% end %>
@squiter
squiter / followings.rb
Created February 5, 2014 21:27
Followers in Rails
class Followings < ActiveRecord::Base
attr_accessible :user_id, :follower_id
belongs_to :user
belongs_to :follower, class_name: 'User'
belongs_to :following, class_name: 'User', foreign_key: :user_id
validates_uniqueness_of :user_id, scope: :follower_id
end
@squiter
squiter / gist:cf4e474b8b51251c5085
Created April 22, 2015 01:47
Mod 11 - Módulo 11
def mod11(number, total)
as_string = number.to_s
sub = as_string.length
value = 0
max = total
sub.times do |t|
value += as_string[t].to_i * max
max = max - 1
end
@squiter
squiter / notifications.md
Last active March 21, 2021 13:30
Adding desktop notifications to your org-mode

This script is for OSX only! ;)

First install terminal-notifier app:

brew install terminal-notifier

After that, using this awesome scritp with some customizations in your .emacs.

@squiter
squiter / postgres_queries_and_commands.sql
Created July 11, 2016 14:36 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@squiter
squiter / install_ruby
Created October 7, 2016 22:26
How to install ruby with TCL and TK for Coursera Programming Languages Part C
#!/bin/bash
set -eou pipefail
version=8.6.4.1
patchinfo=299124-linux-x86_64-threaded
dir=ActiveTcl$version.$patchinfo
package=$dir.tar.gz
url=http://downloads.activestate.com/ActiveTcl/releases/$version/$package