Skip to content

Instantly share code, notes, and snippets.

View matheuseduardo's full-sized avatar
:octocat:
coding

Matheus Eduardo Silva Guimarães matheuseduardo

:octocat:
coding
View GitHub Profile
@matheuseduardo
matheuseduardo / adicionar-dias-uteis.php
Created June 26, 2018 19:10
função para adicionar determinado dias úteis - #php
<?php
function adicionaDiasUteis(int $numDias=0, DateTime $data):DateTime {
$dataFim = clone $data;
$umdia = new DateInterval('P1D'); // intervalo fixo
for ($i=0; $i<$numDias; $i++) {
$dataFim->add($umdia);
if ($dataFim->format('w') == "0" || $dataFim->format('w') == "6") {
$i--; // retorna o contador, caso seja sábado ou domingo
}
@matheuseduardo
matheuseduardo / Cake Composer.md
Created July 9, 2018 14:03 — forked from ogrrd/Cake Composer.md
Install Cake 2.x with Composer

Install CakePHP 2.x with Composer

Remove the main CakePHP lib directory

$ cd /path/to/your/website
$ rm -Rf ./lib

Add the following composer.json file

@matheuseduardo
matheuseduardo / base64.inc.asp
Created July 12, 2018 18:50
Base64 encoding / decoding functions in VbScript / Classic ASP
<%
Function Base64Encode(sText)
Dim oXML, oNode
Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
Set oNode = oXML.CreateElement("base64")
oNode.dataType = "bin.base64"
oNode.nodeTypedValue = Stream_StringToBinary(sText)
Base64Encode = oNode.text
Set oNode = Nothing
Set oXML = Nothing
@matheuseduardo
matheuseduardo / create-preview-from-video.sh
Created July 18, 2018 16:04
Create Short Preview from Video
# source: https://davidwalsh.name/video-preview
# sample in PHP => https://gist.github.com/AkgunFatih/88c2241865c25e40a50edc4e24679a94
sourcefile=$1
destfile=$2
# Overly simple validation
if [ ! -e "$sourcefile" ]; then
echo 'Please provide an existing input file.'
@matheuseduardo
matheuseduardo / Db.class.php
Created August 8, 2018 02:40
classe simples de DB
<?php
class DB {
/**
* @var DB
*/
private static $instancia = NULL;
/**
* @var Mysql link identifier
@matheuseduardo
matheuseduardo / GetrsSetrs.class.php
Created August 21, 2018 18:17
class with getters and setters predefined through magic methods
<?php
class GetrsSetrs {
public function __call($name, $arguments) {
$action = substr($name, 0, 3);
if ($action == 'get') {
return $this->get(lcfirst(substr($name, 3)));
}
else if ($action == 'set') {
@matheuseduardo
matheuseduardo / example.md
Last active August 30, 2018 18:11
subir arquivo para WebDAV via shell
@matheuseduardo
matheuseduardo / .gitalias
Last active May 3, 2021 12:42
alias para o git
alias.lg log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
alias.lg2 log --pretty='%h - %s (%an)'
alias.alias config --get-regexp ^alias\.
alias.unadd reset HEAD --
alias.unstage reset HEAD --
##Test
Exclude
##Books
Chrome
Movies
Music
##PlayGames
Talkback
@matheuseduardo
matheuseduardo / DCIM-sizes.sh
Created January 22, 2019 12:47
shell script to list sizes of pics & vids
anos=`seq 2016 2018`; # 2016 a 2018
meses=`seq -w 1 12`; # todos os meses
for ano in $anos
do
for mes in $meses
do
data=$ano$mes;
tam=`du -c DCIM/**/IMG_$data*.jpg DCIM/**/VID_$data*.mp4 2> /dev/null | tail -1 | cut -f 1`
echo $data: $tam