This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojo::ByteStream; | |
app->helper(alerts => sub { | |
my $c = shift; | |
my $html = ''; | |
for my $message (qw|success info error|) { | |
my $css = "alert alert-$message"; | |
if($c->flash($message)) { | |
$html .= $c->tag('div', class => $css, $c->flash($message)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test::Class::Load 't/lib'; | |
# | |
# I feel that there's a better way to do this. | |
# Also if no tests run then no plan is emitted, shouldn't Test::Class deal with this? | |
# | |
# Regexes are not validated. | |
# | |
if($ENV{TEST_CLASS}) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Include test helpers and/or libs | |
sub MY::test | |
{ | |
package MY; | |
my $make = shift->SUPER::test(@_); | |
$make .= 'FULLPERLRUN = $(FULLPERL) -I t -I t/lib'; | |
return $make; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows Registry Editor Version 5.00 | |
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] | |
"HideFileExt"=dword:00000000 | |
; Show hidden and system files | |
"Hidden"=dword:00000001 | |
"ShowSuperHidden"=dword:00000001 | |
"SuperHidden"=dword:00000001 | |
; In Explorer, do not open folders in new window | |
"SeparateProcess"=dword:00000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - f.buttons do | |
# = f.commit_button | |
# = f.cancel | |
# Need to make this v2 like by using module... | |
class FormBuilderWithCancel < Formtastic::SemanticFormBuilder | |
def cancel(*args) | |
options = args.extract_options! | |
options[:class] ||= "cancel" | |
options[:label] ||= (args.shift || "Cancel") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RandomRecord | |
def random | |
order(random_function_name) | |
end | |
private | |
def random_function_name | |
if !defined? @__random_function_name | |
@__random_function_name = "rand()" | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create README.pod for a repo's GitHub page. Unlike CPAN, GitHub won't | |
# display the module's POD, it looks for a README.* | |
use Config; | |
sub MY::postamble | |
{ | |
my $self = shift; | |
return if -r 'README' or ! -r $self->{VERSION_FROM}; | |
return<<END_MAKE; | |
README.pod: $self->{VERSION_FROM} | |
\@$Config{bin}/perldoc -uT $self->{VERSION_FROM} > README.pod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: | |
# referer? :controller => 'beezies', :action => 'holla', :type => 'popozuda' | |
# referer? %r|/\d+/edit| | |
def referer?(options) | |
referer = request.headers["Referer"] | |
return (options.blank? ? true : false) if referer.blank? | |
if options.is_a?(Regexp) | |
referer =~ options |