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
from enum import Enum | |
from typing import Type, Any | |
Sentinels = Enum("Sentinels", "NO_INIT") | |
class attr_descriptor: | |
def __init__(self, default=Sentinels.NO_INIT): | |
self.default = default |
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
sub terminal-width(:$default=100) { | |
my $width = run('tput', 'cols', :out).out.slurp-rest.trim.Int; | |
return $width < $default ?? $default !! $width; | |
} | |
sub is-mandelbrot(Complex $z0, int $max=100) { | |
my Complex $z = $z0; | |
for ^$max -> $n { | |
return $n if ($z.abs() > 2e0); | |
$z = $z**2 + $z0; |
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
function proxyon { | |
sudo networksetup -setwebproxy Wi-Fi localhost 8080 | |
sudo networksetup -setsecurewebproxy Wi-Fi localhost 8080 | |
sudo networksetup -setwebproxystate Wi-Fi on | |
sudo networksetup -setsecurewebproxystate Wi-Fi on | |
ssh -2CnNqT -L 8080:wwwcache.server.com:8080 user@bastion.host | |
} | |
function proxyoff { | |
sudo networksetup -setwebproxystate Wi-Fi off |
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
from typing import NamedTuple | |
import json | |
class NamedTupleJSONEncoder(json.JSONEncoder): | |
def encode(self, o): | |
print(f"Encoding {type(o)}") | |
return super().encode(o) |
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 TABLE patient ( | |
name text, | |
administrative_gender uuid references concept.concept_cid, | |
ethnicity uuid references concept.concept_cid, | |
phenotypic_sex_cid uuid references concept.concept_cid, | |
); | |
-- Parametric trigger for validating concept FK against sets of codesystems | |
-- concept_ind_codesystem(concept_field_name, array_of_codesystems) |
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
#!/usr/bin/env perl6 | |
sub character_differences(Str $str1, Str $str2) { | |
$str1.comb Z~~ $str2.comb | |
} | |
sub hamming_distance(Str $str1, Str $str2) { | |
my @differences = character_differences($str1, $str2); | |
return @differences.grep(* == False).elems; | |
} |
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
#!/usr/bin/env perl6 | |
use v6; | |
use Stats; | |
#Tim's original times: | |
#primes-inline-loop(1000) ran in 2.425 seconds (σ = 0.213 seconds). | |
#primes-inline-loop-upto-sqrt(1000) ran in 2.311 seconds (σ = 0.131 seconds). | |
#primes-inline-loop-upto-int-sqrt(1000) ran in 2.274 seconds (σ = 0.161). | |
sub bench($name, &code) { |
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
Time: <span id="clockDisplay"></span> |
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
say "Ohai!"; | |
for ^10 -> $stuff { | |
say $stuff if $stuff.is-prime; | |
} |
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 Stats; | |
sub bench($name, &code) { | |
my ($start,$end); | |
my @times; | |
for 1..100 { | |
$start = now; | |
code(); |