Skip to content

Instantly share code, notes, and snippets.

View joasgarcia's full-sized avatar

Joás Garcia joasgarcia

View GitHub Profile
@joasgarcia
joasgarcia / getCustomer.php
Created March 23, 2018 11:58
Consultar cliente API ASAAS
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, "https://www.asaas.com/api/v3/customers");
curl_setopt($ch , CURLOPT_HTTPGET, true);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch , CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"access_token: <COLOQUE AQUI A SUA API>"
));
$response = curl_exec($ch);
curl_close($ch);
@joasgarcia
joasgarcia / createCustomer.php
Created March 14, 2018 18:11
Criar cliente API ASAAS
<?php
$customerData = array(
"name" => "João da Silva",
"cpfCnpj" => "09434952967",
"postalCode" => "89223005",
"mobilePhone" => "47989134255",
"email" => "joasdasilva@teste.com.br"
);
$customerParamsJson = json_encode($customerData);
@joasgarcia
joasgarcia / moveCommitsToAnotherBranch.sh
Created December 29, 2016 13:56
Mover commits para uma nova branch
git branch newbranch
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.*1
git checkout newbranch
@joasgarcia
joasgarcia / logSQL.groovy
Last active March 30, 2016 02:13
Logging SQL em Grails para um trecho de código em específico (fonte: http://www.tothenew.com/blog/log-sql-in-grails-for-a-piece-of-code/)
import org.apache.log4j.Level
import org.apache.log4j.Logger
public static def logSQL(Closure closure) {
Logger sqlLogger = Logger.getLogger("org.hibernate.SQL")
Level currentLevel = sqlLogger.level
sqlLogger.setLevel(Level.TRACE)
def result
@joasgarcia
joasgarcia / runGrailsApp.md
Last active November 16, 2015 16:08
Como rodar um projeto Grails

Download JDK

  • Adicione às variáveis do sistema a variável JAVA_HOME com o valor do diretório onde a JDK foi instalada
  • Informe na variável PATH o seguinte caminho: %JAVA_HOME%\bin (separando com ; dos outros caminhos já existentes)
  • Rode na linha de comando a instrução javac -version. Se mostrar a versão do Java é porque está tudo ok

Download Grails

  • Acesse https://grails.org/download.html e faça download da versão desejada
  • Adicione às variáveis do sistema a variável GRAILS_HOME com o valor do diretório onde descompactou o grails
  • Informe na variável PATH o seguinte caminho: %GRAILS_HOME%\bin (separando com ; dos outros caminhos já existentes)
  • Rode na linha de comando a instrução grails -version. Se mostrar a versão do Grails é porque está tudo ok
@joasgarcia
joasgarcia / underscoreToCamelCase.groovy
Last active August 29, 2015 14:26
Convert string underscore case do camelCase
//Code forked from John Moore (http://grails.1312388.n4.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=111982)
public static String propertyNameCase(String s) {
// Handle null and empty strings.
if(s == null || s.trim().length() == 0 ) return s;
String str;
if (s.indexOf('_') != -1) {
StringBuilder buf = new StringBuilder();
String[] tokens = s.split("_");
for (String token: tokens) {
@joasgarcia
joasgarcia / dateConstructorInGroovy.groovy
Last active August 29, 2015 14:17
Construir datas facilmente em Groovy
Date date1 = new Date()
date1.set(year: 2015, month: Calendar.APRIL, date: 1, hourOfDay: 10, minute: 12, second: 0)
def date2 = new GregorianCalendar(2015, Calendar.APRIL, 1, 1, 23, 45).time
@joasgarcia
joasgarcia / submitFormAsJSON.js
Last active August 29, 2015 14:07
Uma forma de enviar para o server um JSON com os dados de um form
var formFilterReference = $("form")
var jsonString = convertFormToJSON(formFilterReference)
$("#otherForm #filterData").val(jsonString);
$("#otherForm").submit();
var convertFormToJSON = function(form){
var array = $(form).serializeArray();
var json = {};
$.each(array, function() {
ssh-keygen -t rsa -C "youremail@foo.com"
eval `ssh-agent -s` //Precisa ser esse tipo de aspas
ssh-add ~/.ssh/id_rsa
ssh -T git@github.com //Teste
@joasgarcia
joasgarcia / Ant2Gant.groovy
Created September 12, 2014 00:35
Conversor de scripts Ant para scripts Gant (http://gant.codehaus.org/ant2gant+script)
#! /usr/bin/env groovy
// -*- coding:utf-8 mode:groovy -*-
/*
* ant2gant -- a script for converting Ant XML files into Gantfiles.
*
* Copyright © 2007-8 Russel Winder
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at