Skip to content

Instantly share code, notes, and snippets.

View jasonwbarnett's full-sized avatar

Jason Barnett jasonwbarnett

View GitHub Profile
module HashConverter
class << self
def to_underscore hash
convert hash, :underscore
end
def to_camel_case hash
convert hash, :camelize
end
def convert obj, *method
case obj
@jasonwbarnett
jasonwbarnett / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
def mad_based_outlier(points, thresh=3.5):
if len(points.shape) == 1:
points = points[:,None]
median = np.median(points, axis=0)
diff = np.sum((points - median)**2, axis=-1)
diff = np.sqrt(diff)
med_abs_deviation = np.median(diff)
modified_z_score = 0.6745 * diff / med_abs_deviation
@jasonwbarnett
jasonwbarnett / main.go
Created May 29, 2015 19:19
This is an example of how we might nest multiple mux.Routers. This is especially useful if we want to later wrap our nested router with Negroni.
package hello
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
)
func init() {
@jasonwbarnett
jasonwbarnett / gist:2432058
Created April 20, 2012 21:39
Workaround for puppet bug 9361
class updated::config {
file { '/updated/bin/':
ensure => directory,
recurse => true,
purge => true,
force => true,
owner => root,
group => root,
mode => 775,
@jasonwbarnett
jasonwbarnett / sendgmail.rb
Created January 15, 2013 02:27
A script I found at http://www.jayway.com/2010/01/16/scripting-in-ruby/ and I made a few "necessary" changes.
#!/usr/bin/env ruby
# Use the currently configured ruby version
# I could not get this to work on v1.8.7, only v1.9.3
# optparse contains OptionParser, ostruct: OpenStruct and growl Growl
require 'optparse'
require 'ostruct'
require 'growl'
# This is the name of the script that is called
@jasonwbarnett
jasonwbarnett / nginx configuration
Last active December 12, 2015 06:09
nginx configuration for site with auth_ldap OR allow/deny.
server {
listen 80;
server_name accessphase.mydomain.com;
rewrite ^ https://accessphase.mydomain.com$request_uri permanent;
}
server {
listen 192.168.97.208:443;
server_name accessphase.mydomain.com;
root /opt/nginx/accessphase.mydomain.com/public_html;
#!/bin/bash
srpm_url=$1
srpm=`basename $srpm_url`
srpm_name=`echo $srpm | sed -r 's|-[0-9]+.*$||g'`
cat <<EOF
## Setting up tree for: ##
##########################
#!/bin/bash
# on centos minimal
yum install gcc
yum install make
yum install ncurses-devel
yum install lua lua-devel
yum install ruby ruby-devel
yum install python python-devel
yum install perl perl-devel