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 / 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.
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
<!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;
a, b = 0, 1
while still_has_lock():
time.sleep(a + b)
a, b = b, a+b
# Fibonacci WTF !
@alexandru
alexandru / gist:2044035
Created March 15, 2012 12:49 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p125
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1333785)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p125 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
@alexandru
alexandru / latency.txt
Created May 31, 2012 14:32 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@alexandru
alexandru / gist:5160312
Created March 14, 2013 10:30
Play 2.1 / Scala - NullPointerException
java.lang.NullPointerException
at play.core.server.netty.RequestBodyHandler$$anonfun$1.apply(RequestBodyHandler.scala:45)
at play.core.server.netty.RequestBodyHandler$$anonfun$1.apply(RequestBodyHandler.scala:43)
at scala.concurrent.stm.ccstm.InTxnImpl.runBlock(InTxnImpl.scala:538)
at scala.concurrent.stm.ccstm.InTxnImpl.topLevelAttempt(InTxnImpl.scala:494)
at scala.concurrent.stm.ccstm.InTxnImpl.topLevelAtomicImpl(InTxnImpl.scala:365)
at scala.concurrent.stm.ccstm.InTxnImpl.atomic(InTxnImpl.scala:244)
at scala.concurrent.stm.ccstm.CCSTMExecutor.apply(CCSTMExecutor.scala:24)
at play.core.server.netty.RequestBodyHandler$class.pushChunk$1(RequestBodyHandler.scala:43)
at play.core.server.netty.RequestBodyHandler$$anon$1.messageReceived(RequestBodyHandler.scala:89)
@alexandru
alexandru / ExecutorServiceWrapper.scala
Last active March 17, 2021 23:52
Wrapping a scala.concurrent.ExecutionContext into java.concurrent.ExecutorService
import concurrent.{Future, Await, Promise, ExecutionContext}
import java.util.concurrent.{Future => JavaFuture, TimeUnit, Callable, CancellationException, ExecutorService}
import concurrent.duration._
import scala.util.Success
import scala.util.Failure
import scala.util.control.NonFatal
import scala.collection.JavaConverters._
import concurrent.duration.TimeUnit
import java.{util => jutil}
@alexandru
alexandru / CorsSupport.scala
Created May 9, 2013 06:06
For serving CORS headers in responses.
import play.api.mvc._
trait CorsSupport { self: Controller =>
def CorsAction(cb: => Result): Action[AnyContent] =
Action(cb.withHeaders(actionCorsHeaders: _*))
def CorsAction(cb: Request[AnyContent] => Result): Action[AnyContent] =
Action { request =>
cb(request).withHeaders(actionCorsHeaders: _*)