Skip to content

Instantly share code, notes, and snippets.

View jvoorhis's full-sized avatar

Jeremy Voorhis jvoorhis

View GitHub Profile
@jvoorhis
jvoorhis / gist:1428465
Created December 3, 2011 23:15 — forked from lhitchon/gist:1424751
PHP MongoLab sample
<html>
<head>
<title>Demo</title>
</head>
<body>
<h1>PHP Mongo Test</h1>
<?php
try {
$connect = $_ENV["MONGOLAB_URI"];
$m = new Mongo($connect);
#!/usr/bin/env ruby
=begin lit
# Introducing Lit
Lit allows developers to embed Markdown in their comments, and extracts
it for them to produce human friendly documentation.
=end
require 'rubygems'
" Line width nags
hi OverLength ctermbg=red ctermfg=white
let line_width_nag=0
function! ToggleLineWidthNags()
if g:line_width_nag==0
match OverLength /\%80v.\+/
let g:line_width_nag=1
else
match OverLength //
let g:line_width_nag=0
[7] pry(main)> ls 42
Comparable#methods: between?
Numeric#methods: +@ abs2 angle arg coerce conj conjugate eql? i imag imaginary nonzero? phase polar pretty_print pretty_print_cycle quo real real? rect rectangular remainder singleton_method_added step to_c
Integer#methods: ceil chr denominator downto floor gcd gcdlcm integer? lcm next numerator ord pred rationalize round times to_i to_int to_r truncate upto
Fixnum#methods: % & * ** + - -@ / < << <= <=> == === > >= >> [] ^ abs div divmod even? fdiv magnitude modulo odd? size succ to_f to_s zero? | ~
if usage[:cpu] > BEGIN_RENICE_CPU_THRESHOLD
nice = (instance[:nice] || 0) + 1
if nice < MAX_RENICE_VALUE
instance[:nice] = nice
@logger.info("Lowering priority on CPU bound process(#{instance[:name]}), new value:#{nice}")
%x[renice #{nice} -u #{instance[:secure_user]}]
end
end
~/Projects/mote % cat misc/mote.yml
sensors:
- Mem
- Load
- Disk
outputs:
- Stdout
~/Projects/mote % ./bin/mote -c misc/mote.yml
{"timestamp":"2012-08-21 13:37:13 -0700","sensor":"mem","values":{"total":8589934592,"used":8567566336,"free":22368256}}
@jvoorhis
jvoorhis / chef_server_backup.rb
Created November 13, 2012 22:43
knife exec chef_server_backup.rb
#
# Author:: Joshua Timberman (<[email protected]>)
# Author:: Adam Jacob (<[email protected]>)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@jvoorhis
jvoorhis / config.rb
Created January 18, 2013 06:25
Sample llvm/config.rb
module LLVM
module CONFIG
VERSION = "3.2"
PREFIX = "/usr/local/Cellar/llvm/3.2"
SRC_ROOT = "/private/tmp/llvm-U6Ok/llvm-3.2.src"
OBJ_ROOT = "/private/tmp/llvm-U6Ok/llvm-3.2.src"
BIN_DIR = "/usr/local/Cellar/llvm/3.2/bin"
INCLUDE_DIR = "/usr/local/Cellar/llvm/3.2/include"
LIB_DIR = "/usr/local/Cellar/llvm/3.2/lib"
CPP_FLAGS = ["-I/usr/local/Cellar/llvm/3.2/include", "-D_DEBUG", "-D_GNU_SOURCE", "-D__STDC_CONSTANT_MACROS", "-D__STDC_FORMAT_MACROS", "-D__STDC_LIMIT_MACROS"]
@jvoorhis
jvoorhis / routes.rb
Created February 11, 2013 23:46
Static asset resource for webmachine.rb
app.routes do
add ['*'], Resources::Static
end
$ free -h
total used free shared buffers cached
Mem: 114G 1.6G 113G 0B 24M 754M
-/+ buffers/cache: 815M 114G
Swap: 0B 0B 0B