Skip to content

Instantly share code, notes, and snippets.

View codejitsu's full-sized avatar

Alex codejitsu

View GitHub Profile
@asmaier
asmaier / KafkaProducerIT.java
Last active March 23, 2022 11:16
Simple java junit test of an apache kafka producer (works with Kafka 0.11.0.2) (see also https://github.com/asmaier/mini-kafka)
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Properties;
import org.I0Itec.zkclient.ZkClient;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
@madan712
madan712 / IPRangeChecker.java
Created September 21, 2013 16:21
Java program to check IP address range. This is a simple java program to check IP address range. Here we provide a IP address to check whether it lies between start and end IP address.
import java.net.InetAddress;
import java.net.UnknownHostException;
public class IPRangeChecker {
public static long ipToLong(InetAddress ip) {
byte[] octets = ip.getAddress();
long result = 0;
for (byte octet : octets) {
result <<= 8;
@danriti
danriti / hipchat-v2.sh
Last active July 19, 2021 10:49
HipChat API v2 - Send a message to a room using cURL
#!/bin/bash
# Set the ROOM_ID & AUTH_TOKEN variables below.
# Further instructions at https://www.hipchat.com/docs/apiv2/auth
ROOM_ID=XXX
AUTH_TOKEN=XXX
MESSAGE="Hello world!"
curl -H "Content-Type: application/json" \
@mlconnor
mlconnor / aws_iam_permissions.csv
Last active November 11, 2022 21:38
CSV file containing all AWS service names and permissions
Service Permission
Auto Scaling CreateAutoScalingGroup
Auto Scaling CreateLaunchConfiguration
Auto Scaling CreateOrUpdateScalingTrigger
Auto Scaling CreateOrUpdateTags
Auto Scaling DeleteAutoScalingGroup
Auto Scaling DeleteLaunchConfiguration
Auto Scaling DeleteNotificationConfiguration
Auto Scaling DeletePolicy
Auto Scaling DeleteScheduledAction
@irazasyed
irazasyed / homebrew-permissions-issue.md
Last active May 23, 2024 02:59
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*

@debasishg
debasishg / gist:8172796
Last active May 10, 2024 13:37
A collection of links for streaming algorithms and data structures

General Background and Overview

  1. Probabilistic Data Structures for Web Analytics and Data Mining : A great overview of the space of probabilistic data structures and how they are used in approximation algorithm implementation.
  2. Models and Issues in Data Stream Systems
  3. Philippe Flajolet’s contribution to streaming algorithms : A presentation by Jérémie Lumbroso that visits some of the hostorical perspectives and how it all began with Flajolet
  4. Approximate Frequency Counts over Data Streams by Gurmeet Singh Manku & Rajeev Motwani : One of the early papers on the subject.
  5. [Methods for Finding Frequent Items in Data Streams](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.187.9800&amp;rep=rep1&amp;t
@jcabrra
jcabrra / VideoInfo.scala
Created January 6, 2014 19:57
Grab information from either a Youtube or Vimeo online video. I would change enum so more information could be extracted with a single http reponse. Example: import VideoService._, dispatch._ val time = Youtube.video.duration(id)()
import dispatch._
import xml._
import concurrent.Future
import concurrent.ExecutionContext.Implicits.global
/**
* Video information of certain video service providers.
* Supports Youtube, Vimeo.
* Can only get video duration, but easily extensible.
@ekampf
ekampf / setup_kafka.sh
Last active November 29, 2017 17:41
Setup Kafka (0.8.0) on OSX
brew install sbt
cd /tmp
wget http://apache.spd.co.il/kafka/0.8.0/kafka_2.8.0-0.8.0.tar.gz
tar -zxvf kafka_2.8.0-0.8.0.tar.gz -C /usr/local/
cd /usr/local/kafka_2.8.0-0.8.0
sbt update
sbt package
@non
non / ints.scala
Last active March 24, 2019 14:25
Type-level integers. Like shapeless' Nat, but supports negative numbers. Oh, and I've never actually run the code (but it compiles).
package quantity
// like Nat, but for integers
trait Z
// Pos means positive-or-zero, and Neg means negative-or-zero
trait Pos extends Z { type P <: Pos }
trait Neg extends Z { type N <: Neg }
class Zero extends Pos with Neg { type N = Zero }
@viktorklang
viktorklang / Future-retry.scala
Last active July 23, 2023 23:48
Asynchronous retry for Future in Scala
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import akka.pattern.after
import akka.actor.Scheduler
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.