Skip to content

Instantly share code, notes, and snippets.

View postmodern's full-sized avatar
🚧
working on Phase 2 (of Ronin)

Postmodern postmodern

🚧
working on Phase 2 (of Ronin)
View GitHub Profile
@postmodern
postmodern / dm_api_key.rb
Created March 26, 2010 06:07
A basic DataMapper Type to represent unique API keys.
require 'digest/sha2'
module DataMapper
module Types
class APIKey < DataMapper::Type
primitive String
length 64
#
@postmodern
postmodern / Fib.java
Created April 12, 2010 06:56
Before getting into yet-another-pointless language war, here are some recent numbers. Argue less, code more.
public class Fib {
public static int fib(int n) {
if (n == 0 || n == 1)
return n;
return (fib(n-1) + fib(n-2));
}
public static void main(String[] args) {
for (int i = 0; i < 36; i++)
System.out.println("n=" + i + " => " + fib(i));
@postmodern
postmodern / list_prior_art.rb
Created March 8, 2011 23:59
Lists prior "art" (aka all of your repositories).
#!/usr/bin/env ruby
require 'net/http'
require 'json'
require 'date'
class PriorArt < Struct.new(:name,:description,:created_at,:updated_at)
end
prior_art = {}
@postmodern
postmodern / gix_require_benchmark.rb
Created March 10, 2011 05:04
Benchmark each require in your Ruby code.
require 'rubygems'
require 'rbtree'
class Req
attr_accessor :path, :time, :requires, :exception
def initialize(path)
@path = path
@requires = []
@time = 0
end
@postmodern
postmodern / dm_find_validation_errors.rb
Created April 15, 2011 08:43
Quick and Dirty way to find DataMapper Validation errors.
require 'pp'
invalids = ObjectSpace.each_object(DataMapper::Resource).select { |obj| !obj.saved? && !obj.valid? }
pp invalids.map { |obj| [obj.class, obj.errors.to_hash] }
@postmodern
postmodern / bump_copyright.rb
Created January 3, 2012 02:18
Automatically bump the year in the Copyright-notice headers of Ruby files.
@postmodern
postmodern / Makefile
Last active March 4, 2024 14:42
A generic Makefile for building/signing/install bash scripts
NAME=project
VERSION=0.0.1
DIRS=etc lib bin sbin share
INSTALL_DIRS=`find $(DIRS) -type d 2>/dev/null`
INSTALL_FILES=`find $(DIRS) -type f 2>/dev/null`
DOC_FILES=*.md *.txt
PKG_DIR=pkg
PKG_NAME=$(NAME)-$(VERSION)
@postmodern
postmodern / consulting_agreement_amendment.md
Created August 2, 2012 23:53
Contract amendent to allow Open Sourcing of out-of-scope/unrelated Software

Excluded Inventions

Consultant shall have the right to retain ownership of any inventions, original works of authorship, discoveries, concepts or ideas, which are unrelated to Consultant’s present work (or the actual or demonstrably anticipated research or development of the Company) under this Agreement; or that the Consultant developed entirely on his own time without using the Company’s equipment, supplies, facilities and does not contain any Company trade secrets, proprietary materials or any other protected intellectual property owned by the Company. Consultant represents that the exclusion of such Inventions from this Section 9 (Inventions) will not materially affect Consultant’s ability

@cktricky
cktricky / proc-it-like-its-hawt
Created September 30, 2012 01:33
Cool proc-ness
#!/usr/bin/env ruby
require 'celluloid'
require 'net/http'
class Fetcher
include Celluloid
def get(action, url)
puts "doing work.."
res = action.call(url)
@willglynn
willglynn / gemsig_proposal.md
Created October 4, 2012 02:01
.gemsig Proposal

.gemsig Proposal

RubyGems.org has little in the way of defenses against tampering. Right now, new gems could be uploaded to S3 and distributed to users worldwide without detection, and the only thing preventing this is the security of the AWS credentials presently stored on world-facing web servers. S3 Versioning is a step that could be taken immediately to reduce the severity of compromise, but a larger solution is required.

This document proposes a .gemsig file as a means of verifying that a gem has not been modified during distribution. This file would be distributed alongside the .gem files, allowing clients to verify authenticity.

Format