Skip to content

Instantly share code, notes, and snippets.

Avatar

Bryan Berry bryanwb

View GitHub Profile
View login.js
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;
View wdfun.js
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 Feb 21, 2015
sbt shell script
View sbt
#!/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 Jul 9, 2015
how to DRY this up?
View vpc.yml
- 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 Aug 18, 2015
error message for go vet
View err.msg
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 Sep 3, 2015
modifying a dictionary in a loop
View bad.yml
# 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 %}
View Compressing and Concatenating JS
// 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
View simple markup
<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>
View gist:314503
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);
}
});
}}
View reverse.c
/* 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){