Skip to content

Instantly share code, notes, and snippets.

@travispaul
travispaul / Response.md
Created February 15, 2024 16:17
HX-Location

The HX-Location response header looks something like this, the response body is empty:

hx-location: {
  "path":"/foo",
  "target":"#main",
  "select":"#content",
  "values": {
    "allowedPaths":["/foo/1"],
 "notification":"Foo 1 has been created"
@travispaul
travispaul / provider.tf
Last active May 11, 2022 14:08
Example Terraform configuration using Vultr object store for state backend.
# https://www.vultr.com/docs/vultr-object-storage
terraform {
# Even though this example is using Vultr's object storage, the AWS_ACCESS_KEY
# and AWS_SECRET_ACCESS_KEY environment variables need to be defined.
# The values can be obtained from the object storage page at my.vultr.com
backend "s3" {
bucket = "your-bucket-name-here"
key = "/path/in/bucket/terraform.state"
endpoint = "ewr1.vultrobjects.com"
region = "us-east-1"
@travispaul
travispaul / cmusfm.diff
Created April 7, 2020 17:43
cmusfm.diff
diff --git a/cmusfm/Makefile b/cmusfm/Makefile
index 91e348ef57..ed103aec35 100644
--- a/cmusfm/Makefile
+++ b/cmusfm/Makefile
@@ -1,31 +1,31 @@
# $NetBSD: Makefile,v 1.1 2014/06/05 21:26:12 leot1990 Exp $
-DISTNAME= cmusfm-0.2.0
+DISTNAME= cmusfm-0.3.3
CATEGORIES= audio
@travispaul
travispaul / test.sh
Last active August 3, 2019 15:20
Setting a default value for $@ (sh vs dash vs ksh vs bash)
#!/bin/sh
#!/bin/ksh
#!/usr/pkg/bin/dash
#!/usr/pkg/bin/bash
somefn() {
local args="${@:-something}"
echo "Value of \$args: $args"
}
@travispaul
travispaul / patch-salt_grains_core.py.patch
Created May 11, 2018 15:45
sysutils/salt/patches/patch-salt_grains_core.py
$NetBSD$
Prevent crash on NetBSD and OpenBSD when no swap is configured.
https://github.com/saltstack/salt/pull/47600
--- salt/grains/core.py.orig 2018-05-11 13:12:38.000000000 +0000
+++ salt/grains/core.py
@@ -450,11 +450,13 @@ def _bsd_memdata(osdata):
mem = __salt__['cmd.run']('{0} -n hw.physmem64'.format(sysctl))
grains['mem_total'] = int(mem) // 1024 // 1024
@travispaul
travispaul / answer.md
Last active January 26, 2018 12:43
module.exports how to return a function value?

The return value of getAOLDataCount is undefined. You're returning the aolCount variable from within an anonymous function in your .then() call and it's not being returned.

It's basically the same as this:

module.exports = {
    getAOLDataCount:  function () {
        wd = new WeeklyData(sequelize, Sequelize.DataTypes);
        wd.count({where: {week:201740, project: 8}}).then(function (aolCount) {
            console.log(aolCount);

return aolCount;

@travispaul
travispaul / copycommit.sh
Created October 2, 2017 17:37
Alias for copying commits between forks
copycommit () {
if [ $# -lt 2 ]; then
echo -e "Usage:\n copycommit /path/to/repo commithash1 commithash2 ..."
return 1
fi
repo="$1/.git"
shift 1
if [ ! -d "$repo" ]; then
echo "$repo is not a git repo"
return 1
@travispaul
travispaul / cowsay9k.js
Created July 13, 2017 11:03
Cowsay test bot for MatterMost outgoing webhook
// https://docs.mattermost.com/developer/webhooks-outgoing.html
var express = require('express');
var cowsay = require('cowsay');
var bodyparser = require('body-parser');
var app = express();
app.use(bodyparser.urlencoded({ extended: true }));
app.get('/', function (req, res) {
res.end('<pre>'+ cowsay.say({text: 'Moo'}) + '</pre>');
@travispaul
travispaul / bbb.md
Created May 1, 2017 15:03
Networking config for Beaglebone Black
# ifconfig
lo0: flags=0x8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33180
        inet6 ::1/128 flags 0x20<NODAD>
        inet6 fe80::1%lo0/64 flags 0x0 scopeid 0x1
        inet 127.0.0.1/8 flags 0x0
cpsw0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        address: c8:a0:30:aa:65:c4
        media: Ethernet autoselect (100baseTX full-duplex)
 status: active
@travispaul
travispaul / npf.conf
Created March 30, 2017 03:09
Example npf config to redirect ports 80/443 to unprivileged ports
$ext_if = "vioif0"
$ext_v4 = inet4(vioif0)
map $ext_if dynamic XXX.XXX.XXX.XXX port 8080 <- $ext_v4 port 80
map $ext_if dynamic XXX.XXX.XXX.XXX port 4443 <- $ext_v4 port 443
group default {
pass final on lo0 all
pass final on $ext_if all
}