Skip to content

Instantly share code, notes, and snippets.

View briandoll's full-sized avatar
😎
Helping companies market and sell more software

Brian Doll briandoll

😎
Helping companies market and sell more software
View GitHub Profile
@briandoll
briandoll / gist:384
Created July 21, 2008 22:33
awk ldap query to yaml
# This is an awk script, but no awk colour coding is available here.
#
# input: an LDAP query pulling back the displayName and sAMAccountName properties
# for an entire ActiveDirectory forest
#
# output: yaml format of same data
# ex.
# 1:
# name: "Doll, Brian A"
@briandoll
briandoll / gist:1833
Created July 23, 2008 17:57
marcel's rest/crud conventions
# Marcel Molina's REST/CRUD conventions
# http://project.ioni.st/post/2283#snippet_2283
class ApplicationController < ActionController::Base
def self.set_resource(resource, &custom_setter)
filter_name = :"set_#{resource}"
before_filter filter_name, :only => [:show, :edit, :update, :destroy]
if custom_setter
define_method(filter_name) do
@briandoll
briandoll / making.coffee.md
Created February 27, 2014 18:40
Make good coffee at your house
#!/usr/bin/env ruby
domains = {}
ARGF.each do |email|
domain = email.split("@").last.strip
if domains[domain]
domains[domain] += 1
else
domains[domain] = 1
# Add unique header support to soap4r clients
# http://emphaticsolutions.com/index.php/2008/05/06/soap-headers-per-request-in-ruby/
#
require 'soap/header/handlerset'
class SOAP::Header::HandlerSet
# resets the internal handler store to an empty representation
def reset
@store = XSD::NamedElements.new
end
require 'rss/1.0'
require 'rss/2.0'
require 'open-uri'
require 'socket'
module ApplicationHelper
def render_rss_feed(url)
content = ""
open(url, 0) do |s| content = s.read end
feed = RSS::Parser.parse(content, false)
%ruby script/console
Loading development environment (Rails 2.1.0)
>> (Time.now + 30.minutes).class
=> Time
>> 30.minutes.from_now.class
=> ActiveSupport::TimeWithZone
<%- cache "statulous_blog", (Time.now + 60.minutes) do -%>
<%= render_rss_feed("http://statulous.blogspot.com/feeds/posts/default?alt=rss") %>
<%- end -%>
<h3><a href='<%= @link %>'><%= @title %>:</a></h3>
<small>The most recent 5 entries:</small><br/>
<% @items.each do |item| %>
<li><strong><a href='<%= item.link %>'><%= item.title %></a></strong> - <small>(<%= item.date.strftime('%m/%d/%Y') %>)</small>
<% end %>
public void testSnappyHappy() {
Map snappy = null;
Map happy = new HashMap();
addToMap(snappy, "foo", "bar");
addToMap(happy, "foo", "bar");
}
private Map addToMap(Map map, String key, String value){
if (map == null){