Skip to content

Instantly share code, notes, and snippets.

@boysbee
boysbee / HelloWorld.scala
Created May 8, 2014 18:01
hello world with scala
object HelloWorld {
def main(args: Array[String]) = println("Hello World!")
}
@boysbee
boysbee / rabbitmq.sh
Created December 22, 2016 16:28
Run docker with RabbitMQ and management plugin and set user , password default.
#!/bin/sh
docker run -d --hostname my-rabbit --name rabbit-local -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=p@ssw0rd -p 8080:15672 rabbitmq:3-management
#!/bin/sh
docker volume rm $(docker volume ls -qf dangling=true)
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@boysbee
boysbee / clean-docker-for-mac.sh
Created April 5, 2017 08:21
Clean docker for mac
#!/bin/bash
# Copyright 2017 Théo Chamley
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
@boysbee
boysbee / PrometheusMetricsController.scala
Created May 2, 2017 18:52 — forked from jnesbitt/PrometheusMetricsController.scala
Prometheus metrics controller for Play! Framework 2.5
package controllers
import java.io.Writer
import akka.util.ByteString
import io.prometheus.client._
import io.prometheus.client.exporter.common.TextFormat
import play.api.http.HttpEntity
import play.api.mvc._
@boysbee
boysbee / docker-compose-chronograf.yml
Created May 4, 2017 11:11
docker-compose influx, chronograf,kapacitor
version: '2'
services:
# Define a Telegraf service
telegraf:
image: telegraf
volumes:
- ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
links:
- influxdb
@boysbee
boysbee / nginx-tuning.md
Created June 15, 2017 17:15 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@boysbee
boysbee / anorm.scala
Created July 18, 2017 16:02 — forked from davegurnell/anorm.scala
A short guide to Anorm
/*
Overview
--------
To run a query using anorm you need to do three things:
1. Connect to the database (with or without a transaction)
2. Create an instance of `anorm.SqlQuery` using the `SQL` string interpolator
3. Call one of the methods on `SqlQuery` to actually run the query
@boysbee
boysbee / jdk8_optional_monad_laws.java
Created November 23, 2017 15:44 — forked from ms-tg/jdk8_optional_monad_laws.java
Does JDK8's Optional class satisfy the Monad laws? Yes, it does.
/**
* ```
* Does JDK8's Optional class satisfy the Monad laws?
* =================================================
* 1. Left identity: true
* 2. Right identity: true
* 3. Associativity: true
*
* Yes, it does.
* ```