Skip to content

Instantly share code, notes, and snippets.

View ricardocanelas's full-sized avatar
🦈

Ricardo Canelas ricardocanelas

🦈
View GitHub Profile
@ricardocanelas
ricardocanelas / regex.md
Last active April 23, 2021 13:38
Regex - Basic information

Reference

Meta Sequences:

  • . (a dot) It denotes “any character except a newline”

Quantifiers:

  • + to the match one character after another.
  • ? is a quantifier by itself (zero or one), but if added after another quantifier (or even itself) it gets another meaning – it switches the matching mode from greedy --> to --> lazy.
function draggable({ dragElem, zoneElemBefore }) {
const $dragElem = document.querySelector(dragElem)
const $zoneElem = $dragElem.closest(zoneElemBefore)
const margin = 10
$dragElem.onmousedown = function (event) {
if (event.target.tagName === "TEXTAREA") return;
event.preventDefault();
let shiftY = event.clientY - $dragElem.getBoundingClientRect().top;
@ricardocanelas
ricardocanelas / promiseMap.js
Last active December 22, 2019 11:30
JavaScript - Promise Map
// https://codesandbox.io/s/promisemap-o7f7n
const getData = id =>
new Promise((res, rej) => {
setTimeout(() => {
const data = { id, uid: (Math.random() * 100).toFixed(2) };
console.log("data", data);
res(data);
}, 100);
});
@ricardocanelas
ricardocanelas / _wordpress-helpers.md
Last active December 22, 2018 14:57
WordPress Helpers
  • getPrevNext();
  • register_post_type
@ricardocanelas
ricardocanelas / Kernel.php
Created September 3, 2018 14:07
Laravel / Locale (middleware)
<?php // app/Http/kernel.php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
//...
protected $middlewareGroups = [
@ricardocanelas
ricardocanelas / webpack-3.md
Last active October 30, 2017 20:27
[NOTE] Webpack 3.0

WEBPACK

SOLUTIONS

import .min files

LOADERS

@ricardocanelas
ricardocanelas / polish.md
Created February 18, 2017 18:51
Polish for Brazilian People

Good morning Dzien dobry / Jindobre /

Good night Dobranoc / DoBRAnos /

Hi

@ricardocanelas
ricardocanelas / VagrantFile
Last active September 17, 2020 05:45
Vagrant / PHP7.1 + MySQL5.6 + Apache
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.100.100"
config.vm.synced_folder "./www", "/var/www/", :nfs => { :mount_options => ["dmode=777","fmode=666"] }
@ricardocanelas
ricardocanelas / js-array.js
Last active January 1, 2017 13:23
Javascript / Array
const inventors = [
{ first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 },
{ first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 },
{ first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 },
{ first: 'Marie', last: 'Curie', year: 1867, passed: 1934 },
{ first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 },
{ first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543 },
{ first: 'Max', last: 'Planck', year: 1858, passed: 1947 },
{ first: 'Katherine', last: 'Blodgett', year: 1898, passed: 1979 },
{ first: 'Ada', last: 'Lovelace', year: 1815, passed: 1852 },