Skip to content

Instantly share code, notes, and snippets.

View wookiehangover's full-sized avatar
💭
just setting up my gthb...

Sam Breed wookiehangover

💭
just setting up my gthb...
View GitHub Profile
@spullara
spullara / chat
Last active March 26, 2024 19:19
Use this command to get suggestions on how to do things on the command line.
#!/bin/bash
TOKEN=< OpenAI token from https://platform.openai.com/account/api-keys >
PROMPT="You are the best at writing shell commands. Assume the OS is Ubuntu. I want you to respond with only the shell commands separated by semicolons and no commentary. Here is what I want to do: $@"
RESULT=`curl -s https://api.openai.com/v1/chat/completions \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $TOKEN" \
-d "{
\"model\": \"gpt-3.5-turbo\",
\"messages\": [{\"role\": \"user\", \"content\": \"$PROMPT\"}]
}" | jq '.choices[] | .message.content' -r`
@skullface
skullface / lint-autofix.yml
Created November 19, 2021 03:21
Teensy GitHub Action to autofix linting errors (from the script defined in your package.json) per https://mskelton.medium.com/auto-formatting-code-using-prettier-and-github-actions-ed458f58b7df
name: Lint and autofix
on:
pull_request:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
@fridgerator
fridgerator / instructions.md
Created November 14, 2019 23:48
Auto-renewing Lets Encrypt certificates for Rancher 1.6

Lets Encrypt has removed their ACME V1 api in favor of ACME V2. The Rancher 1.6 catalog entry for Lets Encrypt certificates doesn't support this api. There is a forked version of the repo, however the service has to be created manually instead of from the catalog.

  1. Create a new service, give it a name, use vxcontrol/rancher-letsencrypt:v1.0.0 for the image
  2. In the "Volumes" tab, add a volume /var/lib/rancher:/var/lib/rancher
  3. In the "Command" tab, set the "Console" option to none
  4. Click to add an Environment Variable, and paste the following into the first "Variable" input field.
  • All of the environment variables should auto-fill.
  • Fill in the necessary values

Get/set ID3 meta tags using ffmpeg

A quick guide on how to read/write/modify ID3 metadata tags for audio / media files using ffmpeg.

FFmpeg has a free-form command line option that allows the user to specify key-value-pairs for encoding metadata. Let's take a look.

1. Read ID3 metadata

To list all global metadata tags for a media file, just set an input but no output file.

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise

@brianloveswords
brianloveswords / git-obliterate
Last active January 24, 2024 12:28
git-obliterate: for removing sensitive files you may have committed from the entire history of the project.
#!/bin/bash
file=$1
test -z $file && echo "file required." 1>&2 && exit 1
git filter-branch -f --index-filter "git rm -r --cached $file --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
git ignore $file
git add .gitignore
git commit -m "Add $file to .gitignore"
@wookiehangover
wookiehangover / define-wrapper.js
Created May 18, 2013 05:59
connect middleware that wraps serves common-js modules wrapped with AMD define()
var fs = require('fs');
var path = require('path');
var url = require('url');
module.exports = function(directory, blacklist) {
if( directory === undefined ) {
throw new Error('You need to pass a location to work with');
}
blacklist = blacklist || [];
@wookiehangover
wookiehangover / less-middleware.js
Last active December 14, 2015 21:18
Express Middleware for processing less on the fly in development mode.
/*
* Less Middleware
*
* Captures requests for your production css and serves a compiled less bundle
* in its place. Less parser is pretty quick, no noticeable load times when
* parsing bootstrap & custom less on every request. Errors are printed to the
* console.
*
* Meant to be mounted to your css directory, eg:
*
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@wookiehangover
wookiehangover / Cakefile
Created December 24, 2011 08:25
a pretty-good build script, with Cake
# Dependencies
fs = require('fs')
{_} = require('underscore')
path = require('path')
tmpl = require('handlebars-jst')
{log} = require('util')
growl = require('growl')
stitch = require('stitch')
uglify = require('uglify-js')