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
# run with (update the link after editing this file on gist) | |
# bash <(curl -s https://gist.githubusercontent.com/vysogot/5f30427e1f6a9cfe17320d62114faa47/raw/2f03b48494657ffecec7fa26f0e221e82833973c/vim_zsh_install.sh) | |
sudo apt-get update | |
# linux packages (when not available via apt) | |
cd && curl -LO https://github.com/sharkdp/fd/releases/download/v8.2.1/fd_8.2.1_amd64.deb | |
sudo dpkg -i fd_8.2.1_amd64.deb | |
curl -LO https://github.com/BurntSushi/ripgrep/releases/download/12.1.1/ripgrep_12.1.1_amd64.deb | |
sudo dpkg -i ripgrep_12.1.1_amd64.deb |
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
# Animals share some behaviour but each kind needs to be configured properly | |
# I used it to configure sidekiq workers that share sending metrics, logging, | |
# or error handling, but some of them don't send metrics for example | |
# and they need to be configured. | |
class Animal | |
def say_hi | |
puts(greeting_prefix + config.name + hobby_prefix + config.hobby) | |
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
IS_ZERO = -> (x) { x == 0 } | |
ONE = -> { 1 } | |
ONE_LESS = -> (x) { x - 1 } | |
ITSELF = -> (x) { x } | |
COND = -> (cond) { -> (doit) { -> (doelse) { cond ? doit.(nil) : doelse.(nil) } } } | |
MULT = -> (x) { -> (y) { x * y } } | |
puts( | |
-> myself { | |
-> (n) { |
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
defmodule Solution do | |
def odds(elements) do | |
Enum.with_index(elements) | |
|> Enum.map_reduce([], fn {element, index}, acc -> | |
case rem(index, 2) == 1 do | |
true -> {{element, index}, acc ++ [element]} | |
_ -> {{element, index}, acc} | |
end | |
end) | |
|> elem(1) |
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 ruby -wKU | |
# | |
# based on a script | |
# by Kelan Champagne | |
# http://kelan.io | |
require 'date' | |
# Config values | |
podcast_title = "Title" |
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
# Paste your transcript between the quotes | |
# and run | |
# ruby youtube-transcript-to-srt.rb > subtitles.srt | |
transcript = "0:00 Hello and welcome | |
0:05 This is a very nice story | |
0:10 and it needs subtitles" | |
times = transcript.split("\n").map {|x| x[0..4].strip.rjust(5, '0')} | |
times << times[-1] |
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
/* Algorithm based on delay for running different outputs in given LOW/HIGH intervals | |
This code is meant to control the relay grid behind a washing machine | |
and it can be used for many other devices. By Jakub Godawa (vysogot) */ | |
/* addresses for Arduino Uno (!setup properly for Arduino Mega or other!) */ | |
const int r1out = A0; | |
const int r2out = A1; | |
const int s3out = A2; | |
const int s4out = A3; | |
const int s5out = A4; |
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
class PeopleMatcher | |
include FilterMatcher | |
attr_reader :db | |
def initialize(db, input) | |
@db, @input = db, input | |
end | |
def match |
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
module FilterMatcher | |
# | |
# define filter in a class that uses this module | |
# named like: | |
# - name_filter | |
# - age_filter | |
# | |
# they should a filtered array | |
# |
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 'test/unit' | |
class PeopleMatcherTest < Test::Unit::TestCase | |
def setup | |
@db = [ | |
{ :id => 1, :name => "John", :age => 33, :homepage => "www.johny.com", :matched => false }, | |
{ :id => 2, :name => "Mike", :age => 30, :homepage => "www.mikes.com", :matched => false }, | |
{ :id => 3, :name => "Johny", :age => 25, :homepage => "www.johny.com", :matched => false }, | |
{ :id => 4, :name => "Mike", :age => 30, :homepage => "www.realmike.com", :matched => false }, | |
{ :id => 5, :name => "Dan", :age => 25, :homepage => "www.danny.com", :matched => false }, |
NewerOlder