Skip to content

Instantly share code, notes, and snippets.

View wallacemaxters's full-sized avatar

Wallace Maxters wallacemaxters

View GitHub Profile
@wallacemaxters
wallacemaxters / FixedString.php
Last active August 29, 2015 14:26
PHP solution for fixed strings length
<?php
/**
* @author Wallace de Souza Vizerra <wallacemaxters@gmail.com>
* @version 1.0
* @see hehehehehe
**/
final class FixedString implements ArrayAccess
{
@wallacemaxters
wallacemaxters / url_parser.js
Last active December 2, 2017 12:40
idea for javascript url parser
function url_parse (href, name) {
var a = document.createElement('a');
a.href = href;
if (name) return a[name];
return {
host: a.hostname,
<?php
/**
* Forçando números com 8 dígitos, separando os números por um hifen de 4 em 4
**/
$card_1 = 1234567;
$card_2 = 12345678;
function format_money(number)
{
return (number).toFixed(2).replace('.', ',');
}
<?php
$numero = '0.12.13';
preg_replace('/\D+/', '', $numero); // string('01213')
preg_replace('~\D+~', '', $numero); // string('01213')
preg_replace('#\D+#', '', $numero); // string('01213')
SET SESSION group_concat_max_len = 100000000;
SELECT group_concat(matricula) FROM tabela;
<?php
/**
* Xrange for PHP
*/
class XRange implements Iterator
{
/**
* initial value for iteration
* @var int
<?php
class FileObject extends SplFileObject {
public function tail($amount)
{
$lastKey = $this->key();
$this->seek(PHP_INT_MAX);
(function ( $ ) {
$.fn.clickOut = function (callback) {
var that = this;
$(document).click(function (e) {
if ( $(e.target).closest(that).size() > 0) {
@wallacemaxters
wallacemaxters / database_laravel.php
Created November 4, 2015 13:20
Arquivo de configuração do Laravel 3
<?php
return array(
'profile' => true,
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql_gugu',