Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
hackin'

Benjamin E. Coe bcoe

💭
hackin'
View GitHub Profile
@bcoe
bcoe / semaphore.rb
Last active Aug 29, 2015
Semaphore using EventMachine gratifications.
View semaphore.rb
# 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.
View keybase.md

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 Apr 11, 2014
Check vnstat for bandwidth usage.
View check_bandwidth.sh
#!/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 Apr 26, 2014
Using custom builds from our PPA
View custom.markdown

Add the repository:

- name: "add our custom package repository"
  sudo: true
  apt_repository: >
    repo='ppa:bencoe/ppa'
    state=present
View .pbuilderrc
COMPONENTS="main restricted universe multiverse"
@bcoe
bcoe / eample-package.json
Created May 8, 2014
example-package.json
View eample-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
restify-hello-world.js
View 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.
View 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 / callback-hell.js
Created May 11, 2014
callback-hell.js
View callback-hell.js
a(b, function(err, c) {
// wait for a to finish.
d(c, function(err, e) {
// wait for d to finish.
f(e, function(err, g) {
// do something with the result of f.
})
})
})
View 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);
}