Skip to content

Instantly share code, notes, and snippets.

View hamsterready's full-sized avatar

Maciej Lopacinski hamsterready

  • Quaternion.pl
  • Poznan, Poland
View GitHub Profile
@keithresar
keithresar / docker-compose.yaml
Last active December 4, 2023 13:18
Confluent Cloud Connect Cluster Container Config
---
version: '2'
services:
connect:
image: confluentinc/cp-server-connect:5.4.1
hostname: connect
container_name: connect
ports:
- 8083:8083
@channingwalton
channingwalton / NonEmptySet.scala
Last active March 24, 2018 16:48
NonEmptySet Implementation
import cats.data.NonEmptyList
import cats.Eq
import scala.collection.GenTraversableOnce
sealed trait NonEmptySet[T] extends (T => Boolean) {
def head: T
def set: Set[T]
def +(t: T): NonEmptySet[T]
def ++(ts: NonEmptySet[T]): NonEmptySet[T]
@MaximilianoFelice
MaximilianoFelice / builder-phantom-types.scala
Last active July 26, 2023 22:49
A Builder example in Scala using Phantom Types
case class Food(ingredients: Seq[String])
class Chef[Pizza <: Chef.Pizza] protected (ingredients: Seq[String]) {
import Chef.Pizza._
def addCheese(cheeseType: String): Chef[Pizza with Cheese] = Chef(ingredients :+ cheeseType)
def addTopping(toppingType: String): Chef[Pizza with Topping] = Chef(ingredients :+ toppingType)
def addDough: Chef[Pizza with Dough] = Chef(ingredients :+ "dough")
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@agemooij
agemooij / SnakifiedSprayJsonSupport.scala
Last active November 18, 2020 14:34
An example of how to customize the field mapping in spray-json to do generic transformation, in this case translating between camelcased Scala attributes and snakecase JSON attributes
/**
* The MIT License (MIT)
*
* Copyright (c) 2013-2015 Andrew Snare, Age Mooij
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@dashed
dashed / github-pandoc.css
Created September 26, 2013 13:42
GitHub-like CSS for pandoc standalone HTML files (perfect for HTML5 output). Based on Marked.app's GitHub CSS. Added normalize.css (v2.1.3) in the prior to GitHub css.
/*! normalize.css v2.1.3 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined in IE 8/9.
*/
@coder4web
coder4web / redis_install_centos.txt
Last active September 10, 2017 01:45
Redis install on CentOS 6.4
BTW yum has last Redis too, remi repository at least.
$ sudo -i
$ yum list redis
$ redis.x86_64 2.6.13-1.el6.remi remi
But today we want compile redis from source (see http://redis.io/download)
$ yum install make gcc tcl
$ cd /usr/local/src
@iconara
iconara / start_cluster.sh
Last active December 12, 2015 10:39
Script that starts a local RabbitMQ cluster, tested with 2.7, 2.8 and 3.0
#!/bin/bash
# Usage: clusterctl start|stop
#
# Launches a local RabbitMQ cluster
#
# The name returned by `hostname -s` must resolve to 127.0.0.1
CLUSTER_SIZE=4
NODENAME_PREFIX='rmq'
@viktorklang
viktorklang / minscalaactors.scala
Last active March 25, 2024 19:01
Minimalist Scala Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@jtai
jtai / parse-tcpdump-udp-port-53.php
Last active January 16, 2019 16:06
Quick and dirty script to parse output of /usr/sbin/tcpdump -vvv -s 0 -l port 53
<?php
// quick and dirty argument parsing
foreach ($argv as $arg) {
if ($arg == '-f') {
define('FOLLOW', true);
}
if ($arg == '-h') {
define('HISTOGRAM', true);
}