Skip to content

Instantly share code, notes, and snippets.

View veelenga's full-sized avatar
🇺🇦
Annihilating code

Vitalii Elenhaupt veelenga

🇺🇦
Annihilating code
View GitHub Profile
@veelenga
veelenga / benchmark_test.cr
Last active October 3, 2015 19:50
Benchmarking in Crystal (for blogpost http://veelenga.com/benchmarking-in-crystal/)
require "benchmark"
puts ">> Array#[] vs Array#[]?"
arr = Array.new(1000, 1)
Benchmark.ips do |x|
x.report("Array#[]" ) { arr[500] }
x.report("Array#[]?") { arr[500]? }
end
puts ">> Interpolation vs Int32#to_s"
@veelenga
veelenga / tap_and_itself.cr
Created September 24, 2015 10:18
Methods tap and itself in Crystal (for blogpost http://veelenga.com/tap-and-itself-methods-in-crystal/)
################################################################################
p 10.itself # 10
p "1".itself # "1"
p :sym.itself # :sym
p true.itself # true
p nil.itself # nil
p [1, 2].itself # [1, 2]
p ({"1" => "2"} of String => String).itself # {"1" => "2"}
p /1/.itself # /1/
@veelenga
veelenga / hgArtifacts.py
Created June 25, 2015 06:18
Tiny Python script to load files from Mercurial repository
from optparse import OptionParser
from subprocess import call
from subprocess import check_output
import urllib
import re
import os
import sys
import shutil
def getUrlCode(url):
@veelenga
veelenga / git_notes.md
Last active November 20, 2015 06:00
git notes
@veelenga
veelenga / currency.sh
Last active July 5, 2016 09:45
i3blocks script gist for displaying current currency ratio from Google's finance convertor
#!/bin/sh
# Copyright (C) 2014 Vitaliy Elengaupt <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of