Skip to content

Instantly share code, notes, and snippets.

View kidbrax's full-sized avatar

Braxton Beyer kidbrax

View GitHub Profile
@kidbrax
kidbrax / bundle-to-ebs.sh
Created January 14, 2010 23:56 — forked from fairchild/bundle-to-ebs.sh
bundle instance to ebs #shell
#!/bin/bash -xe
EBS_DEVICE='/dev/sdh'
INSTANCE_ID=$1
AKI=${2:-'aki-5f15f636'}
ARI=${3:-'ari-0915f660'}
ARCH=${4:-'i386'}
SIZE=${5:-10}
AZ=${6:-'us-east-1d'}
NAME=${7:-"ami-from-$INSTANCE_ID"}
@kidbrax
kidbrax / toCurrency.js
Created February 10, 2011 14:39
Converts a number to currency format. Based on Alex G's comment at http://www.selfcontained.us/2008/04/22/format-currency-in-javascript-simplified/
function toCurrency(num) {
var sign;
var cents;
var i;
num = num.toString().replace(/\$|\,/g, '');
if (isNaN(num)) {
num = "0";
}
sign = (num == (num = Math.abs(num)));
@kidbrax
kidbrax / librets.rb
Created June 15, 2011 23:58
homebrew formulas for librets
require 'formula'
class Librets < Formula
url 'http://www.crt.realtors.org/projects/rets/librets/files/librets-1.5.2.tar.gz'
homepage 'http://code.crt.realtors.org/projects/librets'
md5 '74bcea0eb11f3c66cde5dc3ecea05224'
depends_on 'boost'
depends_on 'curl'
depends_on 'expat'
@kidbrax
kidbrax / convert.js
Created July 28, 2011 16:29
convert multiple fields on form submit
$('#formId').submit(function() {
newValue = toCurrency($('#filed1Id').val())
newValue2 = toCurrency($('#field2Id').val())
return false;
});
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
if (this.originalType) {
this.type = this.originalType;
delete this.originalType;
}
input.val('');
input.removeClass('placeholder');
}
@kidbrax
kidbrax / point-in-polygon.rb
Created September 22, 2011 22:43
Check whether a point is within a polygon #ruby
def point_in_polygon?(polygonPoints)
return false if self.latitude.blank? or self.longitude.blank?
polygonPoints.each do |point|
point[0] = point[0].to_f
point[1] = point[1].to_f
end
contains_point = false
i = -1
j = polygonPoints.size - 1
@kidbrax
kidbrax / gist:3409263
Created August 20, 2012 23:35
error installing librets with homebrew
~$ brew install librets
==> Downloading http://www.crt.realtors.org/projects/rets/librets/files/librets-1.5.3.tar.gz
Already downloaded: /Library/Caches/Homebrew/librets-1.5.3.tar.gz
==> ./configure --disable-debug --enable-shared_dependencies --prefix=/usr/local/Cellar/librets/1.5.3 --disable-dotnet --disable-java --disable-perl --disable-php --disable-python
==> make install
/usr/bin/clang++ -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8 -fPIC -DHAVE_CONFIG_H -DTARGET_UNIX -DLIBRETS_VERSION='"1.5.3"' -isystem /usr/local/include -I/usr/include -I/usr/local/include -I./project/librets/include -c project/librets/src/AndCriterion.cpp -o build/librets/objects/AndCriterion.o
/usr/bin/clang++ -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.8 -fPIC -DHAVE_CONFIG_H -DTARGET_UNIX -DLIBRETS_VERSION='"1.5.3"' -isystem /usr/local/include -I/usr/include -I/usr/local/include -I./project/librets/include -c project/librets/src/BinaryData.cpp -o build/librets/objects/Bin
@kidbrax
kidbrax / demo.coffee
Last active April 27, 2020 15:27
demo http server #coffee
http = require("http")
PORT = process.env.PORT or 3000
http.createServer((req, res) ->
console.log "%d request received", process.pid
res.writeHead 200,
"Content-Type": "text/plain"
res.end "Hello world!\n"
return
@kidbrax
kidbrax / get-ami.sh
Created January 24, 2018 04:00
Get ID of AMI created using Packer
# assuming you use a manifest file such as:
# "post-processors": [
# {
# "type": "manifest",
# "output": "manifest.json",
# "strip_path": true
# }
# ]
new_ami_id=$(cat manifest.json | jq -r '.builds | .[length-1].artifact_id' | cut -d ':' -f 2)
@kidbrax
kidbrax / github-api.sh
Created January 26, 2018 05:37
useful commands for getting info from Github using their API
# get all private repos whose default branch is master (note pagination)
curl -H "Authorization: token <auth-token>" \
https://api.github.com/orgs/arthrex/repos?type=private \
| jq '.[] | select(.default_branch | contains("master")) | .name, .default_branch'