Skip to content

Instantly share code, notes, and snippets.

@davideicardi
davideicardi / PassThroughFlow.scala
Last active June 6, 2022 08:32
Akka stream generic pass through flow. For latest implementation see https://developer.lightbend.com/docs/alpakka/current/patterns.html#passthrough
/*
https://scalafiddle.io/sf/sniohcZ/3
(old version: https://scalafiddle.io/sf/sniohcZ/1)
Use PassThroughFlow when you have a message that should be used in a
flow that trasform it but you want to maintain the original message for
another following flow.
For example if you consume messages from Kafka (CommittableMessage).
You process the message (transform, save it inside a database, ...) and then you need again the original message
to commit the offset.
@jasongilman
jasongilman / atom_clojure_setup.md
Last active January 11, 2024 09:13
This describes how I setup Atom for Clojure Development.

Atom Clojure Setup

This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

Install Atom

Download Atom

The Atom documentation is excellent. It's highly worth reading the flight manual.

@Emuentes
Emuentes / two_branch_cleanup_scripts.sh
Last active October 12, 2020 19:44
SCRIPT-ONE: will print the names of the branches that have been merged into develop AND master in green. Also, branches that are only merged into develop but not master are listed in red. ---- SCRIPT-TWO: will delete the fully merged branches, those listed in green when you run SCRIPT-ONE
#######################################
# SCRIPT 1 - PREVIEW BRANCH DELETIONS #
#######################################
# will print the names of the branches that have been merged into develop and master in green and branches that are only merged into develop but not master in red.
BRANCHES_IN_MASTER=`git branch -r --merged origin/master | grep -v -E '(\*|master$|develop$)' | cut -f2- -d '/' | tr '\n' ';'` && export BRANCHES_IN_MASTER && git branch -r --merged origin/develop | grep -v -E '(\*|master$|develop$)' | cut -f2- -d '/' | xargs -L1 bash -c 'if [ $(grep -o "$0" <<< "$BRANCHES_IN_MASTER" | wc -l) -gt 0 ] ; then printf "\e[0;32m $0 \e[0m\n"; else printf "\e[0;31m $0 is merged into DEVELOP but not MASTER \e[0m\n"; fi';
#################################################################################################################################
# SCRIPT 2 - DANGER -- RUN AT YOUR OWN RISK -- The following script will DELETE the branches listed in the above preview script #
###########################
@llekn
llekn / http-stdout-echo.py
Last active January 7, 2024 23:35
HTTP server that print what is requested to console. Useful for debugging purposes.
#!/usr/bin/env python3
'''Usage:
python3 http-stdout-echo.py -a <bind-address> -p <bind-port>
Examples:
python3 http-stdout-echo.py # (will listen at 127.0.0.1:8080 by default)
python3 http-stdout-echo.py -a 10.3.1.3 -p 5555'''
from http.server import HTTPServer, BaseHTTPRequestHandler
@JadenGeller
JadenGeller / Unsafe Bit Cast.swift
Last active January 26, 2023 22:09
A Quick Overview of Unsafe Bit Cast
// Let's declare two structs that with different variables and different boolean values:
struct A {
let x = true
}
struct B {
let y = false
}
@AliSoftware
AliSoftware / struct_vs_inheritance.swift
Last active March 27, 2024 11:57
Swift, Struct & Inheritance: How to balance the will of using Struct & Value Types and the need for Inheritance?
// #!Swift-1.1
import Foundation
// MARK: - (1) classes
// Solution 1:
// - Use classes instead of struct
// Issue: Violate the concept of moving model to the value layer
// http://realm.io/news/andy-matuschak-controlling-complexity/
@imminent
imminent / CursorSubject.java
Last active August 11, 2016 17:21
CursorSubject is a Reactive Extension version of Android's CursorLoader. Handles retrieving the Cursor in a background thread, sending the result Cursor on the main thread, and resending a Cursor whenever the content changed notification is triggered.
package com.example.models;
import android.database.ContentObserver;
import android.database.Cursor;
import android.os.Handler;
import android.os.Looper;
import java.io.Closeable;
import java.util.concurrent.atomic.AtomicReference;
@Willyfrog
Willyfrog / virtualenv-auto-activate.sh
Created August 1, 2012 12:57 — forked from codysoyland/virtualenv-auto-activate.sh
virtualenv-auto-activate-auto-deactivate
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.