Skip to content

Instantly share code, notes, and snippets.

View rake7h's full-sized avatar
πŸ˜€

Rakesh rake7h

πŸ˜€
View GitHub Profile
@rake7h
rake7h / async-await-forEach-alternatives.md
Created February 28, 2023 05:17 — forked from joeytwiddle/async-await-forEach-alternatives.md
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach in asynchronous code.

The problem

Array.prototype.forEach is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)

For example, the following forEach loop might not do what it appears to do:

const stream = require('stream')
const cache = new Map() // you might wanna use an lru here
function createCacheStream (url) {
const buf = []
return stream.Transform({
transform: function (data, enc, cb) {
buffer.push(data)
cb(null, data)
},
@rake7h
rake7h / Native.js
Created October 21, 2021 12:17 — forked from alexreardon/Native.js
Some vanilla JS methods and patterns
// Native selectors.
(function(window, document) {
'use strict';
var noop = function() {
};
// DOCUMENT LOAD EVENTS
// not needed at the bottom of the page
document.addEventListener('DOMContentLoaded', noop);
@rake7h
rake7h / vanilla-js-cheatsheet.md
Created October 21, 2021 12:14 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
@rake7h
rake7h / safari-nomodule.js
Created September 17, 2021 16:50 — forked from samthor/safari-nomodule.js
Safari 10.1 `nomodule` support
/*
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@rake7h
rake7h / ServingES6.md
Created May 23, 2021 14:51 — forked from newyankeecodeshop/ServingES6.md
Serving ES6 to modern browsers

Background

Recently I noticed that Safari 10 for Mac/iOS had achieved 100% support for ES6. With that in mind, I began to look at the browser landscape and see how thorough the support in the other browsers. Also, how does that compare to Babel and its core-js runtime. According to an ES6 compatability table, Chrome, Firefox, and IE Edge have all surpassed what the Babel transpiler can generate in conjunction with runtime polyfills. The Babel/core-js combination achieves 71% support for ES6, which is quite a bit lower than the latest browsers provide.

It made me ask the question, "Do we need to run the babel es2015 preset anymore?", at least if our target audience is using Chrome, Firefox, or Safari.

It's clear that, for now, we can't create a site or application that only serves ES6. That will exclude users of Internet Explorer and various older browsers running on older iOS and Android devices. For example, Safari on iOS 9 has pretty mediocre ES6 support.

@rake7h
rake7h / clear-cache.js
Created April 8, 2021 18:42 — forked from deanhume/clear-cache.js
Clear Service Worker Cache
if ('serviceWorker' in navigator) {
caches.keys().then(function(cacheNames) {
cacheNames.forEach(function(cacheName) {
caches.delete(cacheName);
});
});
}

Setup MinIO on Ubuntu 20.04 LTS with Let's Encrypt SSL

✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨
SUPPORT MY WORK - Everything Helps Thanks
YouTube πŸ”— https://YouTube.GetMeTheGeek.com
Buy Me a Coffee β˜• https://www.buymeacoffee.com/getmethegeek
Hire US πŸ”— https://getmethegeek.com
Digital Ocean referral πŸ”— https://tiny.cc/plxdigitalocean
✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨

@rake7h
rake7h / gist:55f17c4b0f3681301bf9d183253cc049
Created January 12, 2021 09:25 — forked from paulirish/gist:5558557
a brief history of detecting local storage

A timeline of the last four years of detecting good old window.localStorage.


Jan Lenhart, bless his heart contributed the first patch for support:

October 2009: 5059daa

@rake7h
rake7h / ApacheHTTPSConfig.md
Created October 13, 2020 17:12 — forked from nrollr/ApacheHTTPSConfig.md
Enable SSL in Apache for 'localhost' (OSX, El Capitan)

Enable SSL in Apache (OSX)

The following will guide you through the process of enabling SSL on a Apache webserver

  • The instructions have been verified with OSX El Capitan (10.11.2) running Apache 2.4.16
  • The instructions assume you already have a basic Apache configuration enabled on OSX, if this is not the case feel free to consult Gist: "Enable Apache HTTP server (OSX)"

Apache SSL Configuration

Create a directory within /etc/apache2/ using Terminal.app: sudo mkdir /etc/apache2/ssl
Next, generate two host keys: