Skip to content

Instantly share code, notes, and snippets.

View jasonwbarnett's full-sized avatar

Jason Barnett jasonwbarnett

View GitHub Profile
@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
@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)
@jasonwbarnett
jasonwbarnett / getopts.rb
Created August 6, 2013 22:04
copy and paste me when you need something like getopts in ruby.
require 'optparse'
options = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename($0)} [options]"
opts.on("-d", "--debug",
"Enables some helpful debugging output."
) { |value| options[:debug] = true }
file { '/etc/opendkim.conf':
ensure => present,
owner => root,
group => root,
mode => 644,
source => 'puppet:///modules/postfix/etc/opendkim.conf',
notify => [ Exec['execName'], Service['opendkim'] ],
}
#!/bin/bash
CACERTS_KEYSTORE="/usr/java/latest/jre/lib/security/cacerts"
wget http://www.startssl.com/certs/ca.pem
keytool -import -trustcacerts -file ca.pem -alias startssl_ca -keystore ${CACERTS_KEYSTORE}
@jasonwbarnett
jasonwbarnett / get-user-input-without-echoing-console-ruby.rb
Last active January 2, 2016 01:09
This is a gist that contains everything that's on my http://knowitnot.com site.
require 'io/console'
print "Please enter your password: "
password = STDIN.noecho(&:gets).chomp
puts ## This is here to add a line break after grabbing the user input