Skip to content

Instantly share code, notes, and snippets.

View nfriedly's full-sized avatar
👾
Invading space

Nathan Friedly nfriedly

👾
Invading space
View GitHub Profile
// source/memory-store.ts
var MemoryStore = class {
/**
* Create a new MemoryStore with an optional custom poolSize
*
* Note that the windowMS option is passed to init() by express-rate-limit
*
* @param [options]
* @param [options.poolSize] - Maximum number of unused objects to keep around. Increase to reduce garbage collection.
*/
@nfriedly
nfriedly / chirp-audiobooks-downloader-readme.md
Last active August 6, 2024 03:06
Chirp Audiobook Download Script

Chirp AudioBook Download Script

⚠️ Not currently working. Chirp changed something that broke this script.


This script eases the process of downloading the audio files from Chirp Audiobooks. It uses the browsers console to generate a list of URLs, and then provides a list of curl or wget commands to download them.

Tested with Firefox + Terminal on MacOS, and Firefox + PowerShell on Windows 10.

function getData(callback) {
setTimeout(() => callback("hi"), 10);
}
function render(promiseData) {
promiseData.then(data => console.log("data"));
}
// wrapper around getData() to make it return a promise
function getDataPromise() {
a = { note: "I'm global" };
function foo(b) {
// b is scoped to this function, but currently points to the same object as a
b === a; // => true
b = { note: "I'm not global" };
// now b points to a new object
b !== a; // => true
}
@nfriedly
nfriedly / dsgnwrks-instagram-importer-hooks.php
Created September 19, 2018 20:32
Plugin to format WordPress posts created byt the DsgnWrks Instagram Importer
<?php
/*
Plugin Name: DsgnWrks Instagram Importer Hooks
Plugin URI: http://dsgnwrks.pro/plugins/dsgnwrks-instagram-importer
Description: Improvements to the Instagram Importer
Author URI: http://www.nfriedly.com
Author: nfriedly
Version: 0.0.0
*/
@nfriedly
nfriedly / stt-ws-transaction-id.js
Last active March 3, 2017 21:33
Extract transaction ID from IBM Watson Node.js SDK Speech to Text RecognizeStream (WebSocket)
'use strict';
const SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
require('dotenv').config({silent: true}); // optional, loads credentials from a .env file
const fs = require('fs');
const speech_to_text = new SpeechToTextV1({
// defaults to env properties if these are unset
// username: 'INSERT YOUR USERNAME FOR THE SERVICE HERE',
// password: 'INSERT YOUR PASSWORD FOR THE SERVICE HERE'
@nfriedly
nfriedly / WatsonSTTWebsocketExample.cs
Last active January 29, 2021 20:07
C# example of streaming Watson Speech to Text results over a WebSocket
// Note: The official .net SDK is in progress. It doesn't support streaming Speech to Text at the time of writing,
// but it will soon. Please check it out before using this code.
//
// https://github.com/watson-developer-cloud/dotnet-standard-sdk
using System;
using System.Net.WebSockets;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Threading;
@nfriedly
nfriedly / 1 article.md
Last active June 25, 2017 01:24
How much are verizon "smart rewards" points worth?

How much are verizon "smart rewards" points worth?

TLDR: Each point is worth about 0.012¢ - 0.109¢ ($0.00012 - $0.00109) depending on what you want and how many you have. The more you have, the more they're worth, but what you get also makes a big difference.

I just noticed that verizon has a rewards program, and so I spent a few minutes trying to work out approximately how much my accrued 74,710 points were worth. There are a few different ways to spend the points, but the gift card auctions seemed like one of the most straightforward ways of getting a real-world value. Helpfully, verizon will show you all past auctions on a single (huge) page, and they even include a copy of jQuery for easy data scraping!

Here's a quick one-liner that you can paste into the console to reduce the page to a single chunk of JSON (

@nfriedly
nfriedly / http-coap-spark-particle-forwarding-app.js
Last active September 17, 2015 16:17
Send arbitrary commands to a Particle Photon (new version of Spark Core) via express
var express = require('express');
var app = express(),
var spark = require('spark');
var _ = require('lodash');
require('dotenv').load(); // reads particle username and password from a file named .env that you can .gitignore
var deviceName = "InternetButton"; // set this to the name of your device
// Login and retrive the device
@nfriedly
nfriedly / mainIoTF.lua
Last active October 28, 2016 19:18
Connect ESP8266 to IBM IoT Foundation and publish data via MQTT (NodeMCU Firmware)
-- see https://developer.ibm.com/recipes/tutorials/connect-espressif-esp8266-to-ibm-iot-foundation/ for more information
orgID = "quickstart" -- IoT Foundation organization ID replace this with your own after creating an IoT service in bluemix
broker = "quickstart.messaging.internetofthings.ibmcloud.com" -- IP or hostname of Quickstart IoTF service
mqttPort = 1883 -- MQTT port (default 1883)
userID = "" -- optional. Set to "use-token-auth" for token auth
userPWD = "" -- optional. Put token here for token auth
macID= wifi.sta.getmac():gsub('-','') -- set this manually if needed. Just hex digits, no collons/spaces/dashes/etc.
clientID = "d:quickstart:esp8266:"..macID -- Device ID
count = 0 -- Test number of mqtt_do cycles