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( timethese cmpthese); | |
| use Inline C => <<'END_OF_C_CODE'; | |
| void clean_hash(SV* hash_ref) { | |
| HV* hash; | |
| HE* hash_entry; | |
| int num_keys, i; | |
| SV* sv_key; |
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
| #!/usr/bin/perl | |
| use 5.16.1; | |
| use B; | |
| use constant DEF_INTEGER_AS_STRING => 4352; | |
| use constant DEF_POSITIVE_INTEGER => 1; | |
| use Scalar::Util::LooksLikeNumber qw(looks_like_number); | |
| use Benchmark qw(cmpthese); | |
| use Inline C => <<'END_OF_C_CODE'; | |
| #include <math.h> | |
| #include <math.h> |
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
| CREATE FUNCTION inc5 (num NUMERIC) | |
| returns NUMERIC | |
| language SQL | |
| AS $$ | |
| WITH recursive n5 (i, l, nt, ln, c) AS ( | |
| SELECT -1, LENGTH(num::text)+1, num::text, '', 1 | |
| UNION ALL | |
| SELECT i+1, l - 1, nt, | |
| CASE (substring(nt FROM l-1 FOR 1)::INT + c) | |
| WHEN 5 |
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
| sub __set_timer { | |
| my ($ptrEvID, %options) = @_; | |
| my ($secAfter, $secInterval, $callback) = @options{qw/after interval cb/}; | |
| return unless $secAfter or $secInterval; | |
| $$ptrEvID = | |
| $secAfter | |
| ? Mojo::IOLoop->timer( | |
| $secAfter => $secInterval | |
| ? sub {$callback->(); $$ptrEvID = Mojo::IOLoop->recurring($secInterval => $callback)} | |
| : $callback |
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
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use feature qw/say bitwise/; | |
| use experimental 'bitwise'; | |
| use utf8; | |
| use Benchmark ':all'; | |
| use Inline C => <<'END_OF_C_CODE'; | |
| #define IN_RANGE_INC(type,val,beg,end) \ |
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.10; | |
| use strict; | |
| use warnings; | |
| use Data::Dumper; | |
| sub _quote_var { | |
| my $s = $_[0]; | |
| my $d = Data::Dumper->new([$s]); | |
| $d->Terse(1); | |
| my $qs = $d->Dump; |
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
| function nextDate(date, direction) { | |
| if(!direction) | |
| direction = 1; | |
| return new Date(date.getFullYear(), date.getMonth(), date.getDate() + direction); | |
| } | |
| function skipWeekend(date, direction) { | |
| while(date.getDay() === 0 || date.getDay() === 6) | |
| date = nextDate(date, direction); | |
| return date; |
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
| # The Computer Language Benchmarks Game | |
| # https://salsa.debian.org/benchmarksgame-team/benchmarksgame/ | |
| # | |
| # contributed by Mykola Zubach | |
| use strict; | |
| use threads; | |
| use threads::shared; | |
| use constant MAXITER => 50; |
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
| create or alter function dbo.is_alpha(@c nchar(1)) returns bit as | |
| begin | |
| declare @lchar nchar(1) = LOWER(@c), @uchar nchar(1) = UPPER(@c); | |
| if @c = 'ß' or unicode(@lchar) <> unicode(@uchar) | |
| return 1; | |
| return 0; | |
| end | |
| go |
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
| -- T-SQL adapted version | |
| CREATE or ALTER FUNCTION dbo.InitCap(@StrStr nvarchar(max)) RETURNS nvarchar(max) AS | |
| BEGIN | |
| DECLARE @StrNew nvarchar(max); | |
| DECLARE @c nvarchar(1); | |
| DECLARE @x integer; | |
| DECLARE @StrLen integer ; | |
| DECLARE @CloseBracket nvarchar(5); | |
| DECLARE @OpenBracket varchar(5); | |
| DECLARE @mode varchar(20) = 'upper'; |