Skip to content

Instantly share code, notes, and snippets.

View RadoRado's full-sized avatar

Radoslav Georgiev RadoRado

View GitHub Profile
@RadoRado
RadoRado / A.hs
Created January 18, 2015 16:28
Haskell Modules
module A (omgwtf) where
omgwtf :: Int -> Int
omgwtf x = x + 1
names = ["Ivan", "Asen", "Vtori"]
result = ""
index = 0
last = len(names) - 1
for name in names:
if index == last:
result = result + name
else:
@RadoRado
RadoRado / main.py
Created February 17, 2015 08:45
Example for using main() and if __name__ check
def divisors(n):
result = []
start = 1
while start < n:
if n % start == 0:
result = result + [start]
start += 1
@RadoRado
RadoRado / count_elements.py
Created February 17, 2015 08:54
Example for counting elements and inputing from user
def count_elements(xs):
count = 0
for element in xs:
count += 1
return count
n = input("Enter n: ")
@RadoRado
RadoRado / problems.md
Created February 18, 2015 18:33
Това е Радо!

Задачи

Задача 1

Условие, условие:

  • Правим нещо
  • После друго нещо
  • Накрая трето
@RadoRado
RadoRado / first_exam.rkt
Last active November 19, 2016 16:44
FP 2016 solutions for first exam
#lang racket
(define (decreasing? ns)
(cond
[(empty? ns) #f]
[(empty? (rest ns)) #t]
[else (and (>= (first ns) (second ns)) (decreasing? (rest ns)))]))
(define (number->list n)
(define (iter n result)
@RadoRado
RadoRado / example.py
Created February 20, 2019 09:24
Example gist to be placed in blog
def schema_validator(schema: Schema, data: Data) -> Tuple[bool, MissingKeys, AdditionalKeys]:
schema_paths = set(build_paths(get_paths(schema)))
data_paths = set(build_paths(get_paths(data)))
missing_keys = schema_paths - data_paths
additional_keys = data_paths - schema_paths
return schema_paths == data_paths, sorted(missing_keys), sorted(additional_keys)
@RadoRado
RadoRado / ec2_explore.py
Created April 7, 2019 08:30
Quick and dirty script to find out what EC2 instances are existing in which regions
from subprocess import check_output
from shlex import split
import json
REGIONS = (
'us-east-2',
'us-east-1',
'us-west-1',
'us-west-2',