Skip to content

Instantly share code, notes, and snippets.

View module_pattern.spec.js
/* jshint expr:true */
/* globals describe, it, beforeEach */
var chai = require( 'chai' )
, expect = chai.expect
;
var moduleNames = ['lib/recurringDateObjects'];
var moduleMethods = [];
@wcravens
wcravens / gist:0e1e423ce1823b718b9d5b1ddf6acffa
Last active Mar 24, 2021 — forked from mikehaertl/gist:3258427
Learn you a Haskell - In a nutshell
View gist:0e1e423ce1823b718b9d5b1ddf6acffa

Learn you a Haskell - In a nutshell

This is a summary of the "Learn You A Haskell" online book under http://learnyouahaskell.com/chapters.


1. Introduction

  • Haskell is a functional programming language.
@wcravens
wcravens / gist:23f8ec6dc8b1bcf6447521314d7300e2
Created Sep 29, 2016
Leibniz pi calculation; Learn You a Haskell Exercices
View gist:23f8ec6dc8b1bcf6447521314d7300e2
stepReverseSign :: (Fractional a, Ord a) => a -> a -> a
stepReverseSign num step = (if num > 0 then -1 else 1) * (abs(num) + step)
piCalc :: (Fractional a, Integral b, Ord a) => a -> (a, b)
piCalc tolerance = piCalc' 1 0.0 tolerance 0
piCalc' :: (Ord a, Fractional a, Integral b) => a -> a -> a -> b -> (a, b)
piCalc' denominator pi tolerance iterations =
| abs( pi' - pi) < tolerance = ( pi', iterations )
| otherwise = piCalc' (stepReverseSign denominator) pi' tolerance (iterations + 1)
@wcravens
wcravens / gist:8096594
Created Dec 23, 2013
pg_prove not picking up files in test/
View gist:8096594
wcravens@aberforth:~/Repos/hoas/database$ pg_prove --version
pg_prove 3.29
wcravens@aberforth:~/Repos/hoas/database$ ls test/*
test/address.sql
wcravens@aberforth:~/Repos/hoas/database$ pg_prove -d hoas_test test/*.sql
test/address.sql .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.03 cusr 0.00 csys = 0.07 CPU)
Result: PASS
wcravens@aberforth:~/Repos/hoas/database$ pg_prove -d hoas_test test/
View gist:4655739
package MyRole;
use Moo;
with 'Foo';
1;
package main;
use Test::More;
ok my $foo = MyRole->new( bar => baz );
View gist:1908098
sub set_config {
my $self = shift;
my $config = My::Config->new;
$self->app->log->debug( $config->test ); #yay
$self->helper( config => sub { $config } );
$self->log->debug( $self->config->test ); # Can't call method "test" on unblessed reference
}
View gist:1480965
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub { shift->render('test/tab/index') };
app->start;