Skip to content

Instantly share code, notes, and snippets.

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 / example.md
Last active Mar 26, 2020
Some reason do not build docker by Packer
View example.md
  1. Packer change entrypoint. This is obscure if you are just trying packer. You can read this here

  2. Packer doesn't work with scratch/distroless images(and another without bash) If your docker image has no bash packer does not build your image. See here

  3. Packer has no some docker command like copy. See here

View insertion_sort.rb
# O(n^2)
def insertion_sort arr
i = 0
j = 0
for i in 1...(arr.length) do
key = arr[i]
j = i - 1
while j >= 0 and key < arr[j] do
arr[j + 1] = arr[j]
@Bablzz
Bablzz / fib_memo.rb
Last active Dec 13, 2019
Fibonacci with memoization
View fib_memo.rb
memo = Hash.new(0)
def fib_rec (number, memo)
if number == 0
return number
elsif (number == 1) || (number == 2)
return 1
end
if (memo.has_key?(number))
return memo[number]
@Bablzz
Bablzz / tower.py
Created Nov 20, 2019
Tower of Hanoi
View tower.py
def solve(n, a, b, c):
if n > 0:
solve(n - 1, a, c, b)
print('Move disk from ' + a + ' to disk ' + b)
solve(n - 1, c, b, a)
solve(3, '1', '2', '3')
@Bablzz
Bablzz / sieve.py
Last active Oct 30, 2019
Sieve of Eratosthenes
View sieve.py
# O(n log(log n))
arr = list(range(0, 300))
def sieve(ar):
for i in ar:
if i > 1:
step = arr[i]
while (arr[i] + step) < len(arr):
@Bablzz
Bablzz / simple.py
Last active Oct 23, 2019
Check if digit is simple
View simple.py
def is_simple(digit):
for i in range(2, digit - 1):
if ((digit % i) == 0):
return False
else:
return True
print(is_simple(72)) # False
print(is_simple(73)) # True
@Bablzz
Bablzz / bank.rb
Created Oct 21, 2019
Bank deposite
View bank.rb
years = 5
a = 1000
def bank(a, years)
i = 0
while i != years
b = (a * 0.1) + a
a = b
i += 1
end
@Bablzz
Bablzz / puzzles.rb
Last active Sep 25, 2019
small_puzzles.rb
View puzzles.rb
digit = 543210
# Reverse digit
def reverse_digit(digit)
str = digit.to_s.reverse.split('')
if str.first == '0'
str.shift
end
str.join('').to_i
end
@Bablzz
Bablzz / max.go
Last active Sep 18, 2019
Max digit without condition
View max.go
package main
import (
"fmt"
"math"
)
func main() {
a := 32
b := -44
@Bablzz
Bablzz / caesar.go
Last active Sep 16, 2019
Caesar cypher
View caesar.go
package main
import "fmt"
var mes = "test cypeher with digit 6"
func main() {
bs := ([]byte)(mes)
cyp := make([]byte, len(bs))
j := 0