Skip to content

Instantly share code, notes, and snippets.

🐝
busy bee

Nick Taylor nickytonline

🐝
busy bee
Block or report user

Report or block nickytonline

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
@nickytonline
nickytonline / mini-expect.js
Last active Jul 20, 2019
Recreated a portion of the expect library
View mini-expect.js
function expect(actual) {
function prettyJSON(objectToSerialize) {
return JSON.stringify(objectToSerialize, null, '\t')
}
return {
toBe(expected) {
if (actual === expected) {
console.log('✅ Pass')
} else {
@nickytonline
nickytonline / object-entries-polyfills.js
Last active Jul 15, 2019
Having fun recreating some lodash functionality and polyfills
View object-entries-polyfills.js
// Just having fun creating some polyfills.
/**
* A polyfill for Object.prototype.entries.
*
* @returns {[string, any][]} An array of tuples where each tuple is a key/value pair.
*/
Object.prototype.entries = Object.prototype.entries || function() {
const obj = this;
@nickytonline
nickytonline / createElement.js
Last active Jul 11, 2019
A Handy DOM element creation function.
View createElement.js
// Inspired from Sam Thorogood's article, https://dev.to/chromiumdev/beyond-appendchild-better-convenience-methods-for-html-55n4
function createElement(nodeName, props) {
const { style = {}, ...propsNoStyle } = props;
const element = Object.assign(document.createElement(nodeName), propsNoStyle);
Object.entries(style).forEach(([key, value]) => { element.style[key] = value; });
return element;
}
@nickytonline
nickytonline / paste.js
Last active Jul 11, 2019
Simulate a paste event in Cypress
View paste.js
/**
* Simulates a paste event.
*
* @param pasteOptions Set of options for a simulated paste event.
* @param pasteOptions.destinationSelector Selector representing the DOM element that the paste event should be dispatched to.
* @param pasteOptions.pastePayload Simulated data that is on the clipboard.
* @param pasteOptions.pasteFormat The format of the simulated paste payload. Default value is 'text'.
*/
function paste({ destinationSelector, pastePayload, pasteType = 'text' }) {
// https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
@nickytonline
nickytonline / webpack.config.js
Created May 9, 2019
@babel/preset-env not transpiling to ES5
View webpack.config.js
module.exports = {
entry: {
acme_co_es5: [
"@babel/polyfill",
"./public/javascripts/webpack_entry_points/acme_co.js"
]
},
resolve: {
extensions: [".js", ".jsx"]
},
@nickytonline
nickytonline / snippets.js
Created Sep 16, 2018
Chrome Extension Snippets
View snippets.js
function getActiveTab() {
return new Promise((resolve, reject) => {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
const activeTab = tabs.find(t => t.active);
resolve(activeTab);
});
});
}
@nickytonline
nickytonline / preview-head.html
Created Jul 11, 2018
Grid Points Background for Storybook
View preview-head.html
<style>
body {
background-image: linear-gradient(transparent 0px, transparent 1px, rgb(255, 255, 255) 1px, rgb(255, 255, 255) 20px), linear-gradient(to right, rgb(54, 69, 79) 0px, rgb(54, 69, 79) 1px, rgb(255, 255, 255) 1px, rgb(255, 255, 255) 20px);
background-position: 1.1875rem;
background-size: 1.25rem 1.25rem;
background-attachment: fixed;
}
</style>
@nickytonline
nickytonline / my-mac-setup.sh
Last active Aug 13, 2019
Mac Setup Scripts
View my-mac-setup.sh
#!/bin/sh
# More Mac setup at https://mac.iamdeveloper.com
# Log file
timestamp=$(date +%s)
logFile="./my-mac-setup-$timestamp.log"
# if true is passed in, things will reinstall
reinstall=$1
@nickytonline
nickytonline / customizing-vs-code.md
Last active Aug 1, 2019
Customizing VS Code for Two Fonts.
View customizing-vs-code.md

Customizing VS Code

I followed the instructions in this blog post Multiple Fonts: Alternative to Operator Mono in VSCode, but did not see any changes made to VS Code. After digging a bit, I discovered that all the CSS class names had changed. They’re now e.g. .mtk13, .mtk16 { … }.

Gotchas

  • Ensure it’s a file URL e.g. { "vscode_custom_css.imports": [ "file:///Users/Brian/Desktop/vscode-style.css" ] }
  • If you move the location of your file and update your user settings with the new location, you will need to disable and enable custom CSS cmd+shift+p.
  • Also, anytime you change the style in your custom CSS file, you need to disable, then re-enable the extension.

For reference

View for-chris.ts
interface Association<TKey, TValue> {
key: TKey;
info: TValue;
}
interface StringKeyInfo {
keyIndexes: Array<Association<string, number>>;
keyIsSet: Array<Association<string, boolean>>;
}
You can’t perform that action at this time.