Skip to content

Instantly share code, notes, and snippets.

View analytically's full-sized avatar

Mathias Bogaert analytically

View GitHub Profile
@analytically
analytically / gist:3077691
Created July 9, 2012 17:11
Spray XStream marshalling support
import cc.spray.typeconversion.{DefaultMarshallers, SimpleMarshaller, SimpleUnmarshaller, DefaultUnmarshallers}
import com.thoughtworks.xstream.XStream
import com.thoughtworks.xstream.io.xml.StaxDriver
import cc.spray.http._
import MediaTypes._
import HttpCharsets._
import cc.spray.json._
import cc.spray.SprayBaseSettings
import cc.spray.http.ContentTypeRange
@analytically
analytically / gist:4293859
Created December 15, 2012 11:11
Rate limiting code using Spray 1.0-M2, needs migration.
def rateLimit(action: String, subject: String, maxRequests: Int) = {
val key = action + ":" + subject
add(redis, key)
val actionCount = count(redis, key, interval)
transformRequestContext {
ctx =>
ctx.withResponseTransformed {
response =>
@analytically
analytically / gist:4295042
Created December 15, 2012 13:37
Migration of gist:4293859
def rateLimit(action: => String, subject: => String, maxRequests: => Int): Directive0 = {
mapInnerRoute {
inner => ctx =>
val key = action + ":" + subject
add(redis, key)
val actionCount = count(redis, key, interval)
if (actionCount >= maxRequests) {
logger.warn("Rate limiting user '" + subject + "': exceeded max number of requests (" + maxRequests + ").")
@analytically
analytically / gist:5760207
Created June 11, 2013 20:13
Ansible /etc/network/interfaces template
# {{ ansible_managed }}
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
{% if ansible_interfaces|length > 2 %}
@analytically
analytically / interfaces
Last active July 31, 2023 11:52
Ansible interface bonding tasks.
# {{ ansible_managed }}
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
{% if ansible_interfaces|length > 2 %}
@analytically
analytically / gist:1a6bdcfa711474d7ba24
Last active November 1, 2021 20:01
Ubuntu 14.04 AWS EC2 cloud-init (Kernel 3.18+NTP+ixgbevf+Docker+Route53) - to be used with ami-870a2fb7 and newer instance types (eg. t2, m3, c3, r3)
#!/bin/bash
set -e
sudo rm -f /etc/update-motd.d/10-help-text
sudo rm -f /etc/update-motd.d/51-cloudguest
sudo rm -f /etc/update-motd.d/91-release-upgrade
echo -e "[sysinfo]\nexclude_sysinfo_plugins = LandscapeLink" | sudo tee /etc/landscape/client.conf
echo deb https://get.docker.com/ubuntu docker main | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
@analytically
analytically / README.md
Created September 1, 2016 22:29 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


Index:

Keybase proof

I hereby claim:

  • I am analytically on github.
  • I am analytically (https://keybase.io/analytically) on keybase.
  • I have a public key whose fingerprint is 6560 B522 27E1 4A62 A9A0 4685 FB67 7394 51EC 486A

To claim this, I am signing this object:

@analytically
analytically / rating.md
Created June 19, 2018 14:02 — forked from alexflav23/rating.md
Interview rating

Interview score card

Part 1. Basic knowledge

  1. (2 points) Easy: What is the difference beteen var, val and def? [x] 2
  2. (3 points) Easy: How does pattern matching work in Scala? [x] 3
  3. (3 points) Easy: What are right associative methods in Scala? [x] 0
  4. (3 points) Easy: What is the difference between a trait and an abstract class in Scala? [x] 3
  5. (2 points) Medium: What is scala.util.control.NonFatal? [x] 2
  6. (3 points) Medium: How does Scala solve the diamond resolution problem with traits? [x] 3