Skip to content

Instantly share code, notes, and snippets.

View rcarvs's full-sized avatar
🏠
Working from home

Renan Carvs rcarvs

🏠
Working from home
View GitHub Profile
@rcarvs
rcarvs / RdStation.php
Last active June 26, 2020 13:18
RDStation API PHP - A singleton PHP class to auth and insert/update leads in RDStation with the control of max requests per minute.
<?php
class RdStation{
public static $instance;
private static $max_requests_per_minute = 60;
private static $base_url = "https://api.rd.services";
public $requests_count = null;
private $client_id;
private $client_secret;
@rcarvs
rcarvs / sequential_dumb.php
Last active October 1, 2019 21:44
The sequential dumb strategy for send a list of e-mails continuously
<?php
$emailsList = News::giveMeNumberAvaiableEmailsAndMarkAsSending($numberOfEmails);
foreach ($emailsList as $email) {
try {
//This task delay seconds and this is bad
$send = $email->send();
$email->markAsSend();
} catch (\Exception $e) {
$email->markAsFailure($e->getMessage());
}
@rcarvs
rcarvs / crawler.php
Created January 20, 2019 11:26
Very little crawller in PHP
<?php
/*
------------------------------------
HOW TO USE
------------------------------------
IN YOUR PHP FILE, INCLUDE THE CRAWLER FILE AND DO AS EXAMPLE BELOW:
$crawler = new crawler();
$crawler->setDomainInitial('http://www.ufsj.edu.br');
@rcarvs
rcarvs / verifica_servidor_publico.php
Created January 19, 2019 21:00
Verifica se determinado CPF é servidor público federal ou não consultando o portal da transparência.
<?php
/*
* @author carvs
*/
$cpf = "12345678912";
$url = "http://transparencia.gov.br/servidores/Servidor-ListaServidores.asp?bogus=1&Pagina=1&TextoPesquisa=".$cpf;
$opts = array('http' =>
array(
'method' => 'GET',
'timeout' => 20
@rcarvs
rcarvs / mysql_all_text_update.php
Created January 19, 2019 19:00
PHP Script to update all defined word in every column of Mysql database
<?php
/*
@Author: carvs
-----
@HOW TO USE
-----
OBS: Necessary to use mysql user with permission in information_schema database and in database witch you would like to change defined word.
> php ./mysql_all_text_update.php [host] [database] [mysqluser] [mysqlpassword] [oldword] [newword]
Example: php ./mysql_all_text_update.php localhost website root mypass website_logo.jpg new_logo.png