Skip to content

Instantly share code, notes, and snippets.

View terremoth's full-sized avatar
🌄
Open to work. #HireMe

Lucas M. Dutra terremoth

🌄
Open to work. #HireMe
  • Imaginum Softworks
  • Florianópolis, SC - Brazil
  • LinkedIn in/dutr4
View GitHub Profile
@terremoth
terremoth / compras.class.php
Created May 21, 2017 20:20
Exemplo de lista de compras para discussão thread safe, parallel programming
<?php
Class Compras
{
private $lista = array();
public add($item)
{
$this->lista[] = $item;
}
@terremoth
terremoth / Car.php
Last active April 5, 2018 07:46
Answering question in "Desenvolvimento Web" facebook group
<?php
class Car
{
// As variáveis da classe são propriedades do objeto "Car"
private $name; // isto é uma propriedade
protected $color; // isto também é
public $brand; // e isto também é
@terremoth
terremoth / count_chars.php
Last active December 17, 2018 10:48
Count repeated chars sequence and build a string with its chars (only 1) + repeated numbers
<?php
$input = 'aaacccbdd';
$output = 'a3b1c3d2';
$list = str_split($input);
$matchs = [];
foreach ($list as $i => $char) {
isset($matchs[$char]) ? $matchs[$char]++ : $matchs[$char] = 1;
@terremoth
terremoth / HttpRequest.php
Last active December 17, 2018 10:52
Curl Request WS API
<?php
class HttpRequest
{
protected $url;
protected $headers = array();
public $httpCode;
private $sslVerify = false;
public function request($data, $rawMethod = 'POST', $sendMode = 'json')
@terremoth
terremoth / bhutti_challenge.php
Last active April 21, 2021 01:41
Challenge from BHUT TI as a "FizzBuzz" similar
<?php
declare(strict_types=1);
/*
* coded by Lucas M. Dutra, github.com/terremoth
*/
abstract class Modulize
{
@terremoth
terremoth / reconfigure-phpini.sh
Last active October 20, 2021 19:10
Change and Reconfigure PHP ini (from FPM) via shellscript
#!/usr/bin/env sh
# The FPM ini file, and not the CLI one
ini_file=$(php -i | grep "Loaded Configuration File" | awk -F ' => ' '{print $2}' | sed 's/cli/fpm/g')
echo $ini_file
sudo sed -i 's/memory_limit\s*=.*/memory_limit = 256M/g' $ini_file
cat $ini_file | grep memory_limit
sudo sed -i 's/upload_max_filesize\s*=.*/upload_max_filesize = 3G/g' $ini_file
@terremoth
terremoth / mbrviewer.php
Created December 7, 2021 02:33
MBR viewer in PHP
<?php
$is_terminal = php_sapi_name() == "cli";
$td_tag_init = "\t".'<td>';
$td_tag_end = '</td>'.PHP_EOL;
$tr_tag_init = '<tr>'.PHP_EOL;
$tr_tag_end = '</tr>'.PHP_EOL;
$to_html_init = '&#';
$to_html_end = ';';
@terremoth
terremoth / ambb_projects_add_license_badges.php
Created December 10, 2021 20:52
Add license badges to all projects in felipefialho/awesome-made-by-brazilians repo
<?php
$aFile = file('README.md', FILE_TEXT);
$licensed_file = fopen('NEW_README.md', 'wb+');
// Stub: [![license](https://img.shields.io/github/license/AUTHOR/REPO.svg)](/LICENSE)
// pattern to search = ![Stars](https://img.shields.io/github/stars/LarissaAbreu/contrata-se-dev.svg?style=flat-square)
foreach ($aFile as $line_num => $line) {
@terremoth
terremoth / sendgrid_csv_import.php
Created January 5, 2022 19:33
After download the Sendgrid email activity exported data, create a SQLite to save some data
<?php
$db = new PDO('sqlite:csvdata.sqlite');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($file = fopen("parsed.csv", "r")) {
while(!feof($file)) {
$line = fgets($file);
@terremoth
terremoth / Win10LicenseShow.vbs
Created January 18, 2022 18:00
Win10 show your license
Set WshShell = CreateObject("WScript.Shell")
Function ConvertToKey(Key)
Const KeyOffset = 52
i = 28
Chars = "BCDFGHJKMPQRTVWXY2346789"
Do
Cur = 0
x = 14
Do