Skip to content

Instantly share code, notes, and snippets.

View nickytonline's full-sized avatar
🚀

Nick Taylor nickytonline

🚀
View GitHub Profile
@nickytonline
nickytonline / tweet-ublock-filters.md
Last active December 24, 2022 04:08
Filters to hide a Tweets number of views 📊

Go to your filters and add the following to hide (for yourself only), the number of views for a Tweet. See https://www.freecodecamp.org/news/how-to-block-content-from-web-pages-using-ublock-origin/ if you've never used uBlock filters

twitter.com##[id^="id__"] > div.r-1h0z5md.r-18u37iz.css-1dbjc4n > .r-lrvibr.r-bztko3.r-1ny4l3l.r-bt1l66.r-1777fci.r-1loqt21.css-1dbjc4n.css-18t94o4.css-4rbku5 > .r-qvutc0.r-3s2u2q.r-clp7b1.r-o7ynqc.r-bcqeeo.r-rjixqe.r-1h0z5md.r-16dba41.r-a023e6.r-37j5jr.r-6koalj.r-1bwzh9t.r-1awozwy.css-901oao > .r-1udh08x.r-xoduu5.css-1dbjc4n > span
twitter.com##[id^="id__"]  > div.r-1h0z5md.r-18u37iz.css-1dbjc4n > .r-lrvibr.r-bztko3.r-1ny4l3l.r-bt1l66.r-1777fci.r-1loqt21.css-1dbjc4n.css-18t94o4.css-4rbku5 > .r-qvutc0.r-3s2u2q.r-clp7b1.r-o7ynqc.r-bcqeeo.r-rjixqe.r-1h0z5md.r-16dba41.r-a023e6.r-37j5jr.r-6koalj.r-1bwzh9t.r-1awozwy.css-901oao > .r-xoduu5.css-1dbjc4n > .r-1hdv0qi.r-lrvibr.r-1plcrui.r-bnwqim.r-dnmrzs.r-1xvli5t.r-yyyyoo.r-4qtqp9
twitter.com##.r-1mf7evn.css-1dbjc4n > .css-1dbjc4n > 
import "https://deno.land/x/dotenv/load.ts";
const response = await fetch("https://www.getrevue.co/api/v2/issues", {
headers: {
Authorization: `Token ${Deno.env.get("REVUE_API_KEY")}`,
},
});
const issues = await response.json();
@nickytonline
nickytonline / useDragAndDrop.js
Last active August 31, 2020 21:44
A (P)React hook for attaching drag and drop events to an element.
/**
* Hook for drag attaching drag and drop functionality to a DOM element
*
* @param {object} props
* @param {Function} props.onDragOver The handler that runs when the dragover event is fired.
* @param {Function} props.onDragExit The handler that runs when the dragexit/dragleave events are fired.
* @param {Function} props.onDrop The handler that runs when the drop event is fired.
*/
export function useDragAndDrop({ onDragOver, onDragExit, onDrop }) {
const [element, setElement] = useState(null);
@nickytonline
nickytonline / mini-expect.js
Last active July 20, 2019 04:13
Recreated a portion of the expect library
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 July 15, 2019 00:45
Having fun recreating some lodash functionality and polyfills
// 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 July 4, 2023 17:21
A Handy DOM element creation function.
// 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 January 25, 2024 06:01
Simulate a paste event in Cypress
/**
* 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
Last active December 2, 2019 04:34
@babel/preset-env not transpiling to ES5
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 September 16, 2018 23:32
Chrome Extension Snippets
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);
});
});
}