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
s = Time.now
e = s + 100.days
i = s
dates = []
dates << s
while i < e
i += 1.week
dates << i
end
@briandoll
briandoll / convertMod2Dv.app
Created August 16, 2008 19:36
AppleScript to convert .MOD files to .DV
--
-- convertMod2Dv.app
--
-- a simple apple script applet to convert .mod files to .dv files
-- this is an essential step for those of us who own DV video cameras
-- that use this .mod file format, but would also like to edit those videos
-- in iMove HD or other editing apps. This applet was developed solely to
-- provide drag-n-drop functionality to the command line tool ffmpeg2.
-- It supports dragging individual files or folders of files, etc.
--
# 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
<%- cache "statulous_blog", (Time.now + 60.minutes) do -%>
<%= render_rss_feed("http://statulous.blogspot.com/feeds/posts/default?alt=rss") %>
<%- 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)
<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 %>
%ruby script/console
Loading development environment (Rails 2.1.0)
>> (Time.now + 30.minutes).class
=> Time
>> 30.minutes.from_now.class
=> ActiveSupport::TimeWithZone
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){