Skip to content

Instantly share code, notes, and snippets.

@keathley
keathley / .credo.exs
Last active December 30, 2023 16:13
Keathley's credo file
# This file contains the configuration for Credo and you are probably reading
# this after creating it with `mix credo.gen.config`.
#
# If you find anything wrong or unclear in this file, please report an
# issue on GitHub: https://github.com/rrrene/credo/issues
#
%{
#
# You can have as many configs as you like in the `configs:` field.
configs: [
@jerry73204
jerry73204 / actix-kafka-example.rs
Created July 27, 2019 11:55
rdkafka integration with actix example
use actix::prelude::*;
use failure::Fallible;
use rdkafka::{
consumer::stream_consumer::StreamConsumer,
message::OwnedMessage,
Message,
};
pub struct MsgConsumer {
consumer: &'static StreamConsumer,
use std::collections::HashMap;
use std::fmt;
use std::io;
use std::num::ParseFloatError;
use std::rc::Rc;
/*
Types
*/

Build or install nghttp2 (optionally with support for the --interval DURATION flag).

Either:

brew install nghttp2

Or:

// Suppose you have a variable named `future` which implements the `Future` trait.
let future: impl Future = ...;
// This gist demonstrates how to run the future until completion using the `stdweb` crate.
// The various imports.
extern crate futures;
extern crate stdweb;
@marwei
marwei / how_to_reset_kafka_consumer_group_offset.md
Created November 9, 2017 23:39
How to Reset Kafka Consumer Group Offset

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
@avocade
avocade / erl-observe.sh
Created February 22, 2017 12:34
Connect to remote erlang node with remote iex session (eg over k8s port-forwarding), and start observer on it
#!/bin/bash
# This script provides easy way to debug remote Erlang nodes that is running in a kubernetes cluster.
# Usage: ./erl-observe.sh -l app=my_all -n default -c erlang_cookie
#
# Don't forget to include `:runtime_tools` in your mix.exs application dependencies.
set -e
# Trap exit so we can try to kill proxies that has stuck in background
function cleanup {
echo " - Stopping kubectl proxy."
// OK so to start with here's the EventHandler trait, just like slack-rs
pub trait EventHandler {
// I don't know what kind of thing EventData should be.
// maybe Json? whatever events actually are in phoenix.
fn on_event(&mut self, channel_name: &str, event_type: &str, event_data: EventData);
fn on_connect(&mut self, ...);
fn on_close(&mut self, ...);
}
fn login_and_run<H: EventHandler>(handler: H, ...) {...}
@bitwalker
bitwalker / config.ex
Created July 19, 2016 23:00
Useful config wrapper for Elixir
defmodule Config do
@moduledoc """
This module handles fetching values from the config with some additional niceties
"""
@doc """
Fetches a value from the config, or from the environment if {:system, "VAR"}
is provided.
An optional default value can be provided if desired.