Skip to content

Instantly share code, notes, and snippets.

Mark remarkablemark

Block or report user

Report or block remarkablemark

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View remove-punctuation.js
var regex = /[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/g
/**
* Removes punctuation from a string.
*
* @param {string} string
* @return {string}
*/
function removePunctuation(string) {
return string.replace(regex, '');
@remarkablemark
remarkablemark / binary_uuid.sql
Last active Apr 8, 2019
Convert between BINARY and UUID for MySQL <8
View binary_uuid.sql
DELIMITER |
CREATE FUNCTION BIN_TO_UUID(b BINARY(16))
RETURNS CHAR(36) DETERMINISTIC
BEGIN
DECLARE HEX CHAR(32);
SET HEX = HEX(b);
RETURN LOWER(CONCAT(LEFT(HEX, 8), '-', MID(HEX, 9,4), '-', MID(HEX, 13,4), '-', MID(HEX, 17,4), '-', RIGHT(HEX, 12)));
END
|
@remarkablemark
remarkablemark / phaser-add-resize-listener.js
Last active Oct 13, 2019
Helper function that resizes or scales a Phaser game canvas.
View phaser-add-resize-listener.js
/**
* Adds resize listener for game canvas.
*
* @example
* var game = new Phaser.Game(config);
* addResizeListener(game);
*
* @param {Phaser.Game} game - The game object.
* @param {HTMLCanvasElement} game.canvas - The canvas element.
* @return {Function} - The resize listener.
View kbd.md
<kbd>Space</kbd>

Space

@remarkablemark
remarkablemark / git-error.md
Last active Nov 20, 2018
git error: unordered stage entries in index
View git-error.md

After a failed rebase, I have the following error:

$ git status
fatal: unordered stage entries in index

To fix the error:

View crontab.md

crontab cheatsheet

crontab

Crontab syntax taken from guide:

* * * * * command
│ │ │ │ │
│ │ │ │ └─── day of week (0 - 6) (0 = Sunday, 6 = Saturday)
│ │ │ └──────── month (1 - 12)
View load-python-dotenv.md

Load .env with python

Install python-dotenv:

$ pip install python-dotenv

Given files:

.
@remarkablemark
remarkablemark / react-beautiful-dnd-utils.js
Created Aug 10, 2018
Tidied and documented the `move` and `reorder` utils from https://codesandbox.io/s/ql08j35j3q
View react-beautiful-dnd-utils.js
/**
* Moves an item from one list to another list.
*
* @param {Array} sources
* @param {Array} destination
* @param {Object} droppableSource
* @param {Number} droppableSource.index
* @param {String} droppableSource.droppableId
* @param {Object} droppableDestination
* @param {Number} droppableDestination.index
@remarkablemark
remarkablemark / webpack-import-raw-js-file.md
Created Jul 24, 2018
Import raw JavaScript file using Webpack raw-loader.
View webpack-import-raw-js-file.md

Give JS file:

// foo.js
console.log('foo');

To import the CommonJS way:

const rawFoo = require('raw-loader!./foo.js');
View measuring-frontend-performance.md

The Performance API:

window.performance

Time to Interactive (TTI):

const { domInteractive, requestStart } = window.performance;
const TTI = domInteractive - requestStart;
You can’t perform that action at this time.