Skip to content

Instantly share code, notes, and snippets.

View videlalvaro's full-sized avatar

Alvaro Videla videlalvaro

View GitHub Profile
@videlalvaro
videlalvaro / fold_example.erl
Created April 27, 2015 14:24
blog post example
%% compile and run fold_example:test().
%% Records used here were taken from RabbitMQ's source code.
-module(fold_example).
-compile(export_all).
-record('P_basic',
{content_type,
content_encoding,
headers,
func RuneCount(buffer []byte) int {
index, count := 0, 0
for index < len(buffer) {
if buffer[index] < RuneSelf {
index++
} else {
_, size := DecodeRune(buffer[index:])
index += size
}
count++
@videlalvaro
videlalvaro / single_letter.go
Last active September 25, 2018 22:52
single_letter.go
func RuneCount(b []byte) int {
i, n := 0, 0
for i < len(b) {
if b[i] < RuneSelf {
i++
} else {
_, size := DecodeRune(b[i:])
i += size
}
n++
package com.example.store.user;
/**
* Implements a user for our store.
*/
public class User {
private String name;
public User(String name) {
this.name = name;
}
#!/bin/bash
CAT="/bin/cat"
HOSTNAME=$(/bin/hostname)
RABBITMQ_HOME="/var/lib/rabbitmq"
RABBITMQ_COOKIE_PATH="$RABBITMQ_HOME/.erlang.cookie"
RABBITMQ_COOKIE=$($CAT $RABBITMQ_COOKIE_PATH) || exit 1
ERLANG_ROOT="/usr/local/erlang"
ERL_CALL="$ERLANG_ROOT/lib/erlang/lib/erl_interface-3.6.5/bin/erl_call"
PROCS=$($ERL_CALL -c $RABBITMQ_COOKIE -sname rabbit@$HOSTNAME -a 'erlang system_info [process_count]')
echo "procs.$HOSTNAME $PROCS"
@videlalvaro
videlalvaro / shift_and.js
Last active January 1, 2016 06:29
This is a vanilla shift_and implementation in JS. Lacking the context it's hard to see what's going on. The interesting part of the algorithm is the bit parallelism techniques it uses to match prefixes. The implementation is based on this book: http://www.amazon.com/Flexible-Pattern-Matching-Strings-Algorithms/dp/0521039932/ Blog post explaining…
/**
* string p: pattern to search (needle);
* string text: haystack
**/
function shift_and(p, text) {
var b = {};
var l = p.length;
var tl = text.length;
// initialize bitmask table
@videlalvaro
videlalvaro / gist:7454226
Created November 13, 2013 18:48
List of algorithms books I've been reading lately
http://www.amazon.com/Flexible-Pattern-Matching-Strings--Line/dp/0521039932/
http://www.amazon.com/Algorithms-Strings-Trees-Sequences-Computational/dp/0521585198/
http://www.amazon.com/Algorithms-Strings-Maxime-Crochemore/dp/0521848997/
http://www.amazon.com/Algorithm-Design-Jon-Kleinberg/dp/0321295358/
include ../umbrella.mk
MAIN_NODE=undefined
OTHER_NODE=undefined
OTHER_PORT=undefined
OTHER_PLUGINS=undefined
BASEDIR=${TMPDIR}/rabbitmq-topic-tests/$(OTHER_NODE)
PID_FILE=$(BASEDIR)/$(OTHER_NODE).pid
start-other-node:
if I run readelf -d /usr/local/lib/erlang/lib/crypto-3.0/priv/lib/crypto.so it depends on this exactly
(NEEDED) Shared library: [libcrypto.so.1.0.0]
is there a way to change that so it will accept libcrypto.so.1.0.1 for example?
NOTE: I tried symlinking libs and that didn't work.
@videlalvaro
videlalvaro / phpunit.xml
Created April 29, 2013 16:52
Sample XML configuration for a PHPUnit RabbitMQ listener
<listeners>
<listener class="RabbitMQListener" file="PhpAmqpLib/Tests/RabbitMQListener.php">
<arguments>
<string>/tmp/rabbitmq-server-mac-standalone-3.0.4.40426.tar.gz</string>
</arguments>
</listener>
</listeners>