Skip to content

Instantly share code, notes, and snippets.

Avatar
😄

Wallace Maxters wallacemaxters

😄
View GitHub Profile
@wallacemaxters
wallacemaxters / make_user_artisan.php
Created Mar 17, 2021
Comando para criar o usuário interativamente através da linha de comando do artisan. Command to create user from php artisan interactively.
View make_user_artisan.php
<?php
Artisan::command('make:user', function () {
$email = $this->ask('Digite um e-mail');
$name = $this->ask('Digite o nome');
$password = $this->secret('Digite a senha');
$user = App\User::firstOrNew(['email' => $email]);
$exists = $user->exists;
@wallacemaxters
wallacemaxters / lista_cargos.json
Last active Dec 4, 2018
Lista de profissões/cargos em JSON
View lista_cargos.json
[
"abastecedor de linha de produção",
"abastecedor de máquinas",
"acabador de embalagens",
"acrilista",
"acupunturista",
"aderecista",
"adesivador",
"adestrador",
"administrador de contratos",
View limite_range_links_pagination.php
@wallacemaxters
wallacemaxters / json_encode_callback.php
Created Aug 9, 2018
json_encode implementation with callback, like JSON.stringify of the Javascript
View json_encode_callback.php
<?php
/**
* @author Wallace Maxters <wallacemaxters@gmail.com>
* Encodes json after apply callback in data passed
*
* @param mixed $data
* @param callable $callback
* @param int $options
* @return string
@wallacemaxters
wallacemaxters / jotEvent.js
Last active May 9, 2018
Sugestão de manipulação de events para a biblioteca https://github.com/brcontainer/jot.js
View jotEvent.js
(function (window) {
"use strict";
var forEach = Array.prototype.forEach;
var Event = function (nodeList) {
this.nodeList = nodeList;
};
var proto = Event.prototype;
View loading.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wallacemaxters
wallacemaxters / routes.php
Created Sep 30, 2017
Execute function in Laravel after response sent to client
View routes.php
<?php
Route::get('/', function () {
$response = Response::json([
'process' => true
]);
return Response::withShutdownTask($response, function () {
@wallacemaxters
wallacemaxters / index.php
Created Jun 8, 2017
Ótima forma de se trabalhar com filas/semáforos em PHP
View index.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
Pequeno programa escrito em Python pra fazer download via linha de comando.
View wget.py
#!/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 Apr 12, 2017
Gets the number in the middle
View middle.js
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) {