Skip to content

Instantly share code, notes, and snippets.

View jasonpincin's full-sized avatar
🌎

Jason Pincin jasonpincin

🌎
View GitHub Profile
@jasonpincin
jasonpincin / vmip.sh
Created February 7, 2013 00:12
Updates IP addresses of a SmartOS VM (with less hassle)
#!/usr/bin/bash
# Updates IP addresses of a SmartOS VM
# This script stops the VM, updates the IP address(es),
# and starts the VM back up.
#
# Usage:
# vmip.sh <uuid> <ip1> [ip2] [ip3] [...]
#
# The IP's are applied to NICs of the VM in order. The
@jasonpincin
jasonpincin / vmid
Last active December 12, 2015 12:28
Get UUID of a SmartOS VM given it's alias
#!/usr/bin/sh
#
# Given a SmartOS VM alias, returns the UUID.
#
# Usage:
#
# vmid <alias>
#
# vmadm get `vmid <alias>`
#
@jasonpincin
jasonpincin / vmmv
Created February 13, 2013 16:42
Moves a SmartOS VM to a different SmartOS host
#!/usr/bin/bash
# Moves a SmartOS VM to a different host
# This script stops the VM, sends it to the target host,
# imports it on the target host, and starts it on the
# target host. It is your responsibility to remove it on
# the origin host after confirming the script worked as
# expected.
#
# Usage:
@jasonpincin
jasonpincin / import-image
Last active December 13, 2015 18:49
Helper utility for smartos-image-server (https://github.com/nshalman/smartos-image-server) that makes publishing new images a one-line breeze! For the global-zone companion script, see: https://gist.github.com/jasonpincin/4958099
#!/usr/bin/bash
#
# import-image (https://gist.github.com/jasonpincin/4958050)
#
# Helper utility for smartos-image-server
# https://github.com/nshalman/smartos-image-server
#
# Global-zone companion script available:
# https://gist.github.com/jasonpincin/4958099
#
@jasonpincin
jasonpincin / mkimg
Last active December 13, 2015 18:49
Companion script to import-image script (https://gist.github.com/jasonpincin/4958050), this script is intended for running against VM's in the global zone. It will snapshot them, and send them off to the image server (equipped with the import-image script).
#!/usr/bin/bash
# Creates an image from a VM
# WARNING: You should run sm-prepare-image inside the zone
# BEFORE running this script!
#
# This script requires the smartos-image-server to be
# equipped with the import-image script:
# https://gist.github.com/jasonpincin/4958050
#
@jasonpincin
jasonpincin / test_spec.js
Created July 2, 2013 23:54
jasmine test with tap output
if (require.main === module) {
var _t = require('jasmine-node').getEnv()
_t.addReporter(new (require('jasmine-tapreporter'))(console.log))
process.nextTick(_t.execute.bind(_t))
}
describe('something', function () {
it('should do something', function () {
})
@jasonpincin
jasonpincin / gist:6135060
Created August 1, 2013 20:38
Enable tap reporting for jasmine-node
if (require.main === module) {
var _t = require('jasmine-node').getEnv()
_t.addReporter(new (require('jasmine-tapreporter'))(console.log))
process.nextTick(_t.execute.bind(_t))
}
@jasonpincin
jasonpincin / server.js
Last active August 29, 2015 13:57
rpc server using dnode, shoe, node-static
var http = require('http')
var shoe = require('shoe')
var dnode = require('dnode')
var static = require('node-static')
var content = new static.Server(__dirname+'/static')
var server = http.createServer(content.serve.bind(content))
var socket = shoe(function (connection) {
// expose two methods: getTime and square
var api = dnode({
@jasonpincin
jasonpincin / client.js
Last active August 29, 2015 13:57
rpc client using dnode, shoe
var shoe = require('shoe')
var dnode = require('dnode')
var document = require('global/document')
var onTime = function (err, time) {
document.getElementById('time').innerHTML = time
}
var onSquare = function (err, val) {
document.getElementById('square').innerHTML = val
}
@jasonpincin
jasonpincin / index.html
Created March 18, 2014 05:00
sample index.html for rpc demo
<html>
<head>
<title>RPC Example</title>
<script type="text/javascript" src="bundle.js"></script>
</head>
<body>
<div id="time" />
<div id="square" />
</body>
</html>