Skip to content

Instantly share code, notes, and snippets.

View caius's full-sized avatar

Caius Durling caius

View GitHub Profile
#!/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
#
# Turn a list of elements into a sentence listing them
#
# Expected outcomes:
# [] => ""
# %w(one) => "one"
# %(one two) => "one and two"
# %w(one two three) => "one, two and three"
#
def list_sentence(elements)
case elements.size
@caius
caius / a_output.txt
Created June 24, 2016 10:55
RabbitMQ nack behaviour
"Got 0 (false)"
"Got 1 (false)"
"Got 2 (true)"
"Got 3 (false)"
"Got 4 (false)"
"Got 5 (false)"
"Got 6 (false)"
"Got 7 (false)"
"Got 8 (false)"
"Got 9 (false)"
#!/usr/bin/env bash
# You could just `gem rdoc --all`, but where's the fun in that?
gem list | \
ruby -ne 'n, v = $_.scan(/(.+) \(([\d., ]+)\)/).first; next unless v; v = v.split(", "); puts Array.new(v.length) { n }.zip(v).map {|x| x.join(" -v ") }' | \
xargs -P$(sysctl -n hw.ncpu) -L1 gem rdoc
module CustomTypes
class SmfProperty < Serverspec::Type::Base
module Helper
def smf_property(fmri, group, property, options = {})
SmfProperty.new(fmri, group, property, options)
end
end
def initialize(fmri, group, property, options = {})
super("#{fmri}-#{group}/#{property}", options)
@caius
caius / centos.txt
Created April 29, 2016 11:16
`cp -r` with a symlink on CentOS vs SmartOS
$ uname
Linux
$ mkdir -p 1/ 2/ shared/assets
$ ln -s `pwd`/shared/assets `pwd`/1/assets
$ ls -l 1/ 2/ shared/
1/:
total 0
begin
thing_2 # =>
rescue Exception => e
e # => #<NameError: undefined local variable or method `thing_2' for main:Object
end
if true
thing_1 = 1 # !> assigned but unused variable - thing_1
else
thing_2 = 2
# Skips the foreman line starting "tomcat:", runs everything else in the Procfile
foreman start -c $(awk -F: 'NR > 1 { printf "," }; $1 != "tomcat" { printf $1 "=1" }' Procfile)
class person(
$first_name,
$second_name,
$full_name = "${first_name} ${second_name}",
$prenom = $first_name
) {
notify { "first_name: ${first_name}": }
notify { "second_name: ${second_name}": }
notify { "full_name: ${full_name}": }
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.7/react-dom.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-router/1.0.3/ReactRouter.js" type="text/javascript" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/history/2.0.0/History.js" type="text/javascript" charset="utf-8"></script>
<script type="text/babel">