This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function unix2DosTime($unixtime = 0) { | |
$timearray = $unixtime ? getdate($unixtime) : getdate(); | |
if ($timearray['year'] < 1980) { | |
$timearray['year'] = 1980; | |
$timearray['mon'] = 1; | |
$timearray['mday'] = 1; | |
$timearray['hours'] = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace felipecwb\Something; | |
interface Storage { | |
public function persist($data); | |
public function delete($data); | |
public function getById($id); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
opcao = True; | |
# enquanto (while) opcao for diferente de 0 roda o bloco de codigo dentro dele | |
while opcao != 0: | |
# imprime nome e opcoes do programa | |
print "\n+---------- SIMPLES CALCULADORA ------------+" | |
print "Opcoes:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Storage\Provider; | |
interface ProviderInterface | |
{ | |
/** | |
* @param string $identifier | |
* @param mixed $data | |
* @return bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global) { | |
"use strict"; | |
// namespace | |
global.Space = { | |
entities: {} | |
}; | |
// class | |
global.Space.entities.UserEntity = function (theName, theAge) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// uma subclasse deve sobrescrever os métodos da classe pai, | |
// de tal maneira que não quebre a funcionalidade do ponto de vista do cliente. | |
namespace Application\Repository; | |
use Application\DataManager\DataManager; | |
class DataRepository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
define('TITLE', PHP_EOL . "Json Pretty print - @felipecwb" . PHP_EOL); | |
function showHelp() { | |
echo TITLE; | |
echo "\tUsage:" . PHP_EOL; | |
echo "\t- jsonlint [file.json]" . PHP_EOL; | |
echo "\t- string.json | jsonlint" . PHP_EOL . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Felipecwb\Sample; | |
class Container | |
{ | |
private $maps = []; | |
public function __call($identity, array $arguments) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
/** | |
* compare date, return 0 = equals, 1 = date1 > date2, -1 = date1 < date2 | |
* @param {String} date1 string in W3C format (Y-m-d\TH:i:sP) | |
* @param {String} date2 string in W3C format (Y-m-d\TH:i:sP) | |
* @return {int|bool} false if dates are invalid, 0 = equals, 1 = date1 > date2, -1 = date1 < date2 | |
*/ | |
Date.compare = function (date1, date2) { | |
if (! (date1 instanceof Date)) { | |
date1 = new Date(date1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateCNH(cnh) { | |
var char1 = cnh.charAt(0); | |
if (cnh.replace(/[^\d]/g, '').length !== 11 || char1.repeat(11) === cnh) { | |
return false; | |
} | |
for (var i = 0, j = 9, v = 0; i < 9; ++i, --j) { | |
v += +(cnh.charAt(i) * j); | |
} |
OlderNewer