Skip to content

Instantly share code, notes, and snippets.

View TiagoGouvea's full-sized avatar

Tiago Gouvêa TiagoGouvea

View GitHub Profile
@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 / 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;
@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();
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'
));
public function sendCampaignMailSes()
{
if ($this->date_sent != null) {
// Log!!!
$this->showLog("Already sent");
return;
}
if ($this->date_sending != null) {
$this->showLog("Already sending! - since: " . $this->date_sending);
return;
@TiagoGouvea
TiagoGouvea / mass_subscription.php
Last active October 8, 2016 14:36
Wordpress - Subscribe to comments reloaded - Suscribe to all users (bulk, mass)
global $wp_subscribe_reloaded;
echo "Subscribe old comments<br><br>";
// Get all comments on database
$comments = get_comments(array('type'=>'comment'));
$added=0;
echo "Comments: ".var_dump(count($comments))."<br>";
foreach ($comments as $comment){
$postId=$comment->comment_post_ID;
$email=$comment->comment_author_email;
if (strpos(email,'YOUR_EMAIL')!==false) continue;
@TiagoGouvea
TiagoGouvea / layout.js
Created June 12, 2017 12:34
Responvie detect in window.resize
componentDidMount() {
window.addEventListener("resize", ()=> {
this.updateDimensions();
});
this.updateDimensions();
}
updateDimensions() {
let w = window,
import React from 'react';
import * as PropTypes from "prop-types";
import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';
import Snackbar from 'material-ui/Snackbar';
import TextField from 'material-ui/TextField';
export default class Context extends React.Component {
@TiagoGouvea
TiagoGouvea / ucWords.js
Created January 19, 2018 13:59
ucWords to JavaScript
fucntion ucWords (str) {
str = str.trim();
str = str.toLowerCase().replace(/^[\u00C0-\u1FFF\u2C00-\uD7FF\w]|\s[\u00C0-\u1FFF\u2C00-\uD7FF\w]/g, function (letter) {
return letter.toUpperCase();
});
return str;
}
@TiagoGouvea
TiagoGouvea / surName.js
Last active January 19, 2018 14:00
Return person first name or surName
/**
* Return the name and surname
* "Tiago Gouvêa de Oliveira" will return "Tiago Gouvea"
* @author TiagoGouvea
* @param name
* @returns String
*/
function nameSurname (name) {
name = name.trim();
if (!name) return '';