Skip to content

Instantly share code, notes, and snippets.

View RadoRado's full-sized avatar

Radoslav Georgiev RadoRado

View GitHub Profile
@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',
@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 / 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 / problems.md
Created February 18, 2015 18:33
Това е Радо!

Задачи

Задача 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 / 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
names = ["Ivan", "Asen", "Vtori"]
result = ""
index = 0
last = len(names) - 1
for name in names:
if index == last:
result = result + name
else:
@RadoRado
RadoRado / A.hs
Created January 18, 2015 16:28
Haskell Modules
module A (omgwtf) where
omgwtf :: Int -> Int
omgwtf x = x + 1
@RadoRado
RadoRado / router.js
Created October 11, 2014 21:18
Minimal NodeJS HTTP router, made for an example. Kudos to @asotirov
/* global module, console */
module.exports = function(http, port) {
'use strict';
var routes = {};
var exportMethods = {};
var middlewares = [];
['get', 'post', 'put', 'delete'].forEach(function(method) {
routes[method] = routes[method] || {};
@RadoRado
RadoRado / compose.scm
Last active December 25, 2015 17:09
Difference between composing funcions and returning result and composing functions and returning new function
; в този вариант, функцията compose връща директно резултата
; като изпълниш (f (g x)) - ако x е число, накрая просто ще ти върне някакъв резултат
(define (compose-first f g x)
(g (f x)))
; например това извикване ще ти даде директно резултат 2
(compose-first (lambda (x) (+ x 1)) (lambda (x) (- x 1)) 2)
; този compose, не ти връща директно скаларен резултат