Skip to content

Instantly share code, notes, and snippets.

View caius's full-sized avatar
👻

Caius Durling caius

👻
View GitHub Profile
@caius
caius / .overcommit.yml
Created May 24, 2017 10:26
overcommit validate puppet syntax
PreCommit:
PuppetValidate:
enabled: true
description: 'Validates puppet syntax'
include: '**/*.pp'
repos=(
binder
mahi
manatee
manta
mdata-client
moray
mountain-gorilla
node-sdc-clients
node-smartdc-auth
<?php
// Looks up the IP address accessing us and prints rDNS record
$remote_ip = $_SERVER["REMOTE_ADDR"];
if (strstr($remote_ip, ', ')) {
$ips = explode(', ', $remote_ip);
$remote_ip = $ips[0];
}
#!/usr/bin/env bash
# Find puppet cattle running a specific branch via mco puppetd
#
# USAGE: puppetd_branch BRANCH
#
set -e
declare branch="$1"
[root@headnode (ovh-1) ~]# sdcadm experimental update -y --all -x sapi -x moray -x binder -x manatee
Finding candidate update images for 25 services (manta, adminui, ca, amon, napi,
vm-agent, dhcpd, amonredis, workflow, net-agent, cn-agent, vmapi, ufds, mahi, cloudapi,
imgapi, fwapi, sdc, cnapi, docker, papi, redis, dockerlogger, cns, assets).
Using channel support
Note: There are no "manta" instances. Only the service configuration will be updated.
This update will make the following changes:
download 1 image (193 MiB):
image 33eec75a-85e4-11e6-8c40-977055a06d03
@caius
caius / illumos.sh
Last active November 16, 2016 18:13
-bash-4.3$ cat projects/illumos/illumos.sh
NIGHTLY_OPTIONS="-CimMNnt"; export NIGHTLY_OPTIONS
GATE="joyent_20161116T172759Z"; export GATE
CODEMGR_WS="/home/caius/smartos-live/projects/illumos"; export CODEMGR_WS
MAX_JOBS=8; export MAX_JOBS
maxjobs() {
ncpu=`kstat -p cpu_info:::state | grep -c on-line`
if [[ $(( $ncpu + 2 )) -lt ${MAX_JOBS} ]]; then
expr $ncpu + 2
else
# USAGE:
# rubocop -r ./tmp/rubocop_default_args_assignment.rb --only Style/RubocopDefaultArgsAssigmment app/
#
# Finds method definitions like `def my_thing(date = date)` which are circular references in ruby 2.3.1
# Change them to `def my_thing(date = self.date)` to maintain behaviour
#
module RuboCop
module Cop
module Style
# Check if default args are circular assignments
require "benchmark/ips"
require "rdl"
def sum(a, b)
a + b
end
type '(Fixnum, Fixnum) -> Fixnum'
def sum_rdl(a, b)
a + b
@caius
caius / Makefile
Created July 6, 2016 15:50
Save edge router config & scripts to current directory
.PHONY: save save_config save_commands save_scripts
save:
make -j save_config save_commands save_scripts
save_config:
ssh earl "/opt/vyatta/bin/vyatta-op-cmd-wrapper show configuration" 2> /dev/null > config.txt
save_commands:
ssh earl "/opt/vyatta/bin/vyatta-op-cmd-wrapper show configuration commands" 2> /dev/null > commands.txt
#!/usr/bin/env ruby
# Converts a markdown file from 4-space code blocks to ``` gated code blocks.
# aka, normal markdown code blocks to Github Formatted markdown code blocks.
#
# Usage:
#
# ruby gfm_code_block.rb path/to/file.md
#