Skip to content

Instantly share code, notes, and snippets.

View sovetnik's full-sized avatar
🪓
Ярость топора!

Oleg Sovetnik sovetnik

🪓
Ярость топора!
View GitHub Profile
@sovetnik
sovetnik / setup.sh
Created November 19, 2019 14:26
Catalina setup WIP
# check versions
git --version
zsh --version
ruby -v
vim -v
# Command line tools
xcode-select --install
echo "Command line tools installed"
@sovetnik
sovetnik / monad_matchers.rb
Last active April 9, 2019 16:23
Monad matchers
# frozen_string_literal: true
# For everything successful we can match it's value
RSpec::Matchers.define :hold do |expected|
match do |actual|
return false unless actual.success?
expect(actual.value!.inspect).to eq expected.inspect
end
failure_message do |actual|
@sovetnik
sovetnik / books.sql
Last active October 30, 2017 22:57
Data and query to select authors which not collaborate with others
-- Create authors
CREATE TABLE authors(id serial PRIMARY KEY, name char(255));
-- Single author of many books
INSERT INTO authors(name)
VALUES ('William Gibson');
-- Collective of authors of one book
INSERT INTO authors(name)
@sovetnik
sovetnik / book.rb
Last active May 20, 2017 09:01
Reading aggregate
class Book < Hanami::Entity
attributes do
attribute :id, Types::Int
attribute :title, Types::String
attribute :author, Types::String
attribute :publisher, Types::String
end
end
@sovetnik
sovetnik / fb.erl
Last active May 16, 2017 14:38
FizzBuzz in Erlang
-module(fb).
-export([run/0, run/1, tell/1]).
run() -> lists:map(fun(L) -> io:format('~p ~n', [tell(L)]) end, lists:seq(1,100)).
run(N) -> lists:map(fun(L) -> io:format('~p ~n', [tell(L)]) end, lists:seq(1,N)).
tell(N) when N rem 15 == 0 -> 'FizzBuzz';
tell(N) when N rem 3 == 0 -> 'Fizz';
tell(N) when N rem 5 == 0 -> 'Buzz';
@sovetnik
sovetnik / gist:7b2ddac2834b92129595
Created October 2, 2015 01:06 — forked from dreadatour/gist:7475747
Remove default Sublime Text 3 snippets
# Sublime Text 3 languages list:
ls -1 /Applications/Sublime\ Text.app/Contents/MacOS/Packages/
# Remove all default Sublime Text 3 snippets for Python language
export ST3_LANG="Python"
mkdir -p ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/$ST3_LANG/
unzip -l /Applications/Sublime\ Text.app/Contents/MacOS/Packages/$ST3_LANG.sublime-package | grep '.sublime-snippet' | awk '{print $4}' | while read f; do touch ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/$ST3_LANG/$f; done
unset ST3_LANG
@sovetnik
sovetnik / dexter.rb
Last active August 29, 2015 14:08
Dexter - by row CSV time series splitter
class Dexter
# file = "/home/Rfiles/EURUSD.csv"
def initialize file
@@pair = 'EU' # For output .csv name
@@file = File.new file
@@directory = File.dirname file
@@head = @@file.gets.chomp.split(',')
@@time = Time.now
<%# shared/_flash_messages.html.erb %>
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<i class='<%= bootstrap_icon_for(type) %>'></i> <%= message %>
</div>
<% end %>
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>