Skip to content

Instantly share code, notes, and snippets.

Avatar

Eugene Kozlov abstractart

View GitHub Profile
@abstractart
abstractart / fibonacci_with_fibers.rb
Created Jul 5, 2021
A implementation of Fibonacci function using Ruby Fibers
View fibonacci_with_fibers.rb
fib = Fiber.new do
last = [0, 1]
while(true)
v = last.sum
last[0] = last[1]
last[1] = v
Fiber.yield v
end
View game-of-life.py
from random import randint
from time import sleep
from copy import deepcopy
import os
LIFE = 1
DEATH = 0
def main():
cols, rows = 7, 7
@abstractart
abstractart / script.rb
Last active Jun 10, 2020
Constructor with block in Ruby
View script.rb
class A
attr_accessor :attribute
def initialize
yield self
end
end
a = A.new {|a| a.attribute = "block" }.tap {|a| puts a.attribute }
@abstractart
abstractart / .ssh.config
Created Apr 28, 2019
SSH connection through shadowsocks
View .ssh.config
# ~/.ssh/config
Host 159.89.190.250 # DigitalOcean droplet ip
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p # 127.0.0.1:1080 - shadowsocks
View replication.rb
def replication(num, list)
replicate_acc([], 0, 0, num, list)
end
def replicate_acc(acc, current_num, index, num, list)
return acc if index >= list.length
if current_num < num
acc << list[index]
current_num += 1
@abstractart
abstractart / script.rb
Created Nov 6, 2018
Downcase non-ASCII characters in Ruby < 2.4
View script.rb
# gem install activesupport
require 'active_support/core_ext/string/multibyte'
"Женя".mb_chars.downcase.to_s # => "женя"
"Женя".mb_chars.upcase.to_s # => "ЖЕНЯ"
@abstractart
abstractart / elastic.sh
Created Sep 14, 2018
Install ElasticSearch 1.7.6 with morphology plugin (Ubuntu/Debian)
View elastic.sh
# Install & Setup ElasticSearch
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.6.deb
sudo dpkg -i elasticsearch-1.7.6.deb
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service
sudo systemctl status elasticsearch.service
# Install & Setup Morphology plugin
wget http://dl.bintray.com/content/imotov/elasticsearch-plugins/org/elasticsearch/elasticsearch-analysis-morphology/1.2.1/elasticsearch-analysis-morphology-1.2.1.zip
@abstractart
abstractart / books.md
Last active Jul 20, 2021
Direct links to Free Codeship eBooks about Continuous Integration and Delivery, Docker, efficient Software Development, distributed team workflows, and much more.
@abstractart
abstractart / books.md
Last active Aug 11, 2021
Free Programming Ebooks - O'Reilly Media. Codeship free ebooks here - https://bit.ly/2oQ0knQ
View books.md