Skip to content

Instantly share code, notes, and snippets.

Travis Paul travispaul

Block or report user

Report or block travispaul

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@travispaul
travispaul / test.sh
Last active Aug 3, 2019
Setting a default value for $@ (sh vs dash vs ksh vs bash)
View test.sh
#!/bin/sh
#!/bin/ksh
#!/usr/pkg/bin/dash
#!/usr/pkg/bin/bash
somefn() {
local args="${@:-something}"
echo "Value of \$args: $args"
}
View local-pkgin.txt
root@netbsd# pkgin -v
pkgin 0.10.1 for NetBSD-7.1.2 x86_64 (using SQLite 3.8.3.1)
root@netbsd# pkgin -f -y in rsync
pkg_summary.bz2 0% 0 0.0KB/s --:-- ETA
cleaning database from http://192.168.1.60/netbsd-7/current/packages/All entries...
pkg_summary.bz2 100% 39KB 39.1KB/s 00:00
empty available packages list
nothing to do.
@travispaul
travispaul / patch-salt_grains_core.py.patch
Created May 11, 2018
sysutils/salt/patches/patch-salt_grains_core.py
View patch-salt_grains_core.py.patch
$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
View notes.txt
httpd -X
<b>Warning</b>: PHP Startup: Unable to load dynamic library 'pdo.so' (tried: /opt/pkg/lib/php/20170718/pdo.so (dlopen(/opt/pkg/lib/php/20170718/pdo.so, 9): Symbol not found: _executor_globals
Referenced from: /opt/pkg/lib/php/20170718/pdo.so
Expected in: flat namespace
in /opt/pkg/lib/php/20170718/pdo.so), /opt/pkg/lib/php/20170718/pdo.so.so (dlopen(/opt/pkg/lib/php/20170718/pdo.so.so, 9): image not found)) in <b>Unknown</b> on line <b>0</b><br />
Installed:
php72-pdo_mysql-7.2.4 = PHP extension for PHP Data Objects (MySQL)
php72-pdo-7.2.4 = PHP extension for PHP Data Objects (base)
php72-mysqli-7.2.4 = PHP5 extension for MySQL 4.1 and later databases
@travispaul
travispaul / answer.md
Last active Jan 26, 2018
module.exports how to return a function value?
View answer.md

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 Oct 2, 2017
Alias for copying commits between forks
View copycommit.sh
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 Jul 13, 2017
Cowsay test bot for MatterMost outgoing webhook
View cowsay9k.js
// 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
Networking config for Beaglebone Black
View bbb.md
# 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 Mar 30, 2017
Example npf config to redirect ports 80/443 to unprivileged ports
View npf.conf
$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
}
@travispaul
travispaul / all-the-rules.sh
Created Feb 9, 2017
Create an RBAC policy with ALL rules (for testing)
View all-the-rules.sh
sdc-policy create --name='kitchensink' --rules='can putdirectory' --rules='can getdirectory' --rules='can deletedirectory' --rules='can putobject' --rules='can getobject' --rules='can deleteobject' --rules='can putlink' --rules='can createjob' --rules='can listjobs' --rules='can getjob' --rules='can managejob' --rules='can getaccount' --rules='can updateaccount' --rules='can listkeys' --rules='can getkey' --rules='can createkey' --rules='can deletekey' --rules='can listusers' --rules='can getuser' --rules='can createuser' --rules='can updateuser' --rules='can changeuserpassword' --rules='can deleteuser' --rules='can listroles' --rules='can getrole' --rules='can createrole' --rules='can updaterole' --rules='can deleterole' --rules='can setroletags' --rules='can listpolicies' --rules='can getpolicy' --rules='can createpolicy' --rules='can updatepolicy' --rules='can deletepolicy' --rules='can listuserkeys' --rules='can getuserkey' --rules='can createuserkey' --rules='can deleteuserkey' --rules='can listdatacente
You can’t perform that action at this time.