Skip to content

Instantly share code, notes, and snippets.

View bbhoss's full-sized avatar
🎯
Focusing

Preston bbhoss

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am bbhoss on github.
  • I am bbhoss (https://keybase.io/bbhoss) on keybase.
  • I have a public key whose fingerprint is 4D8E F428 F96F A521 7A7D EF5B 01E6 E54A A5A8 67AB

To claim this, I am signing this object:

@bbhoss
bbhoss / fizzbuzz.fs
Created October 13, 2014 04:22
FizzBuzz in F#
// DivisibleBy Active Pattern special syntax for defining named patterns that can partition data
let (|DivisibleBy|_|) divisor i =
if i % divisor = 0 then Some () else None
// Use the pattern, easy.
for i in 1..100 do
match i with
| DivisibleBy 3 & DivisibleBy 5 -> printfn "FizzBuzz"
| DivisibleBy 3 -> printfn "Fizz"
| DivisibleBy 5 -> printfn "Buzz"
| _ -> printfn "%d" i
@bbhoss
bbhoss / sdc.py
Last active August 29, 2015 14:13
Joyent/SDC Ansible Module (WIP, not fully functional yet). I am not a Pythonista
#!/usr/bin/env python
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@bbhoss
bbhoss / privdebug.pl
Created January 21, 2015 17:43
Debug privileges of a process on Solaris/Illumos. Rescued from Wayback Machine
#!/usr/bin/perl
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
require 'rubygems'
require 'rack'
def application(env)
[200, {"Content-Type" => "text/html"}, ["Hello Rack!"]]
end
run method(:application)
{
"schedule": "R\/2014-09-25T17:22:00Z\/PT2M",
"name": "dockerjob",
"container": {
"type": "DOCKER",
"image": "libmesos/ubuntu",
},
"cpus": "0.5",
"mem": "512",
"command": "while sleep 10; do date =u %T; done"
(require 'smartparens)
(sp-with-modes '(elixir-mode)
(sp-local-pair "fn" "end"
:when '(("SPC" "RET"))
:actions '(insert navigate))
(sp-local-pair "do" "end"
:when '(("SPC" "RET"))
:post-handlers '(sp-ruby-def-post-handler)
:actions '(insert navigate)))
<h1>Register</h1>
<% form_for(@user) do |f| %>
<%= f.error_messages %>
<% f.fields_for :person do |g| %>
<p>
<%= g.label :firstname %><br />
<%= g.text_field :firstname %>
</p>
<% end %>
use Mix.Config
# Stop lager redirecting :error_logger messages
config :lager, :error_logger_redirect, false
# Stop lager removing Logger's :error_logger handler
config :lager, :error_logger_whitelist, [Logger.ErrorHandler]
# Stop lager writing a crash log
config :lager, :crash_log, false
# Use LagerLogger as lager's only handler.
config :lager, :handlers, [{LagerLogger, [level: :debug]}]
require 'bigdecimal'
#Set values to determine output based on how much % of memory is free
CRITICAL=5
WARNING=10
File.open "/proc/meminfo","r" do |line|
@memtotal = BigDecimal.new($1) if line.gets =~ /MemTotal:\s+(\d+)\s+kB/
@memfree = BigDecimal.new($1) if line.gets =~ /MemFree:\s+(\d+)\s+kB/
end
if @memtotal and @memfree
@free_percentage = ((@memfree/@memtotal)*100)