Skip to content

Instantly share code, notes, and snippets.

View lucasprogamer's full-sized avatar
🕶️
Working on Code

Lucas lucasprogamer

🕶️
Working on Code
View GitHub Profile
function numerosMegaVirada() {
const min = 1;
const max = 60;
const max_numbers = 6;
let numbers = [];
do {
let number = Math.random() * (max - min) + min;
if (number >= min && number <= max && !numbers.includes(parseInt(number))) numbers.push(parseInt(number));
} while (numbers.length != max_numbers);
<?php
class BulmaWalker extends \Walker_Nav_Menu
{
/**
* [private stored in start_el and used in start_lvl to pass custom classes on ]
* @var [array]
*/
private $right_class;
@lucasprogamer
lucasprogamer / docker-file-laravel.yaml
Created June 16, 2021 13:46
my-default-docker-file
version: '3'
# Named volumes
volumes:
pg-container-data:
driver: local
redis-container-data:
driver: local
services:
@lucasprogamer
lucasprogamer / manhatan.js
Last active February 10, 2023 17:45
Manhatan calc in js
function distance(lat, long, lat1, long1, useManhatan) {
var r = Math.sqrt;
var o = Math.cos;
var l = Math.sin;
var p = Math.PI;
var m = Math.round;
var earthCurve = 6371;
var manthatanConst = 1.309;
function gerarCPF(a) {
var b = !0
, c = 9
, d = randomiza(c)
, e = randomiza(c)
, f = randomiza(c)
, g = randomiza(c)
, h = randomiza(c)
, i = randomiza(c)
, j = randomiza(c)
@lucasprogamer
lucasprogamer / valid-cpf.js
Created August 14, 2020 17:08
validador de cpf
cfpValido () {
const regexCPF = /^\d{3}\.\d{3}\.\d{3}-\d{2}$/
let i = 0
let soma = 0
let resto = 0
if (regexCPF.test(this.cpf)) {
for (i = 1; i <= 9; i++) {
soma = soma + parseInt(this.cpf.substring(i - 1, i)) * (11 - i)
}
resto = soma % 11
@lucasprogamer
lucasprogamer / .editorconfig
Created April 16, 2020 19:46
my .editorconfig
# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
indent_style = tab
indent_size = 4
# We recommend you to keep these unchanged
@lucasprogamer
lucasprogamer / money.js
Created April 8, 2020 20:04
Prototype para money
Number.prototype.formatMoney = function (places, symbol, thousand, decimal) {
places = !isNaN(places = Math.abs(places)) ? places : 2;
symbol = symbol !== undefined ? symbol : "$";
thousand = thousand || ",";
decimal = decimal || ".";
var number = this,
negative = number < 0 ? "-" : "",
i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
@lucasprogamer
lucasprogamer / style.scss
Created March 27, 2019 20:45
Bulma SCSS columns
.column {
display: block;
flex-basis: 0;
flex-grow: 1;
flex-shrink: 1;
padding: 0.75rem;
}
.columns {
&.is-mobile > .column {
<?php
namespace App\Lib;
use Utils;
class BulmaWalker extends \Walker_Nav_Menu
{
private $cpt; // CPT, is current post a custom post type
private $archive; // Stores the archive page for current URL
public function __construct()