Skip to content

Instantly share code, notes, and snippets.

View mendes5's full-sized avatar
πŸ“‰
[object Object]

mendes5

πŸ“‰
[object Object]
View GitHub Profile
@mendes5
mendes5 / wow.js
Created April 9, 2018 14:58
Cool not?
//Function paramters are acessible in default values:
const isLoaded = (state, index, item = state[index]) => item && item.loaded
//2 Array acess
const isLoaded = (state, index) => state[index] && state[index].loaded
//Bigger
const isLoaded = (state, index) => {
var item = state[index]
return item && item.loaded
const changeCase = (()=>{
const removeCase = str => str.split(/\s|-|_|[^A-Z](?=[A-Z])/).join(' ').toLowerCase().split(/\s/);
return {
noCase: removeCase,
constant2: (str, arr) => (arr = removeCase(str), arr.map(s => s.toUpperCase()).join('-')),
constant: (str, arr) => (arr = removeCase(str), arr.map(s => s.toUpperCase()).join('_')),
kebab: (str, arr) => (arr = removeCase(str), arr.join('-')),
title: (str, arr) => (arr = removeCase(str), arr.map(s => s.length > 2 ? s[0].toUpperCase() + s.slice(1) : s).join(' ')),
setence: (str, arr) => (arr = removeCase(str), arr[0][0].toUpperCase() + arr[0].slice(1) + ' '+ arr.slice(1).join(' ')),
@mendes5
mendes5 / index.js
Created May 3, 2018 15:03
Realtime redux state (or any object) visualization draggable modal.
import reducer from 'reducers/reducer-name';
document.head.appendChild(document.createElement('style')).innerHTML = `
.debug-state{
opacity: 0.5;
background: #fafafa;
display: inline-block;
padding: '10px';
z-index: 3;
position: absolute;
@mendes5
mendes5 / thanos.js
Last active May 8, 2018 13:27
Did thanos kill you?
/*
* Blazing fast!
* Case insensitive
* You can check your friends too!
* Not Math.random() based
* Same answers:
- any device (i think...)
- any time
- any place
@mendes5
mendes5 / overload.js
Created May 18, 2018 16:36
Function overloading techinique. Will flattern any arrays.
config = (thing) => {
const getCase = (item) => item.constructor.name.toLowerCase();
const configurator = {
test(...items){
const cases = {
array(array){
array.map(item => cases[getCase(item)](item));
return configurator;
},
function(func){
# Just to initialize the engine
Create Database Collision;
Use Collision;
# The Quad "Data Structure"
Create Table Quad (
x float,
y float,
w float,
h float,
//Maps an register name to its opcode
const registerEncoder = {
'NUL': 0b100001000000000000000000000000000000000,
'EAX': 0b100001000000000000000000000000000000001,
'EBX': 0b100001000000000000000000000000000000010,
'ECX': 0b100001000000000000000000000000000000011,
'EDX': 0b100001000000000000000000000000000000100,
'EEX': 0b100001000000000000000000000000000000101,
'EFX': 0b100001000000000000000000000000000000110,

Google analytics debugger:

Better than nothing...

some_controller.rb:

  def fake_ga
    p "=====================  Google Analytics Report  ====================="
    p "Method   : ( #{params.require(:method)      || "none"} )"
 p "Type : ( #{params.require(:type) || "none"} )"

Google Analytics Debugger (for node)

I like to inspect the analytics data in the devtolls...

Open an devtolls with node --inspect and paste it: analytics_listener.js:

const http = require('http');

const fillLeading = (str, char, amount, terminator) =>
@mendes5
mendes5 / πŸ‘Œ.js
Created June 8, 2018 18:30
πŸ‘ŒπŸ’―πŸ˜‚πŸ‘ŒπŸ”₯πŸ’―πŸ”₯πŸ’―πŸ”₯πŸ”₯
'x'.repeat(3e3).replace(/x/g,(e,d,c,a='πŸ˜‚πŸ‘ŒπŸ’―πŸ”₯',b=Math.random()*4<<0)=>a[b*2]+a[b*2+1])