Skip to content

Instantly share code, notes, and snippets.

View mzimecki's full-sized avatar

Marcin Zimecki mzimecki

  • Gdańsk, Poland
View GitHub Profile
@mzimecki
mzimecki / ruby_code_kata.rb
Last active March 7, 2017 14:15
[Ruby] My first code kata
def find_needle(haystack)
haystack.each_with_index do |elem, i|
if elem.to_s.eql?(‘needle’)
return “found the needle at position #{i}”
end
end
end
@mzimecki
mzimecki / The Technical Interview Cheat Sheet.md
Created February 26, 2017 10:16 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@mzimecki
mzimecki / ExecutorsExample.java
Created November 1, 2013 15:54
[Java] Callable, Future, Executors example
package com.zimek.executors;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@mzimecki
mzimecki / FileWrapper.scala
Created November 1, 2013 10:22
[Scala] Views example from Scala in Depth book
import FileWrapper.wrap
/**
* Views example: converting one type to other.
*/
class FileWrapper(val file: java.io.File) {
def /(next: String) = new FileWrapper(new java.io.File(file, next))
override def toString = file.getCanonicalPath()
}
@mzimecki
mzimecki / Max.scala
Created October 26, 2013 19:43
[Scala] generic max function
def max[T](xs: T*)(implicit ord: Ordering[T]): T = xs.reduceLeft((a, b) => if (ord.gteq(a, b)) a else b)
@mzimecki
mzimecki / MergeSort.scala
Created October 16, 2013 09:20
[Scala] Merge sort with implicit parameter used for comparing elements in a list. Making prameter implicit will cause compiler will discover type of elements in a list to be sorted.
object MergeSort {
def msort[T](xs: List[T])(implicit ord: Ordering[T]): List[T] = {
def merge(xs: List[T], ys: List[T]): List[T] = (xs, ys) match {
case (Nil, ys) => ys
case (xs, Nil) => xs
case (x :: xs1, y :: ys1) =>
if (ord.lt(x, y)) x :: merge(xs1, ys) else y :: merge(xs, ys1)
}
@mzimecki
mzimecki / InsertionSort.scala
Created October 12, 2013 19:09
[Scala] Insertion sort
object InsertionSort {
def sort(list: List[Int]): List[Int] = {
def insert(x: Int, xs: List[Int]): List[Int] = xs match {
case List() => List(x)
case y :: ys => if (x <= y) x :: xs else y :: insert(x, ys)
}
list match {
case List() => List()
@mzimecki
mzimecki / HashCodeEqualsExample.scala
Last active December 25, 2015 07:09
[Scala] hashCode and equals of mutable object
import scala.collection.immutable.HashMap
/**
* hashCode and equals of mutable object (not working well because of object mutability)
* the only way to make it working is to use immutable object
*/
class Point2(var x: Int, var y: Int) {
def move(mx: Int, my: Int): Unit = {
x = x + mx
y = y + my
}
@mzimecki
mzimecki / AndOr.scala
Last active December 23, 2015 06:09
[Scala] Functions and(x,y) and or(x,y)
def and(x: Boolean, y: =>Boolean) = if (x) y else false
def or(x: Boolean, y: =>Boolean) = if (x) true else y