Skip to content

Instantly share code, notes, and snippets.

View cowboyrushforth's full-sized avatar

Scott Rushforth cowboyrushforth

View GitHub Profile
#!/usr/bin/ruby
# sa-retrain.rb
# to be used to pipe mail into sa-lean, from postfix
# postfix master.cf can be setup like so:
#
# sa-retrain unix - n n - 10 pipe
# flags=Ru user=amavis argv=ruby /usr/local/bin/sa-retrain.rb $nexthop $sender $recipient
#
# then setup some transport like so in /etc/postfix/transport:
#
@cowboyrushforth
cowboyrushforth / gist:5963752
Created July 10, 2013 05:48
Java<->Ruby AES-256-CBC PKCS5 Working 2 way encryption
# RUBY
require 'openssl'
require 'digest/sha2'
require 'json'
def bin2hex(str)
str.unpack('C*').map{ |b| "%02X" % b }.join('')
end
class AssetOriginInjectionMiddleware
def initialize(app)
@app = app
end
def call(env)
# this is a weird hack. what it does is
# add the production origin access allowed origin header
# of the production sites url
# if we happen to be serving an asset.
COLOR_YELLOW="\[\e[33;40m\]"
COLOR_RED="\[\e[31;40m\]"
COLOR_GREEN="\[\e[32;40m\]"
COLOR_BLUE="\[\e[34;40m\]"
COLOR_NONE="\[\e[0m\]"
COLOR_NONEP="\[\e[38;40m\]"
git_dirty_flag() {
git status 2> /dev/null | grep -c : | awk '{if ($1 > 0) print "⚡"}'
}
parse_git_branch() {
#!/usr/bin/ruby
# Ruby version of dspam-retrain perl script.
# Perl version: http://dspamwiki.expass.de/DspamRetrainScript
# Author: wsr@rushforthnetworks.com
# License: BSD
# Abstract: setup postfix to pipe mail into this script
# so that we may then pass it off to dspam in
# an appropriate way.
#
# dspam-retrain.rb handles spam-user@domain.tld, and
def duration(filename)
f = File.open(filename, 'r')
raise "Could not open File!" unless f
#check for flv text
unless f.read(3) === 'FLV'
raise "This does not seem to be an FLV file."
end
#check to make sure we are a video
#!/usr/bin/env ruby
require 'rubygems'
gem 'feedtools'
gem 'htmltokenizer'
require 'feed_tools'
require 'html/htmltokenizer'
require 'twitter'
require 'net/http'
#your redmine url