Skip to content

Instantly share code, notes, and snippets.

View matisojka's full-sized avatar

Mateusz Sójka matisojka

View GitHub Profile
@matisojka
matisojka / docker-cleanup-resources-centos.md
Last active June 1, 2018 19:32 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks (CentOS version)

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ sudo docker volume rm $(sudo docker volume ls -qf dangling=true)

$ sudo docker volume ls -qf dangling=true | xargs -r sudo docker volume rm

@matisojka
matisojka / enteprisifier.rb
Created September 30, 2016 13:38
Tiny helper to make your program feel more enteprisy!
class Enterprisifier
def self.enterprisify!
sleep 5
end
end
@matisojka
matisojka / Dockerfile
Created March 5, 2016 11:00
Tiny Go microservice plumbing
FROM alpine:3.2
ENV GOROOT=/usr/lib/go \
GOPATH=/gopath \
GOBIN=/gopath/bin \
PATH=$PATH:$GOROOT/bin:$GOPATH/bin
WORKDIR /gopath/src/app
ADD . /gopath/src/app
@matisojka
matisojka / Dockerfile
Last active March 5, 2016 09:23 — forked from shijuvar/main.go
A simple microservice plumbing in Go
FROM google/golang:stable
# Godep for vendoring
RUN go get github.com/tools/godep
# Recompile the standard library without CGO
RUN CGO_ENABLED=0 go install -a std
MAINTAINER mateusz.sojka@deindeal.ch
ENV APP_DIR $GOPATH/Users/mati/deindeal/moosehead/modules/newsletter_feeds
# Set the entrypoint
@matisojka
matisojka / gist:ca41d70da79239ffbfe8
Created July 2, 2015 12:46
Github labels / states
Review finished - expecting dev input
Feedback considered - expecting review
Code accepted - Ready for QA
QA pending
QA validated
QA rejected - expecting dev input
Ship it
@matisojka
matisojka / routes.rb
Last active August 29, 2015 14:24
Splitting routes into modules
YourApplication::Application.routes.draw do
root to: 'home#index'
get '/about'
get '/login' => 'application#login'
end
ADDITIONAL_ROUTES = [:messages, :orders, :api, :admin]
ADDITIONAL_ROUTES.each do |route_file|
require "#{Rails.root}/config/routes/#{route_file}"
end
@matisojka
matisojka / env.rb
Last active August 29, 2015 14:24
Proposal for better ENV usage in Ruby
# Currently, many times we are using ENV variables in a non-optimal way.
# I'd like to explain some of the common use cases for those variables
# and how we can use them in a way that we get the most out of it.
# A common error is to assume that the variable has to be there, but it isn't
# This happens when we use the ENV hash like this:
ENV['SOME_KEY']
# In Ruby, if the key is missing, it will return `nil`, thus calling a method on it
@matisojka
matisojka / memory_cache.rb
Last active August 29, 2015 14:11
In-memory cache with key limit
class MemoryCache
DEFAULT_MAX_KEYS = 5000
attr_reader :data, :max_keys
def initialize(config)
@data = {}
@max_keys = config[:max_cache_keys] || DEFAULT_MAX_KEYS
@lock = Mutex.new
@matisojka
matisojka / Gemfile
Last active August 29, 2015 14:04
Proxy for separate backend + frontend apps that work together
source 'https://rubygems.org'
gem 'rack-reverse-proxy', require: 'rack/reverse_proxy'
group :development do
gem 'foreman'
end
@matisojka
matisojka / comparison.rb
Created November 27, 2013 08:40
First string character comparison benchmark
require 'benchmark'
name = 'my_cool_string'
Benchmark.bmbm(10) do |x|
x.report('name[0] hit') do
1_000_000.times { name[0] == 'm' }
end
x.report('name[0] miss') do
1_000_000.times { name[0] == 'y' }