Skip to content

Instantly share code, notes, and snippets.

View codejitsu's full-sized avatar

Alex codejitsu

View GitHub Profile
@ursuad
ursuad / kafka-cheat-sheet.md
Last active March 14, 2024 10:32
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@danikin
danikin / tar_test.c
Last active December 18, 2020 07:28
Tarantool Quick Test
// Tarantool quick test
// Copyright, Dennis Anikin 2016
//
// Quick disclaimer:
//
// This test shows 500K-1000K transactions per second on one CPU core
// and 600K-1600K queries per second on one CPU core.
//
// Based on the $6.57 per-month-price for the AWS t2.micro instance we can afford the tremendous number of 630bln queries for just $1
//
@bigsnarfdude
bigsnarfdude / gist:07a28061b0faf48b6b73
Last active September 6, 2017 11:14
algebird hll serialized via redis repl
import com.twitter.algebird.HyperLogLog
import com.twitter.algebird.HyperLogLogMonoid
import com.twitter.algebird.HLL
import org.apache.commons.codec.binary.Base64
import com.twitter.chill.algebird.AlgebirdRegistrar
import com.twitter.chill.{KryoPool, ScalaKryoInstantiator}
// base 64 encoded string
// val data = List(1, 1, 2, 2, 3, 3, 4, 4, 5, 5)
@stefanobaghino
stefanobaghino / KafkaFeed.scala
Last active April 11, 2023 07:57
Pipe a Kafka consumer to a WebSocket on Play! Framework.
package controllers
import java.util.Properties
import com.typesafe.config.ConfigFactory
import kafka.consumer.{Consumer, ConsumerConfig, ConsumerConnector, Whitelist}
import kafka.serializer.StringDecoder
import play.api.libs.iteratee.{Enumerator, Iteratee}
import play.api.mvc.{Controller, WebSocket}
@unnikked
unnikked / QuickSelect.java
Created July 4, 2015 15:40
A basic implementation of quickselect algorithm in Java. Intentionally unused generics.
import java.util.Arrays;
/**
* quickselect is a selection algorithm to find the kth smallest element in an
* unordered list. Like quicksort, it is efficient in practice and has good
* average-case performance, but has poor worst-case performance. Quickselect
* and variants is the selection algorithm most often used in efficient
* real-world implementations.
*
* Quickselect uses the same overall approach as quicksort, choosing one
@nylki
nylki / char-rnn recipes.md
Last active March 16, 2024 15:13
char-rnn cooking recipes

do androids dream of cooking?

The following recipes are sampled from a trained neural net. You can find the repo to train your own neural net here: https://github.com/karpathy/char-rnn Thanks to Andrej Karpathy for the great code! It's really easy to setup.

The recipes I used for training the char-rnn are from a recipe collection called ffts.com And here is the actual zipped data (uncompressed ~35 MB) I used for training. The ZIP is also archived @ archive.org in case the original links becomes invalid in the future.

@milessabin
milessabin / gist:b16e0765e1acdc90fd29
Last active August 16, 2016 16:25
Functional update of common fields of an open family of case classes via a case-class-like copy through the common super type ...
import shapeless._
/**
* Functional update of common fields of an *open* family of case classes
* via a case-class-like copy through the common super type ...
*
* This is a follow up to my earlier post showin how to do functional
* update for a sealed family of case classes,
*
* https://gist.github.com/milessabin/a212d946aef33811fee1
@markrendle
markrendle / explanation.md
Last active July 3, 2022 07:56
Why I was previously not a fan of Apache Kafka

Update, September 2016

OK, you can pretty much ignore what I wrote below this update, because it doesn't really apply anymore.

I wrote this over a year ago, and at the time I had spent a couple of weeks trying to get Kafka 0.8 working with .NET and then Node.js with much frustration and very little success. I was rather angry. It keeps getting linked, though, and just popped up on Hacker News, so here's sort of an update, although I haven't used Kafka at all this year so I don't really have any new information.

In the end, we managed to get things working with a Node.js client, although we continued to have problems, both with our code and with managing a Kafka/Zookeeper cluster generally. What made it worse was that I did not then, and do not now, believe that Kafka was the correct solution for that particular problem at that particular company. What they were trying to achieve could have been done more simply with any number of other messaging systems, with a subscriber reading messages off and writing