Skip to content

Instantly share code, notes, and snippets.

View macobo's full-sized avatar
🚀

Karl-Aksel Puulmann macobo

🚀
View GitHub Profile
from itertools import islice
from bisect import bisect_left
keyboard = {
1: '',
2: 'abc',
3: 'def',
4: 'ghi',
5: 'jkl',
6: 'mno',
module Interactors
class Base
def call(*args)
@memo ||= {}
return @memo[args] if @memo.has_key?(args)
@memo[args] = calculate(*args)
end
# @abstract Subclass is expected to implement a pure method #calculate
# @!method calculate
@macobo
macobo / flatten.py
Created January 2, 2017 10:31
Python with simple [MyPy](https://github.com/python/mypy) type validation.
from typing import Iterator, List, TypeVar, Union
T = TypeVar('T')
def flatten_generator(nestedlist: List[Union[T, List[T]]]) -> Iterator[int]:
if not isinstance(nestedlist, list):
yield nestedlist
else:
for sublist in nestedlist:
yield from flatten_generator(sublist)
@macobo
macobo / Test.scala
Last active December 1, 2016 19:12
Repor
package com.heap
import java.util.Date
import java.util.concurrent.Executors
import kamon.Kamon
import scala.concurrent.duration._
import scala.concurrent.{Await, ExecutionContext, Future}

Keybase proof

I hereby claim:

  • I am macobo on github.
  • I am macobo (https://keybase.io/macobo) on keybase.
  • I have a public key whose fingerprint is B4F2 139B 26AF C894 F85D C653 FA1B 8E2D 4433 3198

To claim this, I am signing this object:

_ = require 'lodash'
async = require 'async'
log = require 'log'
connection = require '../orm/connection'
# distinct - only choose 1 replica for each shard
# returns a list of objects with {shardId, isShared, [appId | minAppId,maxAppId], dbLocation, tablename, normalized}
getAllShards = (distinct, callback) ->
query = """
[ { table: 'users',
shardid: '540275',
dbLocation: 'double-guy-101:7432' },
{ table: 'events',
shardid: '540276',
dbLocation: 'double-guy-101:7432' },
{ table: 'users',
shardid: '702536',
dbLocation: 'double-guy-101:7432' },
{ table: 'users',
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"auto_complete_triggers": [
{
"characters": ".@",
"selector": "source.coffee, source.litcoffee, source.coffee.md"
}
]
}
from kafka import KafkaClient
from kazoo.client import KazooClient
from kafka.common import OffsetRequest
from checks import AgentCheck
import json
def chunk(lists, n):
for i in range(0, len(lists), n):
yield tuple(lists[i:i+n])
@macobo
macobo / 229B.py
Created February 1, 2015 13:11
Näitelahendused, Graafid 2
from heapq import *
from collections import defaultdict
from sys import stdin
def readNums():
return [int(x) for x in stdin.readline().split()]
planets, no_roads = readNums()
# if we do roads[key].append(value) and key wasn't set before, we get roads[key] == [value]
# avoids doing