Skip to content

Instantly share code, notes, and snippets.

View endymion1818's full-sized avatar
🦈
47

Ben Read endymion1818

🦈
47
View GitHub Profile
@endymion1818
endymion1818 / restore-blog-scraper.js
Created September 7, 2023 15:08
restore blog scraper
const { parse } = require('rss-to-json');
const cheerio = require('cheerio');
const fs = require('fs');
const TurndownService = require('turndown')
const turndownService = new TurndownService({
codeBlockStyle: 'fenced',
bulletListMarker: '-',
headingStyle: 'atx',
})
@endymion1818
endymion1818 / pre-push
Created October 18, 2023 15:01
git pre-push hook
# ~/.git_templates/hooks/pre-push
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
echo "${protected_branch} is a protected branch, create PR to merge"
@endymion1818
endymion1818 / matchWeatherCode.js
Last active November 3, 2023 12:13
matchWeatherCode.js
// @see https://www.nodc.noaa.gov/archive/arc0021/0002199/1.1/data/0-data/HTML/WMO-CODE/WMO4677.HTM
function matchWeatherCode(code) {
switch (code) {
case 0:
return "🌥️"
case 1:
return "🌥️"
case 2:
return "🌥️"
case 3:
@endymion1818
endymion1818 / zathras.zsh-theme
Last active June 5, 2024 11:18
ZHS theme (forked from "amuse")
# vim:ft=zsh ts=2 sw=2 sts=2
# Must use Powerline font, for \uE0A0 to render.
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}\uE0A0 "
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg_bold[red]%}‹"
@endymion1818
endymion1818 / fetch.js
Last active February 5, 2024 10:44
fetch
async function getStuff(token) {
const body = {}
// wrap in try / catch so we can resolve any network failures
try {
// initial request
const result = await fetch(`https://example.com/api/v1`, {
headers: {
"x-CSRF-Token": token,
"Content-Type": "application/json"
},