Skip to content

Instantly share code, notes, and snippets.

@sameei
sameei / QTask.java
Last active November 17, 2016 05:06
A simple queue ended in a function/applicaiton.
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author Reza Samei <[email protected]>
*/
public abstract class QTask<T> extends Thread {
@sameei
sameei / dirtysimplemodel.scala
Last active August 15, 2016 10:16
Simple Domain Model / Functional + Type Class
// Domain / Rules ======================================================
trait Balance[T] {
def merge(other: T): T
}
trait AccountBalance[T, B] {
def balance(): B
def newBalance (balance: B): T

Keybase proof

I hereby claim:

  • I am reza-samei on github.
  • I am samei (https://keybase.io/samei) on keybase.
  • I have a public key whose fingerprint is B344 63B4 9B0C 490C 0D08 0ABA BA94 ABE7 2235 A65D

To claim this, I am signing this object:

// in the name of ALLAH
case class PopulationStat(
val country: String,
val symbol: String,
val year: Int,
val amount: Long
)
class WritablePopulationStat extends WritableComparable[WritablePopulationStat] {
case class InvalidDataException[T](
val message:String,
val value:T,
val cause:Option[Throwable] = None )
extends Exception ( message, cause getOrElse null )
@sameei
sameei / .hgignore
Created February 12, 2015 07:19
hgignore
syntax: glob
*.kate-swp
*.swp
bin
target
.project
.settings
.cache
.classpath
logs/application.log
@sameei
sameei / .hgrc
Last active August 29, 2015 14:15
hgrc
[ui]
username = My Name <my.email@somedomain>
verbose = false
ignore = ~/.hgignore
[extensions]
color =
graphlog =
[alias]
@sameei
sameei / YetAnotherSimpleHttpServer.py
Created November 5, 2014 17:55
My needed improvment for python's SimpleHTTPServer module.
#!/usr/bin/python2.7
import sys
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
class MyHTTPRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_my_headers()
@sameei
sameei / gitconfig
Last active August 29, 2015 14:04
~/.gitconfig
[user]
name = {{ forename surname }}
email = {{ email }}
[core]
editor = vim
# excludesfile = default -> $XDG_CONFIG_HOME/git/ignore or $HOME/.config/git/ignore
# # ignores
# # # .idea/
# # # .project
; in the name of ALLAH
; at /etc/systemd/system/stunnel.service
; or at /usr/lib/systemd/system/stunnel.service
; or at /usr/lib/systemd/system/tunnelproxy.service
; change "{{ config.conf }}" by your config path.
[Unit]
Description=SSL tunnel for network daemons
After=syslog.target