Skip to content

Instantly share code, notes, and snippets.

View alexandru's full-sized avatar
😺
Having fun

Alexandru Nedelcu alexandru

😺
Having fun
View GitHub Profile
@alexandru
alexandru / cache-sample-2.scala
Created September 21, 2014 12:30
Immutable cache implementation
import scala.annotation.tailrec
import scala.collection.SortedSet
import scala.concurrent.duration.{Duration, _}
import Cache._
import Cache.ExpiryInfo.ordering
/**
* An immutable cache implementation.
@alexandru
alexandru / designer.html
Created December 29, 2014 16:07
designer
<link href="../topeka-elements/category-images.html" rel="import">
<link href="../core-icon/core-icon.html" rel="import">
<link href="../core-icons/core-icons.html" rel="import">
<link href="../core-icons/av-icons.html" rel="import">
<link href="../paper-fab/paper-fab.html" rel="import">
<polymer-element name="my-element">
<template>
<style>
def recoverWith[T](source: Observable[T], pf: PartialFunction[Throwable, Observable[T]]) =
Observable.create[T] { subscriber =>
implicit val s = subscriber.scheduler
val o = subscriber.observer
source.unsafeSubscribe(new Observer[T] {
def onNext(elem: T) =
o.onNext(elem)
def onError(ex: Throwable) = {
import language.experimental.macros
import scala.reflect.macros.Context
/**
* Provides type-safe equality and inequality operators, implemented with
* macros for efficiency reasons.
*/
implicit class TypeSafeEquals[T](val self: T) extends AnyVal {
def ===[U](other: U): Boolean = macro TypeSafeEquals.equalsImpl[T, U]

The context:

First of all I must say that the Scheduler in Akka, while useful for Akka's purposes, it isn't adequate as is currently to be exposed as part of Scala's standard library. As part of a project I've been working on, I have defined a Scheduler interface that inherits from ExecutionContext (it's an enhanced execution context) that has the following methods and I believe that all of them are needed:

package different.future
import concurrent.ExecutionContext
import scala.util.Try
/**
* Just a tuple formed from a callback and an ExecutionContext.
*
* @param callback is the function called whenever we've got the value to signal
* @param context is the thread-pool under which our tasks are running
node : rabbit@piticu
app descriptor : /usr/lib/rabbitmq/lib/rabbitmq_server-1.8.0/sbin/../ebin/rabbit.app
home dir : /var/lib/rabbitmq
cookie hash : 9boeDHrGvd6fzPuNSwjoow==
log : /var/log/rabbitmq/rabbit@piticu.log
sasl log : /var/log/rabbitmq/rabbit@piticu-sasl.log
database dir : /var/lib/rabbitmq/mnesia/rabbit@piticu
erlang version : 5.7.4
BOOT ERROR: Could not add boot step dependency of rabbit_mgmt_db_handler on rabbit_event:
amqp_client-2.2.0.ez
mochiweb-2.2.0.ez
rabbitmq-management-2.2.0.ez
rabbitmq-management-agent-2.2.0.ez
rabbitmq-mochiweb-2.2.0.ez
rabbit_stomp-2.2.0.ez
webmachine-2.2.0.ez
@alexandru
alexandru / stomp_helpers.py
Created March 7, 2011 20:08
how I solved the rabbitmq connection error
#
# This is related to (reported by Scott, also happened to me):
# https://gist.github.com/12420d9060341b10e8cc
#
# Guys, syncdb / migrate should in no way be dependent on any server other than PostgreSQL.
#
# Secondly, this method requires access to a port that's not the standard RabbitMQ port.
# I have no idea what port 61613 should be doing, or how to set it up.
#
# And even though I have started RabbitMq and it is properly set, it still wouldn't work.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GrabSwag - Ooma Hub - Free VoIP</title>
<style type="text/css" media="screen">
#outer {
BORDER-BOTTOM-STYLE: solid;
BORDER-BOTTOM: 1px solid #666;