Skip to content

Instantly share code, notes, and snippets.

Avatar

Anderson Dias andersondias

View GitHub Profile
@andersondias
andersondias / script.rb
Last active May 21, 2020
Teste de NFs travadas
View script.rb
ids = %w(6675436 6675449 6675454 6675464 6675483 6675503 7114435 6675537 7114417 7115359 6675520 6675521 6675519 6675532 6675543 6675542 6675558 6675561 6675556 6675572 6675567 6675568 6675600 6675589 6675614 6675608 6675602 7114497 6675626 6675622 7114519 6675638 6675643 6675659 6675665 6675666 7114543 7114556 6675685 6675712 7114629 6675759 6675833 6675775 6675795 6675792 6675845 6675820 6675857 6675823 6675831 6675828 6675856 5090738 6675867 6675882 6675883 6675930 6675885 6675892 6675896 6675926 6675942 6675897 6675899 6675963 6675902 6675967 7114758 6675984 6676020 6675966 6676021 6675928 6675939 6675955 6675983 6675978 6675979 6675990 7114833 7114866 6676042 6676053 7114852 6676047 6676062 6676061 6676074 6676081 7114888 6676098 6676125 6676087 6676100 6676597 6676116 7114890 6676120 7114918); nil
Invoice.where(state: "waiting_order", id: ids).update_all(state: "title_integrated", provider_order_process_id: nil)
Setting.set(:send_invoice_to_mxm_worker_enabled, 'true')
ids.each do |id|
SendInvoiceToMx
@andersondias
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
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.
Gem::Version.new('2.1.15') > Gem::Version.new('1.14.1')
# => true
# It supports any number of minor versions
Gem::Version.new('2.0.0.1') < Gem::Version.new('2.0.1')
# => true
# And it deals with empty strings and nil values
Gem::Version.new('') < Gem::Version.new('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")
system("gitk")
print("Informe qual a tag que será usada nesse release: ")
@andersondias
andersondias / Migration.md
Last active Aug 29, 2015
Updating to Yosemite
View Migration.md

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"
View gitconfig.sh
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 alias.co checkout
git config --global alias.mt mergetool
git config --global color.diff auto
git config --global color.status auto
@andersondias
andersondias / pomodoro.sh
Created Aug 18, 2011
Pomodoro Script for Ubuntu
View pomodoro.sh
# Dependencies: libnotify-bin sox
# Sound file download: http://www.soundjay.com/clock/alarm-clock-1.wav
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
andersondias / Price.java
Created May 21, 2011
An Observer design pattern implementation example based on Ruby's Observable API
View Price.java
import java.util.Random;
public class Price {
private int value;
public Price(int value) {
this.value = value;
}
public int getValue() {
@andersondias
andersondias / install.sh
Created May 12, 2010
Script to install basic apps on ubuntu
View install.sh
# 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
You can’t perform that action at this time.