Skip to content

Instantly share code, notes, and snippets.

View bcoe's full-sized avatar
💭
hackin'

Benjamin E. Coe bcoe

💭
hackin'
View GitHub Profile
@bcoe
bcoe / semaphore.rb
Last active August 29, 2015 13:56
Semaphore using EventMachine gratifications.
# Execute an IMAP command from the frontend
# API on a specific user's ImapConnection.
#
# @param command [symbol] the command to execute.
# @param params [Hash] the parameters for the command.
def execute_imap_command(command, params)
log_info("executing #{command} for #{email}")
# we should re-select the mailbox
# once per command executed.

Keybase proof

I hereby claim:

  • I am bcoe on github.
  • I am coe (https://keybase.io/coe) on keybase.
  • I have a public key whose fingerprint is 29C5 CC8F 0FB0 261B 6672 449B 85DD 5E99 7DD2 3EEE

To claim this, I am signing this object:

@bcoe
bcoe / check_bandwidth.sh
Created April 11, 2014 17:57
Check vnstat for bandwidth usage.
#!/bin/bash
# script created by nsc
# usage ./bw_watch bw_warning bw_critical pkt_warning pkt_critical
# bw usage is in kbits/s
if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]] || [[ -z $4 ]]
then
echo "VARIABLES ARE NOT SET!!!"
echo "usage $0 bw_warning bw_critical pkt_warning pkt_critical"
echo "bw usage is in kbits/s"
@bcoe
bcoe / custom.markdown
Created April 26, 2014 21:58
Using custom builds from our PPA

Add the repository:

- name: "add our custom package repository"
  sudo: true
  apt_repository: >
    repo='ppa:bencoe/ppa'
    state=present
COMPONENTS="main restricted universe multiverse"
@bcoe
bcoe / eample-package.json
Created May 8, 2014 05:24
example-package.json
{
"name": "npm-typeahead",
"version": "0.0.0",
"description": "Perform typeahead searchs for npm packages.",
"main": "lib/index.js",
"scripts": {
"test": "./node_modules/.bin/mocha -u bdd"
},
"repository": {
"type": "git",
@bcoe
bcoe / restify-hello-world.js
Created May 8, 2014 05:49
restify-hello-world.js
var restify = require('restify'), // require the restify library.
server = restify.createServer(); // create an HTTP server.
// add a route that listens on http://localhost:5000/hello/world
server.get('/hello', function (req, res, cb) {
res.send("Hello World!");
return cb();
});
server.listen(process.env.PORT || 5000, function () { // bind server to port 5000.
@bcoe
bcoe / example-role.yml
Created May 9, 2014 21:36
example-role.yml
# Update and install dependent packages.
- name: install nagios' dependent packages
sudo: true
apt: pkg={{ item }} state=present force=true update_cache=yes
with_items: nagios_packages
- name: install legacy packages
sudo: true
apt: pkg={{ item }} state=present force=true update_cache=yes
with_items: nagios_legacy_packages
@bcoe
bcoe / server.js
Created May 11, 2014 18:22
server.js
var restify = require('restify'),
server = restify.createServer(),
search = new (require('./lib').Search);
// add the query-string parsing extension
// to restify.
server.use(restify.queryParser());
// lookup packages by their name.
server.get('/search', function(req, res, cb) {
@bcoe
bcoe / search.js
Created May 11, 2014 18:36
search.js
var _ = require('lodash'),
elasticsearch = require('elasticsearch');
function Search(opts) {
_.extend(this, {
client: new elasticsearch.Client({
host: process.env.ELASTIC_SEARCH_URL || 'localhost:9200'
})
}, opts);
}