Skip to content

Instantly share code, notes, and snippets.

View subversivo58's full-sized avatar
📧
For critical issues, send me an email

Lauro Moraes subversivo58

📧
For critical issues, send me an email
View GitHub Profile
@AnalyzePlatypus
AnalyzePlatypus / lambda-gmail-compose.md
Created May 13, 2020 08:11
Use serverless function to send low-volume emails without 3rd party mail services.

Sending email with serverless functions

You can deploy this function on any of the serverless platforms - AWS Lambda, Google Cloud Functions, Azure Functions, Netlify, Cloudflare Workers, etc.

  1. Create a new function and paste in the following code.
  2. You will need to add nodemailer to your package.json (npm i nodemailer), and follow your platform's instructions on bundling dependencies.
  3. Obtain Gmail API credentials for your account. You will need clientID, clientSecret, and refreshToken. Follow this YouTube tutorial
  4. Expose these credentials as the follwing environment variables:
GMAIL_EMAIL_ADDRESS
@joshuabaker
joshuabaker / languages.json
Last active April 22, 2024 18:02
List of languages with ISO 639-1 Alpha-2 codes in JSON.
[
{
"code": "aa",
"name": "Afar",
"native": "Afar"
},
{
"code": "ab",
"name": "Abkhazian",
"native": "Аҧсуа"
@WesThorburn
WesThorburn / adding_wasm_MIME.md
Last active July 30, 2023 04:35
Webassembly, wasm files, webservers and MIME types

When compiling client files to webassembly, usually you'll end up with both .js and .wasm files. By default, most webservers don't know about the wasm MIME type. You'll likely see the following error: wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

Here is how to add the wasm MIME type (on linux systems, apache + nginx):

Open /etc/mime.types You'll see two columns, media type on the left, file type on the right Add the line application/wasm wasm

const describe = (desc, fn) => {
console.log(desc)
fn()
}
const it = (msg, fn) => describe(' ' + msg, fn)
const matchers = (exp) => ({
toBe: (asssertion) => {
if (exp === assertion) {
@ebidel
ebidel / feature_detect_es_modules.js
Last active September 4, 2023 13:56
Feature detect ES modules: both static import and dynamic import()
<!--
Complete feature detection for ES modules. Covers:
1. Static import: import * from './foo.js';
2. Dynamic import(): import('./foo.js').then(module => {...});
Demo: http://jsbin.com/tilisaledu/1/edit?html,output
Thanks to @_gsathya, @kevincennis, @rauschma, @malyw for the help.
-->
@blattmann
blattmann / Git: Empty branch.md
Last active October 9, 2023 22:40
Git: Create empty branch

Replace empty-branch with your desired branch name.

git checkout --orphan empty-branch

Then you can remove all the files you'll have in the staging area (so that they don't get committed):

git rm -rf .

At this point you have an empty branch, on your machine.

@kenmazaika
kenmazaika / README.md
Last active April 19, 2019 00:10
Showdown Markdown extension

Markdown Extensions for Wells and PrismJS

Hello

foo
```javascript:4,5-7
hello
```
@ziluvatar
ziluvatar / token-generator.js
Last active April 11, 2024 07:10
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');
@barretts
barretts / css-filter-generator-to-convert-from-base-hex-color-to-target-hex-color.markdown
Last active March 26, 2021 09:15
CSS filter generator to convert from black to target hex color
@chrisveness
chrisveness / crypto-sha.js
Last active July 20, 2023 04:45
Uses the SubtleCrypto interface of the Web Cryptography API to hash a message using SHA-256.
/**
* Returns SHA-256 hash from supplied message.
*
* @param {String} message.
* @returns {String} hash as hex string.
*
* @example
* sha256('abc').then(hash => console.log(hash));
* const hash = await sha256('abc');
*/