Skip to content

Instantly share code, notes, and snippets.

View wallacemaxters's full-sized avatar

Wallace Maxters wallacemaxters

View GitHub Profile
@wallacemaxters
wallacemaxters / index.php
Created June 8, 2017 17:32
Ótima forma de se trabalhar com filas/semáforos em PHP
<?php
// Exemplo de Message Queue nativo em PHP
// Veja a documentação sobre "Funções Semáforo" : http://php.net/manual/pt_BR/ref.sem.php
define('__ID__', 59544);
// Definimos um ID para a Fila
@wallacemaxters
wallacemaxters / wget.py
Created May 30, 2017 17:35
Pequeno programa escrito em Python pra fazer download via linha de comando.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib2
def open_url(url):
return urllib2.urlopen(url).read()
if __name__ == '__main__':
@wallacemaxters
wallacemaxters / middle.js
Created April 12, 2017 18:46
Gets the number in the middle
function middle() {
var numbers = Array.prototype.slice.call(arguments);
if (numbers.length % 2 == 0) throw Error("The number of parameters should be odd");
var min, max;
while (numbers.length > 1) {
@wallacemaxters
wallacemaxters / example.html
Last active April 25, 2017 20:13
Simple countdown written for angularJS
<!DOCTYPE html>
<html>
<head>
<title>Countdown Test</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="wm-countdown.js"></script>
@wallacemaxters
wallacemaxters / favicon.sublime-snippet
Created January 27, 2017 16:04
Sublime snippet to favicon tag creation
<snippet>
<content><![CDATA[
<link rel="icon" type="image/png" href="$1">
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>favicon</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.html</scope>
</snippet>
@wallacemaxters
wallacemaxters / quiet_debug.php
Created January 19, 2017 11:10
Quiet debug for expression/variable on shutdown (html commented)
<?php
/**
* Debug a expression/variable on shutdown with html comment
*
* @param ...$args
* @return void
* */
function quiet_debug()
{
@wallacemaxters
wallacemaxters / Routing.py
Created November 4, 2016 17:43
provides a classes for easy routing with python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
class NotMatchingException(Exception):
pass
"""
This class represente a route
"""
@wallacemaxters
wallacemaxters / ui-bootstrap-dialogs.js
Created October 14, 2016 12:16
confirm and alert dialog using uib-modal of the ui angular bootstrap
angular.module('ui.bootstrap.dialogs', ['ui.bootstrap'])
.factory('$dialogConfirm', function ($uibModal) {
return function (message, title) {
var modal = $uibModal.open({
size: 'sm',
template: '<div class="modal-header">\
<h4 class="modal-title" ng-bind="title"></h4>\
@wallacemaxters
wallacemaxters / exception_trace_to_json.php
Last active September 5, 2016 12:38
Simplify the Trace of an exception. Object references are converted to class string name.
<?php
/**
* Simplify the Trace of an exception. Object references are converted to class string name.
*
* @param Exception|Throwable $e
* @throws \InvalidArgumentException
* @return array
* */
@wallacemaxters
wallacemaxters / ciganomorrisonmendes_ipsum.txt
Created August 22, 2016 17:08
As frases memoráveis do Cigano Morrison Mendes
Que isso, jovem. PHP é um adicente que virou linguagem.
Sabe, acho curioso o rumo que Node tomou, servindo de facilitador pra pacotes JS, que, olhem só, justamente pra resolver comportamento de cliente.
Sou um cara com uma cabeça velha. Fora de moda. Não gosto de Node. Não gosto de JS.
Eu detesto o Node pro que ele se propôs no começo. Ser um servidor JS.
Ainda que a pobreza extrema do mundo acabe em 15 anos, ainda que logo tenha cura pra câncer, AIDS, etc., aparece aí o PHP, o Node e o Estado Islâmico pra provar que nem tudo são flores.
Node.js é tudo, menos JS