Skip to content

Instantly share code, notes, and snippets.

View psenger's full-sized avatar
:octocat:
Makin Bacon

Philip A Senger psenger

:octocat:
Makin Bacon
View GitHub Profile
# install_certifi.py
#
# sample script to install or update a set of default Root Certificates
# for the ssl module. Uses the certificates provided by the certifi package:
# https://pypi.python.org/pypi/certifi
import os
import os.path
import ssl
import stat
@psenger
psenger / frontmatter.js
Created August 3, 2023 01:57 — forked from sudkumar/frontmatter.js
MDX Remark plugin to handle frontmatter
// helps us in parsing the frontmatter from text content
const matter = require('gray-matter')
// helps us safely stringigy the frontmatter as a json object
const stringifyObject = require('stringify-object')
// helps us in getting the reading time for a given text
const readingTime = require('reading-time')
// please make sure you have installed these dependencies
// before proceeding further, or remove the require statements
// that you don't use
@psenger
psenger / 1. buffer_stream.js
Last active April 25, 2023 09:14 — forked from abdulloooh/1. buffer_stream.js
[Advanced Node.js Streams] #Stream #NodeJS
// BUFFER
// Load the whole content into a buffer/ into memory once before wrting it out to user
const http = require("http");
const media = "./testvid.mp4";
const fs = require("fs");
http
.createServer((req, res) => {
@psenger
psenger / 1-post.md
Last active January 20, 2023 02:03 — forked from getify/1-post.md
[Comparing: array method chaining, generator delegations, and transducing]

Comparing: array method chaining, generator delegations, and transducing

I'm writing this quick post to respond to a recent twitter conversation where claims were made about the merits (or lack thereof) of transducers, as they relate to composing list comprehensions (map, filter).

For comparison sake throughout the rest of my post, below you'll find three (actually four!) implementations of a simple list operation demo:

// Dynamic Flags
let args = {};process.argv.forEach(function (val, index, array) {let valsplit = val.split("=");args[valsplit[0]] = valsplit[1]});
// Speedometer
function formatBytes(a,b=2,k=1024){with(Math){let d=floor(log(a)/log(k));return 0==a?"0 Bytes":parseFloat((a/pow(k,d)).toFixed(max(0,b)))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][d]}}
var fs = require('fs');
var AWS = require('aws-sdk');
const StreamSpeed = require('streamspeed');
// File
<script>
// Based on code from https://stackoverflow.com/questions/59629947/how-do-i-load-an-external-js-library-in-svelte-sapper
import { onMount, createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher();
export let src;
export let libraryDetectionObject;
let script;
onMount(() => {
@psenger
psenger / make-animated-gifs-using-ffmpeg.md
Created August 30, 2021 02:14 — forked from gka/make-animated-gifs-using-ffmpeg.md
how to make a nice GIF from png frames

Make sure ffmpeg is up-to-date:

brew update
brew upgrade ffmpeg

Convert a MOV into frames. Tweak the 2/1 if you want more or fewer frames.

@psenger
psenger / mysql_cheat_sheet.md
Last active October 18, 2020 02:49 — forked from bradtraversy/mysql_cheat_sheet.md
[MySQL Cheat Sheet] #MySQL

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@psenger
psenger / setup-avahi.sh
Last active September 3, 2020 02:20 — forked from davisford/setup-avahi.sh
[Setup avahi-daemon on Ubuntu for so you can reach hostname `ubuntu.local` from host OS] #Unix #picker
## AVAHI is a whay of ZeroConf and the host name will be discovered by the clients in the network
sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan
@psenger
psenger / services.markdown
Last active March 15, 2020 02:40 — forked from rwilcox/services.markdown
[How to create a new gist from OS X Service] #git #MacOS

How to create a Public Gist Service:

Step 0: Open Automator, New Service.

Step 1: Drag out Run Shell Script action. Pass Input to STDIN

Step 2: This code:

open `gist`