Skip to content

Instantly share code, notes, and snippets.

View designbyadrian's full-sized avatar
⚛️
Reacting

Adrian von Gegerfelt designbyadrian

⚛️
Reacting
View GitHub Profile
@samdenty
samdenty / README.MD
Last active November 11, 2021 04:57
VS Code CSS addition to increase readability on file tree.

How to install

Custom CSS plugin

Install the custom CSS plugin, then make a file on your computer that will hold your custom CSS, I like to make one in my home directory called ~/.vscodestyles.css and then add the CSS into it.

Once done, open your command palette and select enable custom CSS and JS

@blenderous
blenderous / prettify-base64.js
Last active October 19, 2022 08:09
Convert PNG image to data URI using Node.js
var fs = require('fs');
//
// reference for accessing file system using node.js
// http://www.sitepoint.com/accessing-the-file-system-in-node-js/
fs.readFile('image.png', 'binary', function(error, data) {
var buf = new Buffer(data, 'binary');
var string = buf.toString('base64');
var limit = parseInt(string.length/50);
console.log('Data url of the image.png in not more than 50 characters per line:');
console.log('');
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active December 29, 2023 00:40
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@nosp4mSnippets
nosp4mSnippets / finalevent.js
Created June 23, 2013 22:10
JS: wait final event
// Here's a modification of CMS's solution that can be called in multiple places in your code:
// Wait for final event example during resize
//
var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@robnyman
robnyman / image-data-url-localStorage.js
Created February 21, 2012 08:29
Turn image into Data URL and save in localStorage
// Get a reference to the image element
var elephant = document.getElementById("elephant");
// Take action when the image has loaded
elephant.addEventListener("load", function () {
var imgCanvas = document.createElement("canvas"),
imgContext = imgCanvas.getContext("2d");
// Make sure canvas is as big as the picture
imgCanvas.width = elephant.width;