This file contains hidden or 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
| <?php | |
| # Add the following to your existing functions.php, if there is one... | |
| add_action( 'wp_enqueue_scripts', function () { | |
| $the_theme = wp_get_theme(); | |
| wp_enqueue_script( 'hotkeys', get_stylesheet_directory_uri() . '/js/hotkeys.js', [ 'jquery' ], $the_theme->get( 'Version' ), true ); | |
| } ); | |
| add_action( 'wp_head', function () { |
This file contains hidden or 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 strict; | |
| use warnings; | |
| use feature 'say'; | |
| my $input = 'foo:bar:baz:quux'; | |
| my ($fbb, $quux) = | |
| reverse map scalar(reverse($_)), | |
| split /:/, reverse($input), 2; | |
| say $fbb; |
This file contains hidden or 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
| package Geometry { | |
| use MooX::Pression; | |
| # PointND isn't a class itself, but a class generator! | |
| # It generates classes to represent points in n dimensions. | |
| class PointND ( | |
| IntRange[1,26] $n, | |
| ArrayRef $labels = ['x'..'z', reverse('a'..'w')] | |
| ) { | |
| my @letters = @{$labels}[0 .. $n-1]; |
This file contains hidden or 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
| package Bank { | |
| use MooX::Pression; | |
| class Account { | |
| has balance ( | |
| type => Num, | |
| default => 0, | |
| handles_via => 'Number', | |
| handles => { '_adjust_balance' => 'add' }, | |
| ); |
This file contains hidden or 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
| # Looks like overloaded &{} doesn't work with after_parse in either of Text::CSV_{PP,XS} | |
| # so need to use \&{...} to get a real coderef. That's not a huge problem. | |
| # This will die on any row that breaks the constraint... | |
| after_parse => \&{ Tuple[Str, Str, Int, Bool, Optional[Num]] } | |
| # This will skip on any row that breaks the constraint... | |
| after_parse => sub { | |
| state $type = Tuple[Str, Str, Int, Bool, Optional[Num]]; | |
| state $check = $type->compiled_check; |
This file contains hidden or 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
| /* I'm not very good at Java */ | |
| class Example { | |
| public static void main(String[] args) { | |
| exampleWithoutArray(); | |
| exampleWithArray(); | |
| } | |
| public static void exampleWithoutArray () { |
This file contains hidden or 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 strict; use warnings; | |
| package Point { | |
| sub new { | |
| bless { | |
| x => 0, | |
| y => 0, | |
| @_, | |
| }, shift; | |
| } |
This file contains hidden or 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 strict; use warnings; | |
| package Point { | |
| sub new { | |
| bless { | |
| x => 0, | |
| y => 0, | |
| @_, | |
| }, shift; |
This file contains hidden or 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 strict; | |
| use warnings; | |
| use Benchmark qw(cmpthese); | |
| package Local::Moose::Native { | |
| use Moose; | |
| has foo => (is => 'rw', isa => 'Int'); | |
| } | |
| package Local::Moose::TypeTiny { |
This file contains hidden or 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 v5.14; | |
| use strict; | |
| use warnings; | |
| use version; | |
| use List::MoreUtils qw(part); | |
| my @packages = map [split / - /], map { chomp; $_ } <DATA>; | |
| my ($perl, $delta, $other) = part { | |
| $_->[0] =~ /^perl.*delta$/ ? 1 : |