View dependency_sets.cr
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
def affected_files(file, dependencies) | |
tracked_files = Set(String).new | |
track(file, dependencies, tracked_files) | |
tracked_files | |
end | |
def track(file, dependencies, tracked_files) | |
return unless tracked_files.add?(file) | |
dependencies[file].each do |to| |
View move_deployed_linear_issues.rb
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
# Make sure to configure this script! | |
# 1. Change `TEAM_LINEAR` properties below to match your Linear team | |
# 2. Optionally add more teams | |
# 3. Change the value of `DEPLOYED_TO_STAGING_GIT_TAG` to the tag/branch you use for deploys to staging | |
# 4. Change the value of `DEPLOYED_TO_PRODUCTION_GIT_TAG` to the tag/branch you use for deploys to production | |
# | |
# Usage: | |
# LINEAR_API_KEY=... GITHUB_API_KEY=... ruby move_deployed_linear_issues.rb | |
# | |
# Adding new teams (change "LinearTeam" to your team name): |
View parser_combinators.cr
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
require "benchmark" | |
module Parser(T) | |
def self.char(a : Char) | |
CharParser.new(a) | |
end | |
def self.int | |
IntParser.new | |
end |
View gc_peek.cr
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 = Time.monotonic | |
gcfile = File.new("chry_multiplied.fa") | |
at = 0 | |
gc = 0 | |
while true | |
# Peek the IO's buffer | |
peek = gcfile.peek |
View secret_code.cr
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
require "colorize" | |
enum Color | |
Red | |
Green | |
Blue | |
Yellow | |
Pink | |
Gray |
View constants_vs_inline.cr
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
require "benchmark" | |
RANGE = 3..7 | |
a = 1 | |
v = ARGV[0].to_i | |
Benchmark.ips do |x| | |
x.report("constant") do | |
case v |
View maybe_faster.cr
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
# This Crystal source file is a multiple threaded implementation to perform an | |
# extremely fast Segmented Sieve of Zakiya (SSoZ) to find Twin Primes <= N. | |
# Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
# Output is the number of twin primes <= N, or in range N1 to N2; the last | |
# twin prime value for the range; and the total time of execution. | |
# This code was developed on a System76 laptop with an Intel I7 6700HQ cpu, | |
# 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning | |
# probably needed to optimize for other hardware systems (ARM, PowerPC, etc). |
View foo.cr
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
# This Crystal source file is a multiple threaded implementation to perform an | |
# extremely fast Segmented Sieve of Zakiya (SSoZ) to find Twin Primes <= N. | |
# Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
# Output is the number of twin primes <= N, or in range N1 to N2; the last | |
# twin prime value for the range; and the total time of execution. | |
# This code was developed on a System76 laptop with an Intel I7 6700HQ cpu, | |
# 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning | |
# probably needed to optimize for other hardware systems (ARM, PowerPC, etc). |
View twinprimes.cr
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
# This Crystal source file is a multiple threaded implementation to perform an | |
# extremely fast Segmented Sieve of Zakiya (SSoZ) to find Twin Primes <= N. | |
# Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1. | |
# Output is the number of twin primes <= N, or in range N1 to N2; the last | |
# twin prime value for the range; and the total time of execution. | |
# This code was developed on a System76 laptop with an Intel I7 6700HQ cpu, | |
# 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning | |
# probably needed to optimize for other hardware systems (ARM, PowerPC, etc). |
View interfaces.cr
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
# One can write a class that wraps a Proc and calls it: | |
class Handler | |
def initialize(&@proc : -> String) | |
end | |
def call | |
@proc.call | |
end | |
end |
NewerOlder