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
data class Customer(val name: String, val email: String)
if you want to have mutable properties
data class Customer(var name: String, var email: String)
// Without it
ObservableHttp.createRequest(HttpAsyncMethods.createGet(url), client)
.toObservable()
.flatMap({ response -> response.getContent().map {
byte ->
String(byte)
}
})
.toBlocking()
.forEach {
return ObservableHttp.createRequest(HttpAsyncMethods.createGet(url), client)
.toObservable()
.flatMap({ response -> response.getContent().map {
byte ->
String(byte)
}
})
.toBlocking()
.forEach {
data -> println(data)
package com.somanyfeeds.application
import javax.servlet.annotation.WebServlet
import javax.servlet.http.*
import java.io.InputStream
import java.io.BufferedReader
import java.io.Writer
import java.io.InputStreamReader
WebServlet(name = "SoManyFeeds", value = array("/*"))
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.test</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import javax.servlet.annotation.WebServlet as web
import javax.inject.Inject
import javax.enterprise.context.Dependent
web(name = "Hello", value = array("/hello"))
public class HomeController : HttpServlet() {