Skip to content

Instantly share code, notes, and snippets.

Tamer Abdulradi tabdulradi

Block or report user

Report or block tabdulradi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tabdulradi / Usage.scala
Last active Apr 19, 2018
Function that allows values to be discarded in a visible way. Combined with Scalac flags: `-Ywarn-value-discard` (and maybe `-Xfatal-warnings`).
View Usage.scala
scala> ValueDiscard[Int](5)
scala> ValueDiscard(5)
<console>:12: error: ValueDiscard.type does not take parameters

Keybase proof

I hereby claim:

  • I am tabdulradi on github.
  • I am tabdulradi ( on keybase.
  • I have a public key ASBkIdYjb4IRe7DXOtrp_1ZSev9WYKBiZ8R-iSWKWa8kAAo

To claim this, I am signing this object:

tabdulradi / range-long-bug.scala
Last active Nov 19, 2016
Scala Range.Long min/max bug
View range-long-bug.scala
scala> Range.Long.inclusive(111, 999, 1).max
res27: Long = 999
scala> Range.Long.inclusive(111, 999, -1).max
res28: Long = 111
scala> Range.Long.inclusive(111, 999, 1).min
res29: Long = 111
scala> Range.Long.inclusive(111, 999, -1).min

Introducing Troy: The schema-safe Cassandra toolkit.

Troy is an open source macro-based Cassandra driver, similar to Slick and Quill, provides type-safe & compile-time checking for database queries. Nevertheless, it doesn't impose a DSL to express the queries in Scala. Instead, it allows developers to write plain Cassandra-query-language (CQL) queries within Scala code, complete with schema validation. In addition, it provides cross-validation against the previous versions, ensuring safe and smooth schema migrations.

It is worth noting that Troy doesn't connect to Cassandra during compilation. Instead, the schema is provided as CQL scripts, checked-in within same code base, consisting of plain CREATE TABLE CQL statements. That get's loaded at compile-time into a light-weight Schema engine capable of analysing queries and providing information about column types. Those CQL scripts can be written as increments, by adding new scripts containing `ALTER TA

tabdulradi / CompositeRouter.scala
Last active Mar 5, 2018
Utility Play routes that makes it prettier to combine routes together
View CompositeRouter.scala
class CompositeRouter(routers: Seq[Router]) extends SimpleRouter {
override def documentation: Seq[(String, String, String)] =
override def routes: Router.Routes = orElse _)
object CompositeRouter {
def fromPrefixedRoutes(routers: (String, Router.Routes)*): CompositeRouter =
tabdulradi / ComposingRoutes.scala
Last active May 23, 2016
Cake Blog: All you need to know about Play SIRD
View ComposingRoutes.scala
val service1 = Router.from {
case GET(p"hello/$to") => ???
val service2 = Router.from {
case GET(p"echo/$msg") => ???
View gist:c11e710e972ec0795818
public final class ImmutableDummy {
public final Integer x;
public final Option<Integer> y;
public ImmutableDummy(@JsonProperty("x") Integer x,
@JsonProperty("y") Integer y) {
this.x = x;
this.y = Option.apply(y);
tabdulradi / rational.js
Last active Aug 29, 2015
SICP using JS > rational
View rational.js
function pair(a, b) {
return function(i) {
if (i === 0) return a
else return b
function head(p) {
return p(0)
function tail(p) {
View GeneratorActor.scala
class FibonacciGenerator extends Actor {
import FibonacciGenerator._
def receive = fib()
def fib(a: Long = 0, b: Long = 1): Receive = {
case Next =>
val c: Long = a + b
tabdulradi /
Last active Dec 21, 2015
Python Using a dict instead of Switch statements
def switch(cases, case, default_case, *args, **kwargs):
return cases.get(case, default_case)(*args, **kwargs)
def power(x):
return x ** 2
def add(x, y):
return x + y
def illegal_operator(*args, **kwargs):
You can’t perform that action at this time.