Skip to content

Instantly share code, notes, and snippets.

View nmische's full-sized avatar

Nathan Mische nmische

  • Philadelphia, PA
  • 05:38 (UTC -05:00)
View GitHub Profile
@nmische
nmische / probability.rb
Last active December 16, 2015 23:19
Given a string list all the two letter pairs. Also, give the probability of a third letter following a given pair.
input = "If you are self-motivated, wow, this world is tailored for you. The boundaries are all gone. But if you're not self-motivated, this world will be a challenge because the walls, ceilings and floors that protected people are also disappearing. That is what I mean when I say \"it is a 401(k) world.\" Government will do less for you. Companies will do less for you. Unions can do less for you. There will be fewer limits, but also fewer guarantees. Your specific contribution will define your specific benefits much more. Just showing up will not cut it. - T. Friedman".downcase
pair = "ou"
third = "r"
pairs = (0..input.length-2).inject({}) do |h,i|
key, val = input[i,2], input[i + 2]
h[key] = {} unless h[key]
h[key][val] = (h[key][val] || 0) + 1 if val
h
end
@nmische
nmische / unfuddle_xml_to_jira_csv.rb
Created May 1, 2013 19:07
A simple program to transform an Unfuddle project backup.xml file to a CSV that can be imported into JIRA.
require 'optparse'
require 'rexml/document'
require 'csv'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: unfuddle_xml_to_jira_csv.rb -i backup.xml -o project.csv -k PROJECTKEY"
opts.on("-i", "--input FILE", "Input XML") do |i|
options[:input] = i
@nmische
nmische / lockdown.rb
Created April 22, 2013 17:48
Config setting for lockdown recipe.
coldfusion10_config "rutime" do
action :set
property "runtimeProperty"
args ({"propertyName" => "CFFormScriptSrc", "propertyValue" => node['cf10']['lockdown']['?']})
end
@nmische
nmische / jira_msg_filter.sh
Created April 22, 2013 16:05
Update git history for JIRA
# CM is the project key
git filter-branch --msg-filter 'sed "s/#\([0-9]*\)/#\1 [CM-\1]/g"'
@nmische
nmische / wsconfig
Created April 8, 2013 01:25
Output from ColdFusion 10 wsconfig -help
Usage:
To use GUI:
java -jar wsconfig.jar
To use property file to specifiy options:
java -jar wsconfig.jar -f <property-file-path>
To use command line to specify options:
java -jar wsconfig.jar [options]
Options
To install web server connector:
@nmische
nmische / cfjedis.cfc
Last active December 15, 2015 07:38
Jedis Wrapper
<cfcomponent name="cfjedis" displayname="Jedis" hint="This CFC handles communication with Redis">
<cffunction name="init" access="public" returntype="Any" output="no">
<cfargument name="serverName" type="string" required="true" />
<cfargument name="port" type="numeric" required="true" />
<cfset variables.pool = createObject("java","redis.clients.jedis.JedisPool").init(JavaCast("string",arguments.serverName), JavaCast("integer",arguments.port)) />
<cfreturn this>
</cffunction>
<cffunction name="getResource" access="private" returntype="Any" output="no">
@nmische
nmische / rename_tag.sh
Created March 14, 2013 17:53
One liner to clean up bad cookbook tags
git tag -l | while read line; do if [[ $line == v* ]]; then git tag ${line:1:5} $line && git tag -d $line && git push origin :refs/tags/$line; fi done
@nmische
nmische / default.rb
Created March 7, 2013 19:47
Tests for simple_iptables
# Reject packets other than those explicitly allowed
simple_iptables_policy "INPUT" do
policy "DROP"
end
# The following rules define a "system" chain; chains
# are used as a convenient way of grouping rules together,
# for logical organization.
# Allow all traffic on the loopback device
coldfusion10_config "set_colfire_debugging" do
action :bulk_set
config ( {
"debugging" => {
"debugProperty" => [
{"propertyName" => "enableDebug", "propertyValue" => true }
]
}
} )
end
@nmische
nmische / Cheffile
Last active December 12, 2015 02:59
Shibboleth IdP Vagrant Setup
site 'http://community.opscode.com/api/v1'
cookbook 'apt'
cookbook 'rng-tools'
cookbook 'java'
cookbook 'tomcat'
cookbook 'shibboleth-idp',
:git => 'https://github.com/wharton/chef-shibboleth-idp.git'
cookbook 'simple_iptables',
:git => 'https://github.com/nmische/cookbook-simple-iptables.git',
:ref => 'nat'