Skip to content

Instantly share code, notes, and snippets.

View groz's full-sized avatar

Tagir Magomedov groz

  • Amsterdam, NL
  • 23:47 (UTC +02:00)
View GitHub Profile
@groz
groz / numl_kmeans_error
Created March 15, 2014 01:28
Demonstrates error (or my misunderstanding) of KMeans algorithm in numl.
using System;
using numl.Model;
using numl.Unsupervised;
namespace KmeansError
{
class Program
{
class DataPoint
{
@groz
groz / fotmjs-todo-list
Last active August 29, 2015 14:10
ToDo list for fotmjs project.
Main
- [ ] Implement Monitor's dependencies for Google cloud VM backend
- [ ] Storage
- [ ] Pub/sub
- [ ] Analytics
- [ ] Implement brain
Architecture
- [ ] Move modules to separate folders (monitor/ brain/ etc)
- [ ] Create tests for each module
- [ ] Track code coverage
@groz
groz / gist:ad8f962de5e35923339a
Last active August 29, 2015 14:22
Scala cheat sheet (ru)
/*
В одном проекте и даже одном файле может быть объявлено несколько приложений (или точек входа).
Запуск нужного производится следующей командой:
$ sbt "run-main <полное имя объекта>"
Пример:
$ sbt "run-main Integers"
*/
/*
Назовем набор кортежей целых чисел кластером
Входные данные алгоритма: один кластер
Выходные данные: разбиение входного кластера на непересекающиеся подкластеры
*/
abstract class Clusterer {
type V = Vector[Double]
type Cluster = Seq[V]
def clusterize(input: Cluster): Set[Cluster]
import info.fotm.crawler.ObservableStream
val sink = new ObservableStream[Int] {
def put(x: Int) = super.publish(x)
}
val othersink = new ObservableStream[Int] {
def put(x: Int) = super.publish(x)
}
@groz
groz / gameoflife.scala
Last active September 23, 2015 22:39
Conway's Game of Life in Scala
package gameoflife
final case class Cell(x: Long, y: Long)
// Actual solution
object Life {
def proximity(c: Cell): Set[Cell] =
(for {
x <- -1 to 1
@groz
groz / main.cpp
Created September 30, 2015 08:48
Conway's Game of Life in C++
#include <iostream>
#include <set>
using namespace std;
struct Cell {
const long x, y;
Cell(long sx, long sy) : x(sx), y(sy) { }
@groz
groz / FBSampleApp.scala
Created October 10, 2015 00:27
Facebook's how to crush your coding interview example in Scala.
object FBSampleApp extends App {
// sample implementations
def nearbyChars(c: Char): Set[Char] = Set(c + 0, c + 1).map(_.toChar)
def isWord(s: String): Boolean = true
def distSoFar(a: String, b: String) = a.zip(b).count(ab => ab._1 != ab._2)
def nearbyWords(input: String, maxDist: Int = 1): Set[String] =
input.foldLeft(Set("")) { (words, char) =>
for {
@groz
groz / parsers_lecture.hs
Created November 19, 2015 08:59
fp101x parsers lecture working example
module Parsers where
import Prelude hiding (fail, return, (>>=))
type Parser a = String -> [(a, String)]
item :: Parser Char
item [] = []
item (c:cs) = [(c, cs)]
fail :: Parser a
@groz
groz / RandomAccessListApp.scala
Created April 22, 2016 01:42
Scala RandomAccessList
trait Node[+T] {
val index: Int
val left: Node[T]
val right: Node[T]
val len: Int
def apply(index: Int): T = ???
def update[X >: T](index: Int, value: X): Node[X] = ???
}
case object NullNode extends Node[Nothing] {