Skip to content

Instantly share code, notes, and snippets.

ive lost a shade of color in my life. rest in peace.


ive lost a shade of color in my life. rest in peace.
View GitHub Profile
the-vampiire / 1-dom-counter.js
Last active Dec 9, 2020
react basics (DOM, class-based, function with hooks)
View 1-dom-counter.js
// vanilla DOM approach: you manage state (externally) and updating the DOM manually
// state must be managed externally in a variable
const state = { count: 0 };
const counterDiv = document.createElement("div");
const counterSpan = document.createElement("span");
counterSpan.textContent = `The count is: ${state.count}`;
View table-foreign.stub
/* eslint func-names:0 */
exports.up = function (knex) {
return knex.schema.createTable("", (table) => {
.integer("") // foreign_key_name
.references("") // table.primary_key_name
the-vampiire /
Last active Dec 1, 2019
short tool for easily creating DOM elements and children (mini OG react :])

Create Element

A short (~50 lines of code) tool that you can use to easily create DOM elements and their children. Similar to the original React way of creating components :]

Simple Example

with config.children using just HTML template strings and a nested config object.

Initial HTML

View jquery-light.js
* 90% of JQuery
* @param {String} cssSelectorString: any valid css selector syntax
* @returns for ID selectors: Element
* @returns for others: Element[] (NodeList)
export const $ = cssSelectorString =>
? document.querySelector(cssSelectorString)
: document.querySelectorAll(cssSelectorString);
the-vampiire / gist:a3621c22de5daf2e804fa3942d37de97
Created Oct 11, 2019 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.
View gist:a3621c22de5daf2e804fa3942d37de97

Client-side SSL

For excessively paranoid client authentication.

Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

the-vampiire / 00-https-single-instance.yaml
Created Sep 2, 2019
AWS EB elastic beanstalk single instance nodejs nginx SSL/HTTPS ebextensions config file
View 00-https-single-instance.yaml
# set the following configuration environment variables at: configuration -> software -> modify -> environment variables
# CERT_EMAIL: the email address used for registering the cert
# CERT_DOMAIN: the domain to create a cert for
# EB environment URL (listed at the top of the environment page) or a custom domain, custom domains must have a DNS CNAME record pointing to the EB environment URL
# !! MUST NOT have "http://" prefix or the trailing "/" at the end !!
the-vampiire /
Created Jul 28, 2019
apollo-directives library proposal

apollo-directives library proposal

resources used to learn:

the proposed library aims to resolve this quote, and commonly shared opinion, from the Schema Directives docs:

...some of the examples may seem quite complicated. No matter how many tools and best practices you have at your disposal, it can be difficult to implement a non-trivial schema directive in a reliable, reusable way.

the-vampiire /
Created Jul 24, 2019
generate a usable object of jwt.kid:RSA entries for verifying AWS cognito tokens


$ node index.js <AWS cognito user pool ID> <relative/output/path.js>

generates the following file shape

module.exports = {
the-vampiire / extract-cookies.js
Last active Jan 4, 2021
express supertest / superagent utility for accessing response cookies as objects
View extract-cookies.js
const shapeFlags = flags =>
flags.reduce((shapedFlags, flag) => {
const [flagName, rawValue] = flag.split("=");
// edge case where a cookie has a single flag and "; " split results in trailing ";"
const value = rawValue ? rawValue.replace(";", "") : true;
return { ...shapedFlags, [flagName]: value };
}, {});
const extractCookies = headers => {
const cookies = headers["set-cookie"]; // Cookie[]
the-vampiire /
Last active Jul 1, 2019
what do the command line notations mean

it can be frustrating but it was likely left out because writing a CLI is predicated by having seen this notation used in the documentation when using a CLI.

to answer your question though (and a bit extra because i was there once too):

when you see $ this is almost always used to indicate that everything after the $ is a single line to paste into the command line (shell) and hit enter. it will usually be in this general form

$ program command <required arg> [optional arg]