Skip to content

Instantly share code, notes, and snippets.

@trentm
trentm / manual-sdcadm-self-update.sh
Created November 6, 2015 18:11
manual install of latest sdcadm (for https://joyent.com/triton)
updates-imgadm get-file -o latest-sdcadm.sh $(updates-imgadm list name=sdcadm --latest -H -o uuid)
bash latest-sdcadm.sh
@trentm
trentm / hacktime.js
Created September 8, 2015 04:09
Show a Bunyan raw stream that hacks 'rec.time' to a custom format, if desired.
var bunyan = require('./');
function HackTimeStream(stream) {
this.stream = stream || process.stderr;
}
HackTimeStream.prototype.write = function write(rec) {
rec.time += 'wallawalla';
this.stream.write(JSON.stringify(rec) + '\n');
};
@trentm
trentm / magic.js
Created March 24, 2015 02:35
compressed file type detection using magic numbers. Wrote it. Don't need it right now.
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at http://smartos.org/CDDL
*
a: I have 1854430734d43a of smartos-live in the platform that I'm building for testing ... Do I need to update?
b: yes. That's ancient. :)
a: It's like 10 days old!
b: 10 whole days!!!
a: flip table
@trentm
trentm / hack.bash
Created November 6, 2014 18:45
Hack SmartDataCenter's CNAPI (historically this chunk of functionality was called DAPI) to allow "customer" provisioning (i.e. via cloudapi) on the headnode for dev/testing.
function hack_dapi_for_headnode_provisioning {
local cnapi_zone=\$(vmadm lookup -1 alias=cnapi0)
# TODO: don't change if already done
echo "# Hack DAPI to allow headnode provisioning"
local config_path=/zones/\$cnapi_zone/root/opt/smartdc/cnapi/sapi_manifests/cnapi/template
sed -e "
s:hard-filter-headnode:identity:g;
s:hard-filter-min-ram:identity:g;
s:hard-filter-min-disk:identity:g;
s:hard-filter-min-cpu:identity:g;
$ echo quote what? ; read quoteme ; printf %q "$quoteme" ; echo
quote what?
The horse said "$)#*@(!!%" when he stubbed his hoof.
The\ horse\ said\ \"\$\)#\*@\(\!\!%\"\ when\ he\ stubbed\ his\ hoof.
$

Keybase proof

I hereby claim:

  • I am trentm on github.
  • I am trentm (https://keybase.io/trentm) on keybase.
  • I have a public key whose fingerprint is 89FB E5A2 CF9E C32D 9D53 746C 3608 1DFD 9D74 41BA

To claim this, I am signing this object:

@trentm
trentm / googl.sh
Created July 31, 2013 22:27
Bash function to use the goo.gl URL shortener on stdin. See <https://developers.google.com/url-shortener/v1/getting_started> TODO: pbcopy it too if that command is available
# echo URL | googl
function googl {
local url=$(cat <&0)
(
set -e pipefail;
echo "{}" \
| json -e "this.longUrl='$url'" \
| curl -sf https://www.googleapis.com/urlshortener/v1/url \
-H 'Content-Type: application/json' -d@- \
| json id
---
hr:
- Mark McGwire
# Following node labeled SS
- &SS Sammy Sosa
rbi:
- *SS # Subsequent occurrence
- Ken Griffey
[root@d632a4c8-2a8d-44bd-842d-f898fe95271c ~/src/node]# uname -a
SunOS d632a4c8-2a8d-44bd-842d-f898fe95271c.local 5.11 joyent_20120424T232010Z i86pc i386 i86pc Solaris
[root@d632a4c8-2a8d-44bd-842d-f898fe95271c ~/src/node]# gcc --version
gcc (GCC) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[root@d632a4c8-2a8d-44bd-842d-f898fe95271c ~/src/node]# git log -1
commit 771ba34ca7b839add2ef96879e1ffc684813cf7c