Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View wcravens's full-sized avatar

Wes Cravens wcravens

  • The Bootstrap Factory
  • Champaign, IL, USA
View GitHub Profile
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub { shift->render('test/tab/index') };
app->start;
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
}
package MyRole;
use Moo;
with 'Foo';
1;
package main;
use Test::More;
ok my $foo = MyRole->new( bar => baz );
@wcravens
wcravens / gist:8096594
Created December 23, 2013 12:49
pg_prove not picking up files in test/
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/
@wcravens
wcravens / gist:23f8ec6dc8b1bcf6447521314d7300e2
Created September 29, 2016 12:02
Leibniz pi calculation; Learn You a Haskell Exercices
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)
/* 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 March 24, 2021 13:53 — forked from mikehaertl/gist:3258427
Learn you a Haskell - In a nutshell

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.