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
package main | |
import ( | |
"fmt" | |
"runtime" | |
) | |
func main() { | |
var stats runtime.MemStats |
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 'json' | |
require 'strscan' | |
FILENAME = ARGV[0] | |
POOLSIZE = 6 | |
BUFSIZE = 128 * 1024 * 1024 | |
pool = Array.new(POOLSIZE) do |_idx| # rubocop:disable Metrics/BlockLength | |
outpipe_out, outpipe_in = IO.pipe(encoding: Encoding::BINARY) | |
cmdpipe_out, cmdpipe_in = IO.pipe(encoding: Encoding::BINARY) |
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 'strscan' | |
stats = Hash.new { |h, k| h[k] = [10_000, -10_000, 0, 0] } | |
SEMI = String.new(';', encoding: Encoding::BINARY) | |
NEWLINE = String.new("\n", encoding: Encoding::BINARY) | |
BUFLEN = 128 * 1024 * 1024 | |
buf = ' ' * BUFLEN | |
buf.force_encoding(Encoding::BINARY) |
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
stats = {} | |
File.open('measurements.txt') do |f| | |
f.each_line do |line| | |
city, temp_s = line.split(';') | |
temp = temp_s.to_f | |
stats[city] ||= { | |
min: 10_000, | |
max: -10_000, | |
sum: 0, |
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 'csv' | |
def parse_monocsv(csv_string) | |
columns = %i[ | |
date | |
hour | |
debit_or_credit | |
details | |
counteragent | |
edrpou |
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
enum DateIndex { | |
// All dates are integers counting from this date | |
static let zeroDate = Calendar.current.date(from: .init(year: 1970, month: 1, day: 1))! | |
static func fromDate(_ date: Date) -> Int { | |
Calendar.current.dateComponents([.day], from: zeroDate, to: date).day! | |
} | |
static func toDate(_ index: Int) -> Date { | |
Calendar.current.date(byAdding: .day, value: index, to: zeroDate)! |
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
VALUES_PER_SECOND = 10_000_000.0 | |
# Probability of collision of a single generation | |
# - gen_per_second = how many values are generated per second | |
def p_gen(machine_count, gen_per_second) | |
value_count = VALUES_PER_SECOND / gen_per_second | |
1 - Math.exp(-machine_count*(machine_count-1)/(2*value_count)) | |
end |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"os/exec" | |
"runtime" | |
"strconv" | |
"strings" |
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 'concurrent/atomic/read_write_lock' | |
require 'benchmark/ips' | |
require 'active_support/core_ext/string' | |
rw = Concurrent::ReadWriteLock.new | |
Benchmark.ips do |x| | |
x.report("with_read_lock") do | |
rw.with_read_lock do | |
Math.sqrt(4) | |
end |
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
#!/bin/sh | |
GITHUB_PAT_TOKEN=github_pat_xxx | |
REPO=myuser/myrepo | |
FILEPATH=online.txt | |
# echo -n '...' | base64 | |
INCREMENT='Li4u' | |
FILEINFO=$(curl \ |
NewerOlder