Skip to content

Instantly share code, notes, and snippets.

View DavidWells's full-sized avatar
😃

David Wells DavidWells

😃
View GitHub Profile
@gushogg-blake
gushogg-blake / entrypoints.md
Last active May 20, 2022 16:19
A proposal for // ENTRYPOINT comments to indicate where a project connects to the outside world

Entrypoints

This is a proposal to adopt the use of // ENTRYPOINT comments next to a program's top-level entrypoints, such as the main function, event handlers, and network listeners.

The idea is to allow new contributors and curious readers to quickly gain an overview of the project's main functions in a way that's easy to understand, and for the entrypoints to act as sensible starting points (and helpful mental anchor points) for further exploration.

The presence of ENTRYPOINT comments should allow the reader to quickly begin to answer questions like what does this program do? (provided the main function is sufficiently readable); what happens when I press a key?; and how does this program respond to network requests?.

Tooling

@iamandrewluca
iamandrewluca / README.md
Last active May 9, 2023 20:10
Instant Markdown editor

Instant Markdown editor in new tab

  1. Create a new bookmark
  2. To the link add data:text/html,
  3. After data:text/html, paste block below
  4. Save bookmark, and open it

First time it may take a while to load the library

@souporserious
souporserious / build.mjs
Created February 24, 2022 02:48
Build script using esbuild and ts-morph to bundle library code.
import glob from 'fast-glob'
import { build } from 'esbuild'
import { Project } from 'ts-morph'
const project = new Project({
compilerOptions: {
outDir: 'dist',
emitDeclarationOnly: true,
},
tsConfigFilePath: './tsconfig.json',
@bennadel
bennadel / api-client.js
Created February 6, 2022 20:09
Using fetch(), AbortSignal, And setTimeout() To Apply Retry Mechanics In JavaScript
// Regular expression patterns for testing content-type response headers.
var RE_CONTENT_TYPE_JSON = new RegExp( "^application/(x-)?json", "i" );
var RE_CONTENT_TYPE_TEXT = new RegExp( "^text/", "i" );
// Static strings.
var UNEXPECTED_ERROR_MESSAGE = "An unexpected error occurred while processing your request.";
export class ApiClient {
/**
* I initialize the API client.
import { useLoaderData, Link, useSearchParams } from 'remix';
import { parseISO, format } from 'date-fns';
import groupBy from 'lodash/groupBy';
let PAGE_SIZE = 5;
function safeParseInt(str) {
let parsed = parseInt(str);
return isNaN(parsed) ? 0 : parsed;
}
@franky47
franky47 / stripe-webhooks.ts
Created December 21, 2021 09:44
Strongly-typed webhook handlers for Stripe (Node.js)
import type { Stripe } from 'stripe'
export type StripeWebhookEventTypes =
Stripe.WebhookEndpointCreateParams.EnabledEvent
export type StripeWebhookEvent<
EventType extends StripeWebhookEventTypes,
Payload
> = {
eventType: EventType
@jsonberry
jsonberry / DateComponent.vue
Created October 12, 2021 00:22
Vue Native Platform Date Component Strategy
<template>
<fieldset class="date-input" :data-qa-id="id">
<legend>{{ legend }}</legend>
<component
@change="onChange($event)"
:is="component"
:custom-validity="customValidity"
v-bind="$props"
/>
</fieldset>
@farminf
farminf / alert.js
Created October 4, 2021 20:23
Sending PR Alerts Via Slack Using AWS Serverless and AWS CDK
const AWS = require("aws-sdk");
const fetch = require("node-fetch");
const crypto = require("crypto");
const slackChannel = process.env.SLACK_CHANNEL_URL;
const githubSecret = process.env.WEBHOOK_SECRET;
const verifyGitHubSignature = (req = {}, secret = "") => {
const sig = req.headers["X-Hub-Signature"];
const hmac = crypto.createHmac("sha1", secret);
const digest = Buffer.from(
import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
@hew
hew / _readme.md
Last active September 29, 2021 12:28
Thoughts on standardizing REST with machines

Thoughts on standardizing REST with machines