Skip to content

Instantly share code, notes, and snippets.

View iambriansreed's full-sized avatar
🏠
Working from my office at home

Brian Reed iambriansreed

🏠
Working from my office at home
View GitHub Profile
@iambriansreed
iambriansreed / deepSet.ts
Last active October 19, 2020 22:43
Sets the value at path of object. If a portion of path doesn't exist, it's created. An alternative to https://lodash.com/docs/#set
/**
* Sets the value at path of object. If a portion of path doesn't exist, it's created.
* An alternative to https://lodash.com/docs/#set
*
* @param {object} obj
* @param {string} keyPath
* @param {any} value
*/
export default function deepSet(
obj: { [key: string]: any },
@iambriansreed
iambriansreed / README.md
Last active June 10, 2017 03:05 — forked from JoelBesada/README.md
Backtick Example Command

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Update This readme with a brief explanation of what your command does or delete this.

  2. Create a new Gist with a command.js and command.json file, or simply fork this one.

  3. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

@danharper
danharper / background.js
Last active March 30, 2024 18:25
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}