Skip to content

Instantly share code, notes, and snippets.

View jsjoeio's full-sized avatar

Joe Previte jsjoeio

View GitHub Profile
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@codediodeio
codediodeio / database.rules.json
Last active June 1, 2024 14:26
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@troyfontaine
troyfontaine / 1-setup.md
Last active June 8, 2024 22:21
Signing your Git Commits on MacOS

Methods of Signing Git Commits on MacOS

Last updated March 13, 2024

This Gist explains how to sign commits using gpg in a step-by-step fashion. Previously, krypt.co was heavily mentioned, but I've only recently learned they were acquired by Akamai and no longer update their previous free products. Those mentions have been removed.

Additionally, 1Password now supports signing Git commits with SSH keys and makes it pretty easy-plus you can easily configure Git Tower to use it for both signing and ssh.

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing your commits with GPG.

@hjertnes
hjertnes / doom.txt
Created April 6, 2018 08:28
Doom Emacs Cheatsheet
SPC
SPC: find file
, switch buffer
. browse files
: MX
; EX
< switch buffer
` eval
u universal arg
x pop up scratch
@BlakePetersen
BlakePetersen / page-progress.js
Last active October 21, 2018 13:53
Page progress indicator bar for fixed navigation elements
import throttle from 'lodash/throttle';
const ProgressBar = () => {
let _canvas,
_canvasHeight,
_canvasWidth,
_ctx,
_fillColor,
_raf,
_scrollDepth,
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

@etienne-dldc
etienne-dldc / codepad
Last active February 17, 2021 20:13
Codepad
// enter this in your browser then add it as favorite !
data:text/html,<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta http-equiv="X-UA-Compatible" content="ie=edge"/><style>html, body{font-family: 'Fira Code', monospace; margin: 0;} %23container{position: fixed; top: 0; bottom: 0; left: 0; right: 0;}</style> <title>Codepad</title> </head> <body> <div id="container"></div><script src="https://unpkg.com/monaco-editor@0.15.6/min/vs/loader.js"></script> <script>require.config({paths:{vs: 'https://unpkg.com/monaco-editor@0.15.6/min/vs'}}); require(['vs/editor/editor.main'], function(){function isApplePlatform(){return window && window.navigator && window.navigator.platform ? window.navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i) ? true : false : true;}console.log(monaco.languages.typescript); monaco.languages.typescript.typescriptDefaults.setCompilerOptions({jsx: 'react',}); const fileContent=['function x(){', '\tconso
@paulmwatson
paulmwatson / async_await_serverless.js
Created June 30, 2020 08:43
Example of using async and await in a Vercel serverless function
const unravel = async (url) => {
const response = await fetch(url)
return response
}
export default async (req, res) => {
const response = await unravel(req.query.url)
res.statusCode = 200
res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify({ response: response }))
<?
//
// AUTO KEYWORD-BASED FOLLOWER CURATION BOT (by @levelsio)
//
// File: twitterFollowerCuratorBot.php
//
// Created: May 2021
// License: MIT
//
//Typescript version of Rust's Result type
interface IValue<T> {
type: 'value'
value: T
}
interface IError<E extends Error> {
type: 'error'
error: E
}