Skip to content

Instantly share code, notes, and snippets.

@mping
mping / nginx.conf
Created September 22, 2010 14:11
nginx config for reverse proxy based on url
#
# Simple basic nginx conf sample for setting up a reverse proxy
#
#user nobody;
worker_processes 1;
error_log logs/error.log info;
#pid logs/nginx.pid;
@mping
mping / commit.md
Last active June 9, 2018 11:47 — forked from abravalheri/commit.md
RFC: Git Commit Message Guidelines

Commit Message Guidelines

Goals

  • allow generating CHANGELOG.md by script
  • allow ignoring commits by git bisect (not important commits like formatting)
  • provide better information when browsing the history

Proposal

@mping
mping / profiles.clj
Last active April 19, 2018 08:06
~/.lein/profiles.clj
{:user {:plugins [[cider/cider-nrepl "0.16.0"]
[lein-midje "3.1.3"]
[lein-cloverage "1.0.9"]
[com.jakemccrary/lein-test-refresh "0.21.1"]
[lein-ancient "0.5.5"]
[jonase/eastwood "0.2.5"]
[lein-kibit "0.0.8"]
[lein-pprint "1.1.2"]]}}
@mping
mping / .zshrc
Created April 5, 2018 12:55
zsh
alias pserv='python -m SimpleHTTPServer $*'
alias wget='wget --trust-server-names --no-check-certificate'
alias ls='LC_COLLATE=C ls -lFha -G' #--group-directories-first --color '
alias grep='grep --color=always'
alias less='less -R'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
@mping
mping / FutureWUT.java
Last active March 27, 2018 15:35
CompletableFuture gotcha
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class FutureWUT {
static void sleep(long millis) {
try {
Thread.sleep(millis);
@mping
mping / core.clj
Created January 29, 2018 10:58
quasar producer
(ns clj-quasar.core
(:require
[co.paralleluniverse.pulsar
[core :refer :all]
[actors :refer :all]]))
(defsfn adder []
(receive [from v]
(do
(+ v 1))))

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@mping
mping / multiline.sh
Last active October 9, 2017 13:07
Multiline processing with bash
#!/bin/bash
## run nc with
# while true ; do echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -l 1500; done
#curl -XPOST -H "Partner-Id:230" --data "@-" http://localhost:1500
while read email; do
curl -X POST -d "$email" http://localhost:1500;
done << EOF
@mping
mping / Main.scala
Created July 3, 2017 09:46 — forked from sujoyu/Main.scala
Scala parser combinator sample like HTML tag.
import scala.util.parsing.combinator._
import scala.language.postfixOps
object Main {
def main(args:Array[String]) = {
val sc = new java.util.Scanner(System.in)
val input = collection.mutable.ListBuffer[String]()
while(sc.hasNextLine) {
input += sc.nextLine