Skip to content

Instantly share code, notes, and snippets.

View devth's full-sized avatar
Hacking on @yetibot

Trevor Hartman devth

Hacking on @yetibot
View GitHub Profile
@kyledrake
kyledrake / ferengi-plan.txt
Last active January 10, 2025 14:02
How to throttle the FCC to dial up modem speeds on your website using Nginx
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
(def ^ThreadLocal stack-depth (ThreadLocal.))
(def ^Executor overflow-protection-pool
(let [cnt (atom 0)]
(Executors/newCachedThreadPool
(thread-factory #(str "manifold-overflow-protection-pool-" (swap! cnt inc))))))
(def ^:const max-depth 50)
(defmacro without-overflow [& body]
@jessitron
jessitron / gist:8777503
Created February 3, 2014 01:09
The magic of blocking { ... } in Scala's global ExecutionContext: it leads to the creation of more threads, so the CPUs don't get bored
val des = scala.concurrent.ExecutionContext.global
import scala.concurrent._
import duration._
def ct = Thread.currentThread.getName
val n = Runtime.getRuntime.availableProcessors
def hogThread(sec:Int) = future {
@bitemyapp
bitemyapp / gist:8739525
Last active May 7, 2021 23:22
Learning Haskell
@martinklepsch
martinklepsch / random-color.clj
Last active April 23, 2022 20:07
Generate a random HEX color in cojure or clojurescript
(require '[clojure.string :as s])
;; My initial attempt
(def c [:0 :1 :2 :3 :4 :5 :6 :7 :8 :9 :A :B :C :D :E :F])
(str "#" (s/join (map name (repeatedly 6 #(rand-nth c)))))
;; Another option not using keywords (/ht locks in #clojure)
(def c [0 1 2 3 4 5 6 7 8 9 \A \B \C \D \E \F])
(str "#" (s/join (repeatedly 6 #(rand-nth c))))
;; the last line can be simplified even more (/ht xificurC in #clojure)
@fjavieralba
fjavieralba / KafkaLocal.java
Last active March 23, 2021 09:57
Embedding Kafka+Zookeeper for testing purposes. Tested with Apache Kafka 0.8
import java.io.IOException;
import java.util.Properties;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServerStartable;
public class KafkaLocal {
public KafkaServerStartable kafka;
public ZooKeeperLocal zookeeper;
@mkristian
mkristian / Mavenfile
Last active December 23, 2015 23:59
Mavenfile to use warbler to create the war file and replaces the maven artifact with that. the pom.xml is equivalent to the Mavenfile which got genreated by ruby-maven/tesla.
packaging :war
phase :package do
plugin 'de.saumya.mojo:jruby-maven-plugin', '1.0.0-rc3' do
execute_goal( :jruby,
:id => 'pack-war with warbler',
:filename => 'warble',
:gemUseSystem => true )
execute_goal( :jruby,
:id => 'move war to maven build dir',
@zmanji
zmanji / gist:6575133
Created September 15, 2013 23:15
Lol Scala.
Zameers-MacBook-Air:~ zmanji$ scala
Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17).
Type in expressions to have them evaluated.
Type :help for more information.
scala> null == null.asInstanceOf[Int]
<console>:8: warning: comparing values of types Null and Int using `==' will always yield false
null == null.asInstanceOf[Int]
^
res0: Boolean = true
@alexyoung
alexyoung / tmux.conf
Created July 19, 2013 16:12
tmux cheap powerline
#!/usr/bin/env sh
ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%\n", $10/$5 * 100)}'
@ashrithr
ashrithr / kafka.md
Last active March 14, 2024 21:16
kafka introduction

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic