Skip to content

Instantly share code, notes, and snippets.

View phsacramento's full-sized avatar

Paulo Henrique Sacramento phsacramento

View GitHub Profile
```
require 'rails_helper'
RSpec.describe Admin::CoursesController, type: :controller do
let(:valid_attributes) {
attributes_for(:course)
}
let(:invalid_attributes) {
require 'uri'
require 'net/http'
url = URI("http://www.domaingames.com.br/Ajax_Funcoes.asp?IsNovoCfg=true&Busca=Exeggcute&Funcao=BuscaAvancada&Pagina=1")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["content-length"] = '108'
request["content-type"] = 'application/x-www-form-urlencoded'
@phsacramento
phsacramento / Geocoder.rb
Created April 5, 2016 18:24
Geocoder.rb
require 'geocoder'
module ImportXML
class Geocoder
attr_accessor :result
GERMAN_STATES = {
"Germany" => "Deutschland",
"Bavaria" => "Bayern",
"Hesse" => "Hessen",
@phsacramento
phsacramento / solution_dead_workers.text
Created April 2, 2016 21:23
Solution for dead workers
http://stackoverflow.com/questions/7416318/how-do-i-clear-stuck-stale-resque-workers
http://ubuntuforums.org/showthread.php?t=2008576
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash reboot=warm,cold,bios,smp,triple,kbd,acpi,efi,pci,force"
@phsacramento
phsacramento / example.js
Last active February 15, 2016 14:29
Chama para API Jardim das Perdizes - Criação de Usuário
var settings = {
"async": true,
"crossDomain": true,
"url": "https://jardim-das-perdizes.compartibike.com.br/api/v1/cyclists?cyclist[name]=NAME&cyclist[email]=EMAIL&cyclist[cpf]=CPF&cyclist[password]=PASSWORD&cyclist[password_confirmation]=PASSWORD_CONFIRMATION&cyclist[adr_logradouro]=LOGRADOURO&cyclist[adr_number]=ADD_NUMBER&cyclist[adr_city]=CITY&cyclist[adr_state]=STATE&cyclist[adr_cep]=ZIP-CODE&cyclist[birthday]=BIRTHDAY&cyclist[phone_number]=PHONE_NUMBER_FORMATED",
"method": "POST",
"headers": {
"x-api-key": VALID_TOKEN,
"cache-control": "no-cache"
}
}
# collection
# Model.start datetime
# 20/02/2016 16:20
# 20/02/2016 19:20
# 20/03/2016 20:20
Model.find(:all).collect(&:start).uniq
# i would like select only date, rejecting the time in attribute
@phsacramento
phsacramento / fix.sh
Created December 4, 2015 17:03
Magento folder Permissions
# set 777 to all folders
```
find . -type d -exec chmod 777 {} \;
```
# reset permissions
```
find . -type d -exec chmod 777 {} \;
@phsacramento
phsacramento / install.sh
Last active January 6, 2016 13:43
Install PHP Site
# create website directory
cd /var/www/html/
sudo mkdir nome-do-projeto
# create virtual host
cd /etc/apache2/sites-available
sudo nano projeto.conf