Skip to content

Instantly share code, notes, and snippets.

View devshawn's full-sized avatar
💻
Kafka! 😄

Shawn Seymour devshawn

💻
Kafka! 😄
View GitHub Profile
@elandau
elandau / StateMachine
Created October 30, 2014 23:22
Rx based state machine
package com.netflix.experiments.rx;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rx.Observable;
import rx.Observable.OnSubscribe;
@seriousme
seriousme / loki-test.js
Created March 12, 2015 18:59
loki crypted file adapter
var cryptedFileAdapter = require('./lokiCryptedFileAdapter');
cryptedFileAdapter.setSecret('mySecret');
var loki=require('lokijs');
var db = new loki('loki.json.crypted',{ adapter: cryptedFileAdapter });
db.loadDatabase({},function(){
var children = db.addCollection('children');
children.insert({name:'Bleep', legs: 2});
db.save();
@ThomasChiroux
ThomasChiroux / httpserve.py
Created September 26, 2012 09:11
python2 and python3 compliant simple http server
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""launch small http server
"""
import sys
try:
from SimpleHTTPServer import SimpleHTTPRequestHandler
except ImportError:
@Jire
Jire / BadWords.java
Last active December 12, 2023 23:18
Based off PimDeWitte's, this improves performance by over a magnitude and eliminates all garbage (allocations).
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.openhft.hashing.LongHashFunction;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
/**
@PimDeWitte
PimDeWitte / Efficient Bad Word Filter
Last active February 11, 2024 14:57
Simple profanity filter written in Java for efficient comparison. Runtime grows based on string input, not list size.
static Map<String, String[]> words = new HashMap<>();
static int largestWordLength = 0;
public static void loadConfigs() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new URL("https://docs.google.com/spreadsheets/d/1hIEi2YG3ydav1E06Bzf2mQbGZ12kh2fe4ISgLg_UBuM/export?format=csv").openConnection().getInputStream()));
String line = "";
int counter = 0;
while((line = reader.readLine()) != null) {
@sloria
sloria / bobp-python.md
Last active April 20, 2024 13:02
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@staltz
staltz / introrx.md
Last active April 20, 2024 14:15
The introduction to Reactive Programming you've been missing