Skip to content

Instantly share code, notes, and snippets.

View hhariri's full-sized avatar

Hadi Hariri hhariri

View GitHub Profile
@Magic
@SomeMoreMagic
@EvenMoreMagic
@AwesomeSauce
class Simple
val x = 100
val y = 1
for (i in 0..x step y) {
}
val r = 1..100
for (z in r) {
println(z)
}
@hhariri
hhariri / Dockerfile
Created August 14, 2016 19:39
Jekyll
# Docker for Jekyll
FROM alpine:latest
MAINTAINER Hadi Hariri <mail@hadihariri.com>
# Install base, Ruby, Headers, Jekyll, Export Path and Clean Up
RUN apk update && apk upgrade && apk add curl wget bash && \
apk add ruby ruby-bundler ruby-dev ruby-irb ruby-rdoc libatomic readline readline-dev \
libxml2 libxml2-dev libxslt libxslt-dev zlib-dev zlib \
libffi-dev build-base git nodejs && \
export PATH="/root/.rbenv/bin:$PATH" && \
@hhariri
hhariri / post.txt
Created April 15, 2016 21:04
I was unfollowed on Twitter and here's what happened
1. It's a boy's club (by and large)
2. The submission process is major pain. 100 fields to fill out
3. They want it to be focused entirely around Microsoft products, and giving little attention to other important values of software development.
4. They don't cover travel expenses unless you know somebody or fight for it. And covering for some and not all is wrong.
5. They want to review your presentation and have the right to modify it if they want.
6. It's hardly about development anymore, but IT.
and finally, the whole conference is a lot of hype and somewhat arguable formalities.
fun albumAndTrackLowerThanGivenSeconds_v2(durationInSeconds: Int, albums: List<Album>): List<Pair<String, String>> {
return albums.flatMap {
val album = it.title
it.tracks.filter {
it.durationInSeconds <= durationInSeconds
}.map {
Pair(album, it.title)
}
}
}
fun <T, R, C: MutableCollection<in R>> Iterable<T>.flatMapTo(result: C, transform: (T) -> Iterable<R>) : C
fun <T, R> Iterable<T>.flatMap(transform: (T)-> Iterable<R>) : List<R>
fun albumAndTrackLowerThanGivenSeconds_v1(durationInSeconds: Int, albums: List<Album>): List<Pair<String, String>> {
val list = arrayListOf<Pair<String, String>>()
albums.forEach {
val album = it.title
it.tracks.filter {
it.durationInSeconds <= durationInSeconds
}.map {
list.add(Pair(album, it.title))
}
fun nameAndTotalTime_v2(albums: List<Album>): List<Pair<String, Int>> {
return albums.map {
Pair(it.title, it.tracks.map { it.durationInSeconds }.reduce { x, y -> x +y })
}
}