Skip to content

Instantly share code, notes, and snippets.

@slavone
slavone / 1.exs
Last active December 3, 2017 20:54
Advent of Code 2017 day two
input = """
3458 3471 163 1299 170 4200 2425 167 3636 4001 4162 115 2859 130 4075 4269
2777 2712 120 2569 2530 3035 1818 32 491 872 113 92 2526 477 138 1360
2316 35 168 174 1404 1437 2631 1863 1127 640 1745 171 2391 2587 214 193
197 2013 551 1661 121 206 203 174 2289 843 732 2117 360 1193 999 2088
3925 3389 218 1134 220 171 1972 348 3919 3706 494 3577 3320 239 120 2508
239 947 1029 2024 733 242 217 1781 2904 2156 1500 3100 497 2498 3312 211
188 3806 3901 261 235 3733 3747 3721 267 3794 3814 3995 3004 915 4062 3400
918 63 2854 2799 178 176 1037 487 206 157 2212 2539 2816 2501 927 3147
186 194 307 672 208 351 243 180 619 749 590
require 'json'
require 'uri'
# how to use:
# ruby parse_har_file.rb filename_in_curr_dir pattern_to_match_correct_urls optional_param_accepted_statuses_separated_by_commas
filename = ARGV[0]
match_pattern = Regexp.compile(ARGV[1] || "")
accept_statuses = (ARGV[2] || "").split(',').map(&:to_i)
@slavone
slavone / benchmark.ex
Created May 1, 2018 10:47
Benchmarking using try/rescue agains function_exported? in elixir for handling unreliable function calls
defmodule Generator do
defmacro testing do
names = (1..10000)
|> Enum.map(fn(_) ->
:crypto.strong_rand_bytes(10) |> Base.url_encode64 |> binary_part(0, 10)
end)
|> Enum.map(&String.to_atom/1)
names
|> Enum.take_every(2)
@slavone
slavone / asdasd.rb
Created June 11, 2021 16:44
formatting
@fields ||=
Array.new(size) do |y|
Array.new(size) do |x|
Field.new(x: Chess::X[x], y: y + 1)
end
end
package main
import (
"log"
"sync"
"time"
)
type Worker struct {
name string
package main
import (
"fmt"
"strings"
)
func main() {
input := []string{"ass", "fuck", "car", "cat", "cucumber"}