Skip to content

Instantly share code, notes, and snippets.

View zygm0nt's full-sized avatar
🥑
AFK

Marcin Cylke zygm0nt

🥑
AFK
View GitHub Profile
@zygm0nt
zygm0nt / template-basic
Last active October 7, 2015 03:18 — forked from Gen2ly/template-basic
bash template with colors
#!/bin/bash
# Description of script
# bash strict mode: http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n\t'
# Display usage if no parameters given
if [[ -z "$@" ]]; then
echo " ${0##*/} <input> - description"
@zygm0nt
zygm0nt / import-blogger.rb
Created October 1, 2012 13:56 — forked from dnagir/import.rb
Import a posts archive to jekyll (octopress version, allows quotes in titles)
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
# usage: ruby import.rb my-blog.xml
# my-blog.xml is a file from Settings -> Basic -> Export in blogger.
data = File.read ARGV[0]
@zygm0nt
zygm0nt / mod_charset_lite.diff
Last active December 9, 2015 22:28 — forked from anonymous/mod_charset_lite.diff
Filter only content with mime types text/plain, text/html, application/* (to catch application/json)
--- mod_charset_lite.c.orig 2009-11-18 17:18:06.000000000 +0100
+++ mod_charset_lite.c 2013-01-14 13:11:45.017062580 +0100
@@ -239,9 +239,9 @@
}
/* catch proxy requests */
- if (r->proxyreq) {
+ /*if (r->proxyreq) {
return DECLINED;
- }

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

package foo.bar
import spray.routing._
import spray.http._
import spray.http.StatusCodes.Forbidden
// See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
case class Origin(origin: String) extends HttpHeader {
@zygm0nt
zygm0nt / service-checklist.md
Created September 26, 2016 21:57 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@zygm0nt
zygm0nt / CirceSupport.scala
Created August 3, 2017 22:42 — forked from mattroberts297/CirceSupport.scala
Akka HTTP Circe Custom Marshaller and Unmarshaller
import io.circe._
import io.circe.parser._
import io.circe.syntax._
import akka.http.scaladsl.marshalling.{Marshaller, ToEntityMarshaller}
import akka.http.scaladsl.model.{ContentTypeRange, HttpEntity}
import akka.http.scaladsl.model.MediaTypes.`application/json`
import akka.http.scaladsl.unmarshalling.{FromEntityUnmarshaller, Unmarshaller}
import scala.concurrent.Future
@zygm0nt
zygm0nt / Lens.java
Created April 4, 2021 19:17 — forked from mathieuancelin/Lens.java
Lenses with Java 8
package bar.foo.lenses;
import java.util.function.BiFunction;
import java.util.function.Function;
public class Lens<A, B> {
private final Function<A, B> getter;
private final BiFunction<A, B, A> setter;