Skip to content

Instantly share code, notes, and snippets.

View TiagoGouvea's full-sized avatar

Tiago Gouvêa TiagoGouvea

View GitHub Profile
public function sendEmail($email, $subject, $html, $text)
{
$sesClient = SesClient::factory(array(
'credentials' => array(
'key' => 'YOURKEY',
'secret' => 'YOURSECRET',
),
'region' => 'us-east-1',
'version' => '2010-12-01'
));
@TiagoGouvea
TiagoGouvea / cpf.cs
Created September 19, 2016 12:53
Validar e formatar CPF
public static string SomenteNumeros(string texto = null)
{
if (texto == null) return texto;
Regex re = new Regex("[0-9]");
StringBuilder s = new StringBuilder();
foreach (Match m in re.Matches(texto))
{
s.Append(m.Value);
}
return s.ToString();
<?php
/**
* Authors:
* Júlio Paulillo <julio@agendor.com.br>
* Tulio Monte Azul <tulio@agendor.com.br>
*
* DOCS
* #############
* Guia de integrações
* http://ajuda.rdstation.com.br/hc/pt-br/articles/200310549-Guia-de-integra%C3%A7%C3%B5es-com-o-RD-Station
@TiagoGouvea
TiagoGouvea / JustGetContactAgile.php
Created November 4, 2015 09:45
Teste curl_wrap with Agile CRM in PHP
<?php
// Test Agile curl_wrap
require 'php-api-master/curlwrap_v2.php';
$email = "some@email.com";
// Try get contact from Agile
$contact = curl_wrap("contacts/search/email/" . $email, null, "GET");
// Get contatct Agile
@TiagoGouvea
TiagoGouvea / curlwrap_v2.php
Created November 4, 2015 09:44
AgileCRM PHP Api Wrap with some fixes
<?php
define("AGILE_DOMAIN", "tiagogouvea");
define("AGILE_USER_EMAIL", "yourEmail");
define("AGILE_REST_API_KEY", "yourApiKey");
function curl_wrap($entity, $data, $method)
{
$agile_url = "https://" . AGILE_DOMAIN . ".agilecrm.com/dev/api/" . $entity;
$agile_php_url = "https://" . AGILE_DOMAIN . ".agilecrm.com/core/php/api/" . $entity . "?id=" . AGILE_REST_API_KEY;
@TiagoGouvea
TiagoGouvea / index.android.js
Created October 10, 2015 16:12
Sample DrawerLayout opened by clicking in a TouchableHighlight component
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
@TiagoGouvea
TiagoGouvea / Items.java
Created July 29, 2015 11:08
Sample request returning json and materializing it to objects, the looong way
public static void get(Context context, int idStatus, final int id, final SuccessListener successListener, final ErrorListener errorListener) {
String url = "some_url_to_get_json";
ARequest.get(context, url,
new AResponse.SuccessListener() {
@Override
public void onResponse(Object response) {
JSONArray jsonArray = null;
try {
JSONObject jsonObject = new JSONObject(response.toString());
if (jsonObject.getJSONObject("meta").getInt("code") == 200) {
@TiagoGouvea
TiagoGouvea / PickImageActivity.java
Last active April 5, 2019 02:42
Pick a image from all gallery and camera intents and return it in onActivityResult from caller PickImageActivity class.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_add);
// ImageButton
ImageButton imageButton = (ImageButton) findViewById(R.id.imageButton);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewHelper.selectImage(PickImageActivity.this);
@TiagoGouvea
TiagoGouvea / CardContainer.java
Last active June 9, 2016 00:29
Like and Unlike alpha view effect - kikoso/Swipeable-Cards
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mTopCard == null) {
return false;
}
if (mGestureDetector.onTouchEvent(event)) {
return true;
}
Log.d("Touch Event", MotionEvent.actionToString(event.getActionMasked()) + " ");
final int pointerIndex;