Skip to content

Instantly share code, notes, and snippets.

Eran Kampf ekampf

Block or report user

Report or block ekampf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ekampf
ekampf / pypossibly.py
Created Jun 11, 2014
Python option patrern (Maybe Monad)
View pypossibly.py
import logging
import sys
class Maybe(object):
pass
class Nothing(Maybe):
def is_some(self):
return False
@ekampf
ekampf / mem.c
Last active May 27, 2019
Eran's Interview Question
View mem.c
// Implement a virtual memory manager that takes a large contiguous block of memory and manages allocations
// and deallocations on it.
// The entire buffer needs to be available for allocation. You can use whatever extra memory you need to manage it.
//
// Clearly document design choices, algorithm and possible optimizations.
// While we require you to implement one memory allocation algorithm,
// also document future looking design considerations.
// There are many ways to implement this memory manager. It is important for us to know why you implemented it the way you did,
// whats the pros and cons to your implementation, etc.
//
@ekampf
ekampf / gist:772597
Created Jan 10, 2011
Show the current Git branch in the command line prompt
View gist:772597
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PS1="$GREEN\u@machine$NO_COLOUR:\w$YELLOW\$(parse_git_branch)$NO_COLOUR\$ "
View GalaxyCount.md

Galaxies Count

Problem Description

Given a 2d grid of '1's (space clusters with stars) and '0's (dark space clusters without any stars), count the number of galaxies on the grid. An Galaxy is a group a space clusters containing stars, surrounded by dark clusters (no starts) and connected horizontally or vertically.

Examples:

View cache.py
// Implement a cache class that stores given item. The cache is limited to a given `size` and will discard the
// least recently used item if it needs the space.
//
// Clearly document design choices, algorithm and possible optimizations.
// While we require you to implement one memory allocation algorithm,
// also document future looking design considerations.
//
// Implementation Notes:
// * While the interface below is written in Python, feel free to implement the Cache in the language of your choosing.
// * Do not use standard library data structures - write your own. (like Python's `collections` module etc.)
@ekampf
ekampf / setup_kafka.sh
Last active Nov 29, 2017
Setup Kafka (0.8.0) on OSX
View setup_kafka.sh
brew install sbt
cd /tmp
wget http://apache.spd.co.il/kafka/0.8.0/kafka_2.8.0-0.8.0.tar.gz
tar -zxvf kafka_2.8.0-0.8.0.tar.gz -C /usr/local/
cd /usr/local/kafka_2.8.0-0.8.0
sbt update
sbt package
@ekampf
ekampf / big_query_dsl.py
Last active Apr 28, 2017
Choosing an Analytics Schema Scales
View big_query_dsl.py
__author__ = 'ekampf'
class FieldTypes(object):
integer = 'INTEGER'
float = 'FLOAT'
string = 'STRING'
record = 'RECORD'
ts = 'TIMESTAMP'
class FieldMode(object):
View test
{
"streams": {
"nasa": {
"input-path": "/HBOHD_HD_TVE_15152_0_5472624192174078163/format-hls-track-muxed-bandwidth-3101600-repid-root_audio_video1.m3u8",
"servers": [
"http://odol-atsec-sfb-43.linear-tve-pil.top.comcast.net"
]
}
},
"actions": [
@ekampf
ekampf / normalize.py
Last active Nov 20, 2016
Normalize values by std deviation
View normalize.py
def zscore(numbers_list):
numbers = numpy.array(numbers_list)
return (numbers - numbers.mean()) / numbers.std()
@ekampf
ekampf / gist:7721226
Created Nov 30, 2013
Code to convert temperature from Arduino's temperature sensor into heatmap RGB
View gist:7721226
const int rLED = 11;
const int gLED = 9;
const int bLED = 10;
const int sensor = A0;
const float minTemp = 10.0;
const float maxTemp = 50.0;
int redV = 0;
int greenV = 0;
You can’t perform that action at this time.