Skip to content

Instantly share code, notes, and snippets.

View brcontainer's full-sized avatar
👽
Try Inphinit PHP framework today!

Guilherme Nascimento brcontainer

👽
Try Inphinit PHP framework today!
View GitHub Profile
@brcontainer
brcontainer / ByteSize.php
Created March 13, 2018 15:29
Converte tamanho em Kb, Mb, Gb, Tb, etc
<?php
class ByteSize
{
const KB = 1;
const MB = 2;
const GB = 3;
const TB = 4;
const PB = 5;
const EB = 6;
const ZB = 7;
<?php
/*
* @param string $filename Path from windows executable
* @param string $encoding You need single-byte-character output, use ISO-8859-1
* @param int $limit increase limit if you tried read a big file and it returns NULL
* @return null|array
*/
function getFileVersionInfo($filename, $encoding = 'UTF-8', $limit = 15728640)
{
@brcontainer
brcontainer / Evolution.any
Last active December 4, 2017 19:52
Linguagem imaginária mais semelhante ao "Python" (as extensões .any e .am são temporárias/imaginárias)
import Example # importa o Example.any
class Evolution extends Example:
public def __init__(): # Construtor
super("teste") # Equivalente ao super do Java, ele "executa" o Example.__init__(args...) passando o argumentos
self.show() # Executa como o Example.show
public def __destroy__(): # É equivalente ao __destruct() do php ou Foo::~Foo() do C++
print("Bye :(")
@brcontainer
brcontainer / Evolution.any
Last active December 4, 2017 19:45
Linguagem imaginária (as extensões .any e .am são temporárias/imaginárias)
import Example # importa o Example.any
class Evolution extends Example:
public void __init__(): # Construtor
super(100, "teste", false) # Equivalente ao super do Java, ele "executa" o Example.__init__(args...) passando o argumentos
self.show() # Executa como o Example.show
public void __destroy__(): # É equivalente ao __destruct() do php ou Foo::~Foo() do C++
print("Bye :(")
<?php
exec('reg export Hkey_local_Machine\Software\blabla C:\arquivo.reg');
$regfile = file_get_contents('C:/arquivo.reg');
$regfile = preg_replace('#(\r|\n)"|"(=)#', '$1$2', $regfile);
$parsed = parse_ini_string($regfile, false, INI_SCANNER_RAW);
from flask import Flask
import urllib
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.route("/youtubeproxy/<youtubeid>")
$(document).on('keyup blur', "input[name^='cpf']",function() {
$("#resposta").html(CPF.valida($(this).val()));
});

Laravel 5 in Windows IIS

  1. Create a web.config file in laravel root diretory
  2. Put this content in web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
@brcontainer
brcontainer / bug-stack-overflow.txt
Created April 17, 2017 19:19
bug stack overflow and stack snippet
1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam nunc mi, euismod id dapibus sed, sodales id mi.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
teste 1
<!-- end snippet -->
@brcontainer
brcontainer / cdata-to-dom.php
Last active April 12, 2017 01:45
Get images in CDATA (FEED/RSS)
<?php
/*
* http://pt.stackoverflow.com/a/197684/3635
*/
$imagem = array();
$items = simplexml_load_file("http://cidades.gov.br/ultimas-noticias?format=feed&type=rss")->channel->item;
$doc = new DOMDocument;