Skip to content

Instantly share code, notes, and snippets.

View anchietajunior's full-sized avatar
💭
Working Hard

José Anchieta anchietajunior

💭
Working Hard
View GitHub Profile
<%= simple_form_for(@bill) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<div class="row">
<div id="supplier_name">
</div>
<div class="col-md-11">
<%= f.association :supplier, label_method: :fancy_name %>
@anchietajunior
anchietajunior / estados-cidades.json
Created February 2, 2017 17:04 — forked from letanure/estados-cidades.json
JSON estados cidades
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@anchietajunior
anchietajunior / index.html
Created June 14, 2017 19:06
Get Duration and CurrenTime of an Youtube Iframe and Calculates percentage
<!DOCTYPE html>
<html>
<body>
<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
<div id="player"></div>
<div>Current Time: <span id="time"></span></div>
<script>
var timeupdater;
var tag = document.createElement('script');
@anchietajunior
anchietajunior / countries.rb
Created September 14, 2017 06:22
Ruby Countries List
COUNTRIES = [
'Afeganistão', 'África do Sul', 'Akrotiri' 'Albânia', 'Alemanha', 'Andorra', 'Angola', 'Anguila', 'Antárctida', 'Antígua e Barbuda',
'Antilhas Neerlandesas', 'Arábia Saudita', 'Arctic Ocean', 'Argélia', 'Argentina', 'Arménia', 'Aruba', 'Ashmore and Cartier Islands',
'Atlantic Ocean', 'Austrália', 'Áustria', 'Azerbaijão', 'Baamas', 'Bangladeche', 'Barbados', 'Barém', 'Bélgica', 'Belize', 'Benim',
'Bermudas', 'Bielorrússia', 'Birmânia', 'Bolívia', 'Bósnia e Herzegovina', 'Botsuana', 'Brasil', 'Brunei', 'Bulgária', 'Burquina Faso',
'Burúndi', 'Butão', 'Cabo Verde', 'Camarões', 'Camboja', 'Canadá', 'Catar', 'Cazaquistão', 'Chade', 'Chile', 'China', 'Chipre',
'Clipperton Island', 'Colômbia', 'Comores', 'Congo-Brazzaville', 'Congo-Kinshasa', 'Coral Sea Islands', 'Coreia do Norte', 'Coreia do Sul',
'Costa do Marfim', 'Costa Rica', 'Croácia', 'Cuba', 'Dhekelia', 'Dinamarca', 'Domínica', 'Egipto', 'Emiratos Árabes Unidos', 'Equador',
'Eritreia', 'Eslová
@anchietajunior
anchietajunior / postgres-cheatsheet.md
Created October 3, 2017 01:00 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@anchietajunior
anchietajunior / mailchimp_httparty.rb
Last active October 9, 2017 20:27
Integration Milchimp with Httparty Ruby
# BASIC AUTHO
request = HTTParty.get("https://api.mailchimp.com/3.0/",
basic_auth: {username: 'anystring', password: "your-api-key" })
# GET ALL LISTS INFO
request = HTTParty.get("https://api.mailchimp.com/3.0/lists",
basic_auth: {username: 'anystring', password: "your-api-key" })
# SEARCH SPECIFIC USER
@anchietajunior
anchietajunior / nfe_io_httparty.rb
Last active October 10, 2017 18:51
NFE.io Integragration with HTTparty
# GET AUTHORIZATION
HTTParty.get("https://api.nfe.io/v1/",
headers: {"Authorization" => "your-api-key"})
# POST GENERATE INVOICE (NF)
HTTParty.post("https://api.nfe.io/v1/companies/company-id/serviceinvoices",
:body => { :borrower => {
:federalTaxNumber => "99999999999",
:name => "Anchieta Junior",
:email => "email@email.com",
@anchietajunior
anchietajunior / zsh.md
Created November 17, 2017 18:59 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
def create
@payment = Payment.new(payment_params)
respond_to do |format|
if @payment.save
result = CreateInvoiceService.new({payment_id: @payment.id}).charge
if result == "pending"
format.html { redirect_to @payment, notice: 'Payment was successfully created and Invoice is pending.' }
format.json { render :show, status: :created, location: @payment }
else
class CreateInvoiceService
def initialize(params={})
@payment = Payment.find(params[:payment_id])
end
def charge
create_invoice
end
private