Skip to content

Instantly share code, notes, and snippets.

@adamstegman
adamstegman / spec_helper.rb
Created April 19, 2011 05:28
Silence RSpec specs
RSpec.configure do |config|
config.before(:all, &:silence_output)
config.after(:all, &:enable_output)
end
# Redirects stderr and stdout to /dev/null.
def silence_output
@orig_stderr = $stderr
@orig_stdout = $stdout
@adamstegman
adamstegman / hanoi.rb
Created November 20, 2011 05:30
Hanoi solver for Facebook sample challenge
#!/usr/bin/env ruby
# coding: UTF-8
# K pegs, 3 <= K <= 5
# N discs, radius 1 to N, 1 <= N <= 8
# given initial positions and final positions, output minimum moves to achieve it
# Input Format:
# N K
# 2nd line contains N integers.
@adamstegman
adamstegman / available_ebooks.rb
Last active August 6, 2016 19:52
eBooks from my Goodreads to-read list that are available to check out from OverDrive, sorted by average rating on Goodreads
#!/usr/bin/env ruby
require 'json'
require 'logger'
require 'net/http'
require 'addressable/template'
require 'mechanize'
require 'nokogiri'
@adamstegman
adamstegman / project.clj
Created March 23, 2013 06:12
dieter dependencies are not pulled in so I pulled them in myself. `lein dieter-precompile` reports that the task does not exist, `lein with-profile dev dieter-precompile` reports the same.
(defproject melnitz "1.0.0-SNAPSHOT"
:description "Sorts the mail (from an Exchange server) and presents it in a dashboard so you can act on it instead of trying to figure out threads on your own."
:url "http://github.com/adamstegman/melnitz"
:dependencies [[com.edgecase/dieter "0.4.0"]
[commons-httpclient/commons-httpclient "3.1"]
[commons-logging/commons-logging-api "1.1"]
[microsoft.exchange/webservices "1.2"]
[org.clojure/clojure "1.4.0"]
[org.samba.jcifs/jcifs "1.3.3"]
[cheshire "5.0.2"]
@adamstegman
adamstegman / message.md
Last active December 14, 2015 11:09
JRuby NameError: missing class or uppercase package name (`microsoft.exchange.webservices.data.ExchangeService')

I'm attempting to use the [Exchange Webservices API][ewsapi]. Unfortunately it has a weird package, but I thought that wouldn't be hard to overcome. So I wrote this script:

require 'java'
require 'vendor/lib/EWSJavaAPI_1.2.jar'

def microsoft
  Java::Microsoft
end

version = microsoft.exchange.webservices.data.ExchangeVersion::Exchange2010_SP1
@adamstegman
adamstegman / Gemfile
Created August 27, 2011 01:56
Search a website for permutations of "Fillion"
source :rubygems
gem 'nokogiri', '~> 1.5.0'
@adamstegman
adamstegman / gist:1038119
Created June 21, 2011 15:37
brew doctor
$ brew doctor
Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libntfs-3g.54.0.0.dylib
/usr/local/lib/libntfs.9.0.0.dylib
@adamstegman
adamstegman / test_helper.rb
Created April 19, 2011 05:18
silence Test::Unit tests
setup :silence_output
# Redirects stderr and stdout to /dev/null.
def silence_output
@orig_stderr = $stderr
@orig_stdout = $stdout
# redirect stderr and stdout to /dev/null
$stderr = File.new('/dev/null', 'w')
$stdout = File.new('/dev/null', 'w')
def silence
orig_stdout = $stdout
$stdout = File.new('/dev/null', 'w')
yield
ensure
$stdout = orig_stdout
end
desc "Run tests, and have a little fun afterward."
task :test_reward => :test do
puts "\e[1m\e[35m ,%%%, \e[0m"
puts "\e[1m\e[35m ,%%%` %==--\e[5m\e[33m*\e[0m "
puts "\e[1m\e[35m ,%%`( '| \e[0m"
puts "\e[1m\e[35m ,%%@ /\_/ \e[0m"
puts "\e[1m\e[35m ,%.-\"\"\"--%%% \"@@__ \e[0m"
puts "\e[1m\e[35m %%/ |__`\ \e[0m"
puts "\e[1m\e[35m .%'\ | \ / // \e[0m"
puts "\e[1m\e[35m ,%' > .'----\ | [/ \e[0m"