Skip to content

Instantly share code, notes, and snippets.

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

Shawn Seymour devshawn

💻
Kafka! 😄
View GitHub Profile
@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 November 8, 2024 05:14
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) {
@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();
@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;
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing
@sloria
sloria / bobp-python.md
Last active November 14, 2024 15:01
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
@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: