Skip to content

Instantly share code, notes, and snippets.

View djipko's full-sized avatar

Nikola Dipanov djipko

View GitHub Profile
@djipko
djipko / gist:1793463
Created February 10, 2012 22:16
Solution to Embedly problem #1
from math import factorial
from operator import add
from itertools import count
def R(n):
return reduce(add, map(int, str(factorial(n))))
if __name__ == "__main__":
#Brute force works just fine on my makbook air so...
for n in count():
@djipko
djipko / gist:1793535
Created February 10, 2012 22:18
Emebdly solution #2
from HTMLParser import HTMLParser
from operator import add
from math import sqrt, pow
import requests
class EmbedlyParser(HTMLParser):
depth = 1
ps = []
article = False
@djipko
djipko / gist:1793551
Created February 10, 2012 22:22
Embedly solution #3
from operator import add
if __name__ == "__main__":
most_frequent = 2520
freq_list = [most_frequent/n for n in xrange(1, 901)]
total_w = reduce(add, freq_list)
half = total_w/2
cnt = 0
for i, f in enumerate(freq_list, start = 1):
cnt+=f
import gc
import os
import requests
import subprocess
import sys
class request_maker(object):
def __init__(self):
self.s = requests.Session()
def make(self):
import random
import time
import uuid
if __name__ == "__main__":
# 1k instance per host on the heavy side
uuid_list = [str(uuid.uuid4()) for x in xrange(1000)]
# 100 claims also on the heavy side
uuids_to_check = [str(uuid.uuid4()) for x in xrange(100)]
#!/bin/bash
# A script to run tests using khaleesi
# Usage:
#
# Run tests using a RHOS 7/RHEL 7 environment
# ./tools/khaleesi.sh
#
# Run tests using a RHOS 5/RHEL 7 environment
@djipko
djipko / loco.py
Last active March 15, 2016 11:17
import heapq
import sys
class LogFile(object):
def __init__(self, filename):
self.filename = filename
self.f = open(filename)
self.sort_field = self.line = None
self.done = False
use std::error::Error;
use combinations::Combinations;
use std::io::{self, Read};
fn main() -> Result<(), Box<dyn Error>> {
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer)?;
let expenses = buffer
.trim_end()
.split("\n")
use std::error::Error;
use std::io::{self, Read};
#[derive(Debug)]
struct Departure {
id: u64,
wait: u64,
}
impl Departure {