Skip to content

Instantly share code, notes, and snippets.

View codesandtags's full-sized avatar
:octocat:
Learning mode...

Edwin Torres codesandtags

:octocat:
Learning mode...
View GitHub Profile
@codesandtags
codesandtags / css-media-queries-cheat-sheet.css
Created October 24, 2020 15:43 — forked from bartholomej/css-media-queries-cheat-sheet.css
CSS Media Query Cheat Sheet (with Foundation)
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@codesandtags
codesandtags / emoji.go
Created October 19, 2020 02:03 — forked from YamiOdymel/emoji.go
Print the emoji with Golang. https://play.golang.org/p/yPgKw3Z9HW
// (c) 2017 Yami Odymel
// This code is licensed under MIT license.
package main
import (
"fmt"
"html"
"strconv"
)

Monolith

The Monolithic Ball of Mud

  • The Ball Of Mud represents the worst case scenario for a Monolith. Also called as Spaghetti Code.
  • No clear isolation in the application.
  • Complex dependencies where everything depends on every other thing.
  • Hard to understand and harder to modify.

Cleaning Up The Ball Of Mud

  • To clean up the ball of mud we introduce isolation into the application by dividing the application along clear domain boundaries.
  • We introduce packages and libraries that help isolate related pieces of code. They provide a clean and consistent interface.
const getFormattedDay = (stringDate) => {
const date = new Date(stringDate);
const options = {
weekday: 'short',
month: 'short',
day: 'numeric' ,
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
year: 'numeric',
@codesandtags
codesandtags / ID.js
Created May 15, 2020 15:18
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`
@codesandtags
codesandtags / welcome.gif
Last active May 7, 2020 20:53
👋🏼Hello there!
welcome.gif
// Probabilities
const getRandomNumberOneToHundred = () => Math.random() * 100;
const keys = {
arrowLeft : { key : "ArrowLeft", keyCode : 37, code: 37 },
arrowUp : { key : "ArrowUp", keyCode : 38, code: 38 },
arrowRight : { key : "ArrowRight", keyCode : 39, code: 39 },
arrowDown : { key : "ArrowDown", keyCode : 40, code: 40 },
one : { key : "1", keyCode : 49, code: 49 },
two : { key : "2", keyCode : 50, code: 50 }
}
// Probabilities
const getRandomNumberOneToHundred = () => Math.random() * 100;
const keys = {
arrowLeft : { key : "ArrowLeft", keyCode : 37, code: 37 },
arrowUp : { key : "ArrowUp", keyCode : 38, code: 38 },
arrowRight : { key : "ArrowRight", keyCode : 39, code: 39 },
arrowDown : { key : "ArrowDown", keyCode : 40, code: 40 },
one : { key : "1", keyCode : 49, code: 49 },
two : { key : "2", keyCode : 50, code: 50 }
}
// The selectors
const yesButton = document.querySelector('[aria-label="Like"]');
const noButton = document.querySelector('[aria-label="Nope"]');
const getRandomNumberOneToHundred = () => Math.random() * 100;
// Logic
const MINIMUM_NUMBER_OF_PHOTOS = 3;
const RANDOM_PROBABILITIES = 80;
const MILISECONDS_TO_CLICK = 2000;
const getNumberOfPhotos = () => {
/*
Chrome does not let you modify the keyCode prop when you trigger it, so it defaults to 0.
You can use this code to trigger a keydown with a char code of 0 in chrome.
If you use initKeyEvent instead of initKeyboardEvent, it will work in FF
(the bellow example would trigger keydown with a char code of 65 in FF).
*/
document.addEventListener( 'keydown', function( event ){
console.log( event.keyCode )