Skip to content

Instantly share code, notes, and snippets.

@eliaslevy
eliaslevy / gist:fad450e91d7d5e769f52
Created May 14, 2015 17:06
Test of RethinkDB Ruby Driver Connection Thread-Safety
#!/opt/jruby-1.7.20/bin/jruby -J-Xmx10000m
require 'benchmark'
require 'jruby/synchronized'
require 'rethinkdb'
include RethinkDB::Shortcuts
module RethinkDB
class Connection
alias_method :old_send, :send
#!/usr/bin/env ruby
require 'amqp'
amqp_connection_config = {
:host => "localhost",
:port => 5672,
:user => "guest",
:pass => "guest",
:vhost => "/",
#!/usr/bin/env ruby
require 'amqp'
require 'logger'
amqp_connection_config = {
:host => "localhost",
:port => 5672,
:user => "guest",
:pass => "guest",
@eliaslevy
eliaslevy / EventTimeTriggerWithEarlyAndLateFiring.java
Created June 6, 2016 23:41
Modified EventTimeTriggerWithEarlyAndLateFiring with firing suppression if there aren't any new events between timers
package com.dataartisans.beam_comparison.customTriggers;
package com.cisco.sbg.amp;
import org.apache.flink.api.common.state.ValueState;
import org.apache.flink.api.common.state.ValueStateDescriptor;
import org.apache.flink.api.common.typeutils.base.BooleanSerializer;
import org.apache.flink.api.common.typeutils.base.LongSerializer;
import org.apache.flink.hadoop.shaded.com.google.common.base.Preconditions;
import org.apache.flink.streaming.api.windowing.time.Time;
@eliaslevy
eliaslevy / SpecificAvroSerde.scala
Created October 5, 2016 21:43
Avro SpecificRecord Serde for Kafka
package example.kstreams
import org.apache.kafka.common.serialization.Serde
import org.apache.kafka.common.serialization.Serializer
import org.apache.kafka.common.serialization.Deserializer
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import org.apache.avro.io.EncoderFactory
@eliaslevy
eliaslevy / gist:3042381
Created July 3, 2012 19:43
High level AMQP blocking publish method
# Helper method that publishes a message to an exchange and waits for a
# broker acknowledgement using RabbitMQ's publisher confirmation extension.
#
# Confirm mode must already be enabled in the channel. You can turn
# confirm mode on using channel.confirm_select. You must only do this
# once.
#
# It also raises an error if you use the mandatory and/or immediate
# options, and these constrains cannot be meet by the broker.
#
@eliaslevy
eliaslevy / Scan.py
Created June 13, 2017 23:34 — forked from enjoylife/Scan.py
Python implementation of SCAN: A Structural Clustering Algorithm for Networks
# -*- coding: utf-8 -*-
"""
SCAN: A Structural Clustering Algorithm for Networks
As described in http://ualr.edu/nxyuruk/publications/kdd07.pdf
"""
from collections import deque
import numpy as np
from scipy.sparse import csr_matrix
@eliaslevy
eliaslevy / EarlyFiringEventTimeTrigger
Created August 31, 2017 00:42
EarlyFiringEventTimeTrigger
import org.apache.flink.api.common.state.ValueState
import org.apache.flink.api.common.state.ValueStateDescriptor
import org.apache.flink.api.common.typeinfo.TypeHint
import org.apache.flink.streaming.api.windowing.triggers.Trigger
import org.apache.flink.streaming.api.windowing.triggers.Trigger.TriggerContext
import org.apache.flink.streaming.api.windowing.triggers.TriggerResult
import org.apache.flink.streaming.api.windowing.triggers.TriggerResult.{CONTINUE, FIRE, FIRE_AND_PURGE, PURGE}
import org.apache.flink.streaming.api.windowing.time.Time
import org.apache.flink.streaming.api.windowing.windows.TimeWindow
@eliaslevy
eliaslevy / openvpn.template
Created November 7, 2015 04:25
OpenVPN CloudFormation template to attach a VPN AS to an existing VPC with an Internet Gateway
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "OpenVPN Access Server",
"Mappings": {
"RegionMap": {
"us-east-1" : { "AMI" : "ami-5fe36434" },
"us-west-1" : { "AMI" : "ami-8bf40fcf" },
"us-west-2" : { "AMI" : "ami-9fe2f2af" },
"eu-west-1" : { "AMI" : "ami-03644074" },
"eu-central-1" : { "AMI" : "ami-507f7e4d" },
{
"nodes":[
{"name": "Pass 2: Amy Farah Weiss" },
{"name": "Pass 2: Angela Alioto" },
{"name": "Pass 2: Ellen Lee Zhou" },
{"name": "Pass 2: Jane Kim" },
{"name": "Pass 2: London Breed" },
{"name": "Pass 2: Mark Leno" },
{"name": "Pass 2: Michelle Bravo" },
{"name": "Pass 2: Richie Greenberg" },