Skip to content

Instantly share code, notes, and snippets.

Avatar

Hadi Hariri hhariri

View GitHub Profile
View annotations.kt
@Magic
@SomeMoreMagic
@EvenMoreMagic
@AwesomeSauce
class Simple
View forloops.kt
val x = 100
val y = 1
for (i in 0..x step y) {
}
val r = 1..100
for (z in r) {
println(z)
}
View Dockerfile
# 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 Apr 15, 2016
I was unfollowed on Twitter and here's what happened
View dc.kt
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)
View rxjava.kt
// Without it
ObservableHttp.createRequest(HttpAsyncMethods.createGet(url), client)
.toObservable()
.flatMap({ response -> response.getContent().map {
byte ->
String(byte)
}
})
.toBlocking()
.forEach {
View rxjava.kt
return ObservableHttp.createRequest(HttpAsyncMethods.createGet(url), client)
.toObservable()
.flatMap({ response -> response.getContent().map {
byte ->
String(byte)
}
})
.toBlocking()
.forEach {
data -> println(data)
View servlet.kt
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("/*"))
View pom.xml
<?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>
View javaee2.kt
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() {