Skip to content

Instantly share code, notes, and snippets.

Avatar

ab5tract ab5tract

  • Amsterdam, Netherlands
View GitHub Profile
@ab5tract
ab5tract / sha1.p6
Last active Dec 11, 2015 — forked from cognominal/sha1.p6
sha1 hash
View sha1.p6
subset Sha1 of Str where *.chars == 40 and m:i/<[A..Z 0..9]>/;
class Sha1H does Associative {
has $!sha1;
has %!h{Sha1(Str)};
method AT-KEY($_) { %!h{ .lc } };
method ASSIGN-KEY($_, $v) { %!h{ .lc } = $v }
}
class Sha1Str is Str {
View overlaps-with.p6
#!/usr/bin/env perl6
use Test;
sub overlaps-with( $r1, $r2 ) {
$r1.min ~~ $r2 and $r1.max ~~ $r2 or $r2.min ~~ $r1 and $r2.max ~~ $r1
or ( $r1.min == $r2.min and ($r1.max <= $r2.max or $r2.max <= $r1.max) )
or ( $r2.min < $r1.min < $r2.max <= $r1.max )
or ( $r1.min < $r2.min < $r1.max <= $r2.max );
}
View README
Stop putting "require 'rubygems'" in your project files. Just madly require
away, assuming that whatever you need will be found in the load path.
Install dollarspots.rb early in your loadpath. It checks the pwd for a file
named .dollarspots.rb and loads it if found. Use .dollarspots.rb files locally
in projects to jigger with your loadpath such that your reckless requires
actually work. Note that this may involve saying "require 'rubygems'".
Call ruby with -rdollarspots, or set "rdollarspots" as your RUBYOPT. To get TextMate's RubyMate facilities to work you'll need to edit the RUBYOPT shell variable in the Prefs.
View paletton.rb
# Framework
require 'foundations/compact'
# Gems
require 'palettes'
require 'cassandra'
# App
require 'views'
View spit.rb
require 'foundations/compact'
require 'layers/renderers/markaby'
require 'syntaxi'
require 'sequel'
module Spit
include Waves::Foundations::Compact
include Waves::Renderers::Markaby
View gist:10078
Runtime config attributes
host
port (will it be possible for an app to have a separate port?)
log (i'm beginning to see that runtime level logs may be best. perhaps the runtime could have an optional "log viewer" waves app built in that could sort out stuff 'per app')
debug
synchronize?
application (rack builder block)
mime_types
resources (routing)
handler (rack handler)
View dependencies.rb
def self.dependencies( *args )
self['dependencies'] ||= Set.new
args.length == 0 ? self['dependencies'] :
self['dependencies'] += ( args - gems.dependencies )
end
View dependencies.rb
def self.dependencies( *args )
self['dependencies'] ||= Set.new
args.length == 0 ? self['dependencies'] + gems.dependencies :
( self['dependencies'] += ( args - gems.dependencies ) )
end
View application.rb
require 'foundations/simple'
module Blog
include Waves::Foundations::Simple
end