Skip to content

Instantly share code, notes, and snippets.

@khajavi
khajavi / kryo.scala
Last active June 18, 2016 10:06
Apache Spark Kryo Encoder
class Bar(i: Int) {
override def toString = s"bar $i"
def bar = i
}
object BarEncoders {
implicit def barEncoder: org.apache.spark.sql.Encoder[Bar] = org.apache.spark.sql.Encoders.kryo[Bar]
}
abstract class Foo
@khajavi
khajavi / FileServer.java
Last active June 22, 2021 18:15
Create File Server With Jetty
//
// ========================================================================
// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
////Source code from: http://cglab.ca/~abeinges/blah/too-many-lists/book/first-final.html
use std::mem;
pub struct List {
head: Link,
}
enum Link {
Empty,
@khajavi
khajavi / SpyMockitoTest.scala
Created April 16, 2016 12:41
Test spy mockito
class DataRepo {
def getData = 5
}
class MockWithInjectionTest extends FunSuite {
@Spy var repo: DataRepo = _
test("spy") {
MockitoAnnotations.initMocks(this)
Mockito.when(repo.getData).thenReturn(8)
@khajavi
khajavi / MockWithInjectionTest.scala
Created April 16, 2016 08:21
Mock dependency in CDI context with mockito
import javax.inject.Inject
import org.mockito.{MockitoAnnotations, InjectMocks, Mock, Mockito}
import org.scalatest.FunSuite
class MockWithInjectionTest extends FunSuite {
@Mock var dataRepoMock: DataRepo = _
@InjectMocks var calc: Calculate = _
test("Mockito Injection") {
@khajavi
khajavi / index.html
Created April 15, 2016 13:17
center div vertically in another div
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<style>
#base {

./bin/standalone.sh -c standalone.xml

@khajavi
khajavi / README.md
Last active March 30, 2016 22:48
Glassfish Embedded Deploy
mvn package embedded-glassfish:run
@khajavi
khajavi / build.sbt
Created March 24, 2016 06:00
استفاده از میون لوکال در sbt
resolvers += Resolver.mavenLocal
@khajavi
khajavi / tee
Created March 21, 2016 16:19
redirect sdtout to file and print it
ls -lR / | tee output.file