Skip to content

Instantly share code, notes, and snippets.

View jasonwbarnett's full-sized avatar

Jason Barnett jasonwbarnett

View GitHub Profile
@jasonwbarnett
jasonwbarnett / mutt_and_gmail_smtp.sh
Last active August 29, 2015 13:57
This is how you can use mutt with a gmail account to send email at the command line.
## Install homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
## Run brew doctor to make sure everything is ok
brew doctor
## Install mutt
brew install mutt
## Setup your .muttrc file with the gmail smtp info:
@jasonwbarnett
jasonwbarnett / ssh_proxy.sh
Created August 7, 2014 16:47
How to SSH proxy through another host
jbarnett@Hackintosh-10 ~ $ cat ~/.ssh/config
Host r176.spigit.com r178.spigit.com
ProxyCommand ssh -T operations002.c.mindjet-gce-stack.internal 'nc %h %p'
jbarnett@Hackintosh-10 ~ $
@jasonwbarnett
jasonwbarnett / install_mysql-server_bin.sh
Last active August 29, 2015 14:05
This can be used to install MySQL Server from the bin distribution.
#!/bin/bash
# Author: Jason Barnett <J@sonBarnett.com>
#
# The MIT License (MIT)
#
# Copyright (c) 2014 Jason Barnett
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@jasonwbarnett
jasonwbarnett / equal_div.rb
Last active December 20, 2015 16:29
This will take a starting number, ending number, and group size and it will return an array of groups [rangeStart, rangeEnd]
# Example use:
#
# 1.9.3p392 :000 > equal_div(432,239842934,22)
# => [[432, 10902364], [10902365, 21804297], [21804298, 32706230], [32706231, 43608163], [43608164, 54510096], [54510097, 65412029], [65412030, 76313962], [76313963, 87215895], [87215896, 98117828], [98117829, 109019761], [109019762, 119921694], [119921695, 130823627], [130823628, 141725560], [141725561, 152627493], [152627494, 163529426], [163529427, 174431359], [174431360, 185333292], [185333293, 196235225], [196235226, 207137158], [207137159, 218039091], [218039092, 228941024], [228941025, 239842934]]
#
# 1.9.3p392 :001 > equal_div(432,239842934,4)
# => [[432, 59961058], [59961059, 119921685], [119921686, 179882312], [179882313, 239842934]]
#
def equal_div(first, last, num_of_groups)
@jeremyjarrell
jeremyjarrell / Prefix migrations with timestamp Ant task
Last active May 15, 2017 15:53
An Ant task that prefixes new SQL migration files with a timestamp precise to milliseconds. The following usage will add a prefix to any SQL file in a hardcoded directory that does not begin with an number and double leading underscore: $ ant prefix-new-migrations
<project name="migrations">
<target name="prefix-new-migrations">
<foreach target="rename-file" param="the-file">
<path>
<!-- The hardcoded directory containing the migrations -->
<fileset dir="./src/db/migrations" casesensitive="no" includes="*.sql">
<!-- Exclude any migration files which have already been prefixed -->
<not>
<filename regex="\d+__.*" casesensitive="true"/>

Notifications from Resources "Bubble Up"

Release in Chef 12.9.41 via PR #4741 core chef now has a feature which has been available in Poise for awhile, which is that notifications from within resources will now notify resources in outer run contexts. This means you can write a recipe with a service resource and send a notification to it from a resource that you write.

Notifications will bubble up from arbitrarily nested resources, so users that write resources that wrap resources which wrap your resource will still find the service resource in your default recipe.

At the same time the resources collection #find() and #lookup methods and the more commonly-used DSL method resources("service[ntpd]") has been changed to also match

@niklasvincent
niklasvincent / build-nginx.sh
Last active October 11, 2019 04:44
Build script for statically compiled nginx 1.4.7 with OpenSSL 1.0.1e.
#!/bin/bash
set -e
NGINX_VERSION="1.6.0"
NGINX_TARBALL="nginx-${NGINX_VERSION}.tar.gz"
PCRE_VERSION="8.34"
PCRE_TARBALL="pcre-${PCRE_VERSION}.tar.gz"
OPENSSL_VERSION="1.0.1g"
OPENSSL_TARBALL="openssl-${OPENSSL_VERSION}.tar.gz"
@meonkeys
meonkeys / topCollections.js
Created November 26, 2012 22:02
List largest MongoDB collections
// I wanted to know the top five largest collections in my MongoDB database in
// terms of document count. This MongoDB-specific JavaScript gets the job done.
//
// Edit variables in the config section, then execute like so:
//
// mongo --quiet topCollections.js
// config
var dbname = 'FIXME';

Prerequisites

You'll need to have a system running that is accessible through a DNS record. It should have access to the public Habitat depot, https://app.habitat.sh so it can download the required packages.

You'll need to register an OAuth application for GitHub. You need the client ID and client secret that are created for the application later in this guide. Your system needs to have access to https://github.com so that it can authenticate.

Your system also needs to have an FQDN that can be resolved, for example depot.example.com. This will be used in your OAuth application's "Authorization Callback URL." For this example, use http://depot.example.com/#/sign-in. The /#/sign-in is required.

Operating System

@dentearl
dentearl / gist:3278446
Last active May 8, 2020 17:53
bash loop to run tons of jobs but limit the background to a certain smaller number at a time. change the -gt 0 to be -gt _n_ to limit the number of background jobs to _n_
# primate version
for f in ../packagePrimates/analysis/comparatorWrapper-primates.*/; do
for c in A B C D; do
##########
# This block holds the background process count in check
while [ $(jobs | wc -l) -gt 0 ]; do
sleep 2;
done;
##########
for partner in simChimp simGorilla simOrang; do