Skip to content

Instantly share code, notes, and snippets.

View bryanwb's full-sized avatar

Bryan Berry bryanwb

View GitHub Profile
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
chai.should();
var wd = require('wd');
// enables chai assertion chaining
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
var fs = require('fs');
var rmrf = require('rimraf');
var path = require('path');
var Q = require('q');
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
chai.should();
@bryanwb
bryanwb / sbt
Created February 21, 2015 14:55
sbt shell script
#!/bin/sh
if [ -f "$HOME/.sbtconfig" ]; then
echo "Use of ~/.sbtconfig is deprecated, please migrate global settings to /usr/local/etc/sbtopts" >&2 . "$HOME/.sbtconfig"
fi
exec "/usr/local/Cellar/sbt/0.13.7/libexec/sbt" "$
@bryanwb
bryanwb / vpc.yml
Created July 9, 2015 10:05
how to DRY this up?
- command: "aws ec2 describe-subnets --filters Name=tag:Tier,Values=pub Name=vpc-id,Values={{aws_vpc_id}}"
register: awscli
- set_fact:
pub_subnets: "{{awscli.stdout | from_json}}"
- set_fact:
pub_subnet: "{{pub_subnets['Subnets']|first}}"
- set_fact:
pub_subnet_id: "{{pub_subnet['SubnetId']}}"
@bryanwb
bryanwb / err.msg
Created August 18, 2015 11:31
error message for go vet
hitman@Bryans-MacBook-Pro:~/pr/sellsword$ go vet github.com/bryanwb/sellsword
vet: error walking tree: stat ../go/src/github.com/bryanwb/sellsword/app.go: no such file or directory
vet: error walking tree: stat ../go/src/github.com/bryanwb/sellsword/appset.go: no such file or directory
vet: error walking tree: stat ../go/src/github.com/bryanwb/sellsword/env.go: no such file or directory
vet: ../go/src/github.com/bryanwb/sellsword/app.go: open ../go/src/github.com/bryanwb/sellsword/app.go: no such file or directory
vet: no files checked
exit status 1
@bryanwb
bryanwb / bad.yml
Last active September 3, 2015 13:35
modifying a dictionary in a loop
# this fails on the "set" tag
- set_fact: instances="{%- set instances = dict() %}
{%- for group in group_names %}
{%- for host in groups[group] %}
{%- if hostvars[host].get('InstanceId', None) %}
{%- if hostvars[host].get('Platform', None) == 'windows' %}
{%- set tmp = instances.setdefault(host, hostvars[host]['InstanceId']) %}
{%- endif %}
{%- endif %}
{%- endfor %}
// hope this answers your question
//first follow the instructions for setting up narwhal
// http://karmaeducation.org/2010/01/15/getting-started-with-narwhal-a-standard-library-for-javascript/
//update your catalog of available commonJS packages
// tusk is a lot like ruby's 'gem' command
$ tusk update
//then install yuicompressor, shrinksafe others
<body>
<div id="kHeader">
</div>
<!-- Put the help text here -->
<div id="kHelpText" title="Help Title"> Help text here</div>
<div id="feedback"></div>
<div id="gameArea">
<div id="questionBox">What is this?</div>
function divide(a, b) { return function (callback, errback) {
// Use nextTick to prove that we're working asynchronously
process.nextTick(function () {
if (b === 0) {
errback(new Error("Cannot divide by 0"));
} else {
callback(a / b);
}
});
}}
/* reverse: reverse string s in place */
void reverse(char *s)
{
int j = 0;
int temp = 0;
char *i = s;
s += strlen(s) - 1;
while (s != i){