Skip to content

Instantly share code, notes, and snippets.

Anderson Dias andersondias

Block or report user

Report or block andersondias

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
andersondias / ordering.sql
Last active Jan 6, 2016
Ordering by nulls on Postgres
View ordering.sql
-- Default order will return NULL values at
-- the end of list
SELECT value FROM example ORDER BY value;
-- value --
-- 1 --
-- 2 --
-- 3 --
-- NULL --
andersondias / compare.rb
Last active Dec 28, 2018
How to compare version strings in Ruby
View compare.rb
# Compares if a version is greater than other.'2.1.15') >'1.14.1')
# => true
# It supports any number of minor versions'') <'2.0.1')
# => true
# And it deals with empty strings and nil values'') <'2.0.1')
View git-release
#!/usr/bin/env ruby
# usage: git-release branch-name-1 branch-name-2 origin/remote-branch-name-3
branchs = ARGV[0..-1]
abort unless system("git checkout master")
abort unless system("git pull")
abort unless system("git remote prune origin")
print("Informe qual a tag que será usada nesse release: ")
andersondias /
Last active Aug 29, 2015
Updating to Yosemite

These are the steps I needed to take after installing Yosemite

  1. Java JDK error

The first error I've catch was an error in Java JDK. A popup was shown with this message: "To view this web content, you need to install the Java Runtime Environment."

Java error popup

In order to fix this, you need to install the latest Java 8 JDK.

View test_helper_lite.rb
require "bundler"
Bundler.setup(:default, :test)
require "active_record"
require "active_support"
git config --global alias.s status
git config --global alias.a add
git config --global alias.d diff
git config --global alias.g grep
git config --global alias.b branch
git config --global alias.c commit
git config --global checkout
git config --global mergetool
git config --global color.diff auto
git config --global color.status auto
andersondias /
Created Aug 18, 2011
Pomodoro Script for Ubuntu
# Dependencies: libnotify-bin sox
# Sound file download:
DISPLAY=:0 notify-send -t 1000 -i ~/Pictures/icons/pomodoro.png "New Pomodoro starts" "You have 45 minutes to work."
while true; do
sleep 2700 # 45 minutes
DISPLAY=:0 notify-send -t 1000 -i ~/Pictures/icons/pomodoro.png "Pomodoro ends" "Take a break for 15 minutes!"
play ~/Music/effects/alarm-clock-1.wav
sleep 900 # 15 minutes
DISPLAY=:0 notify-send -t 1000 -i ~/Pictures/icons/pomodoro.png "New Pomodoro starts" "You have 45 minutes to work."
play ~/Music/effects/alarm-clock-1.wav
andersondias /
Created May 21, 2011
An Observer design pattern implementation example based on Ruby's Observable API
import java.util.Random;
public class Price {
private int value;
public Price(int value) {
this.value = value;
public int getValue() {
andersondias /
Created May 12, 2010
Script to install basic apps on ubuntu
# Utils
sudo apt-get install htop
sudo apt-get install gnome-do
sudo apt-get install exuberant-ctags ncurses-term
sudo apt-get install vim-gnome
sudo apt-get install inkscape
sudo apt-get install sun-java6-jdk
sudo apt-get install compizconfig-settings-manager
sudo apt-get install ubuntu-restricted-extras
andersondias / gist:311138
Created Feb 22, 2010
Basics of scope_by_attribute plugin
View gist:311138
module ScopeByAttribute
def self.included(base)
base.send(:extend, ScopeByAttribute::ClassMethods)
module ClassMethods
def scope_by_attribute(attribute)
@scoped_attributes ||= []
@scoped_attributes << attribute.to_sym
You can’t perform that action at this time.