Skip to content

Instantly share code, notes, and snippets.

View Bablzz's full-sized avatar
💭
Quality is remembered long after the price is forgotten (Sir Frederick Royce)

Maksim Sokolnikov Bablzz

💭
Quality is remembered long after the price is forgotten (Sir Frederick Royce)
View GitHub Profile
@Bablzz
Bablzz / Luhn.rb
Last active July 3, 2019 11:57
Luhn algorithm
def sum_digits digit
if digit < 10
digit
else
(digit % 10) + (digit / 10).to_f
end
end
def validate number
number = number.to_s.reverse.to_i
@Bablzz
Bablzz / dijkstra.rb
Created July 1, 2019 14:06
dijkstra's_algorithm
graph = {}
graph['start'] = Hash.new
graph['start']['a'] = 6
graph['start']['b'] = 2
graph['a'] = Hash.new
graph['a']['fin'] = 1
graph['b'] = Hash.new
graph['b']['a'] = 3
graph['b']['fin'] = 5
@Bablzz
Bablzz / s_sort.rb
Last active August 8, 2018 14:51
selection sort
arr = [9,81,-9,3,0,12,-10]
def find_min(list)
min = list[0]
index = 0
list.each_with_index do |val, i|
if val < min
min = val
index = i
end
@Bablzz
Bablzz / dockerfile_spec.rb
Created August 8, 2018 14:49
Test dockefile with ruby/docker-api/serverspec
require "serverspec"
require "docker"
package = ['rake', 'pg']
describe "Dockerfile" do
before(:all) do
@image = Docker::Image.build_from_dir('.', {'dockerfile'=>'Dockerfile'})
@image.tag(repo: 'image-test', tag: 'latest').
def check(arr)
counter = 0
arr.each do |key|
if key == '('
counter += 1
else
counter -= 1
end
end
echo "##teamcity[addBuildTag '%build%']"
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -y ansible zip unzip
SHELL
ALTER SYSTEM SET fixed_date = ‘2009-07-14-10:00:00?;
To unset:
ALTER SYSTEM SET FIXED_DATE=NONE;
- hosts: host1
vars:
# created with:
# python -c "from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.using(rounds=1000).hash(getpass.getpass())"
password: "$6$rounds=1000$7dsUf2EPFiC7m4FV$RM9lxRRaannAAmOfRbjvk9V8OSENyFxBaMkOFnIvjeECw39QLCXfFvJlRqGhypDjG8RKOjwp1ufJJD3JZSpu2."
user: "test_user"
tasks:
- name: "Create group"
group:
from passlib.hash
import sha512_crypt;
import getpass;
print sha512_crypt.using(rounds=1000).hash(getpass.getpass())