Skip to content

Instantly share code, notes, and snippets.

View pgaertig's full-sized avatar

Piotr Gaertig pgaertig

View GitHub Profile
# iptables-save
# Generated by iptables-save v1.8.7 on Sun Dec 18 17:35:25 2022
*filter
:INPUT ACCEPT [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:DOCKER - [0:0]
:DOCKER-ISOLATION-STAGE-1 - [0:0]
:DOCKER-ISOLATION-STAGE-2 - [0:0]
:DOCKER-USER - [0:0]
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
public class Main {
public static void main(String[] args) {
System.out.printf("JKuferek 1.0");
@pgaertig
pgaertig / Dockerfile
Created April 4, 2018 20:28
KP Dockerfile
FROM debian:stretch-slim
ENV RAILS_ENV=production TERM=xterm
ADD Gemfile Gemfile.lock package.json /home/app/
RUN (echo "deb http://deb.debian.org/debian/ stretch non-free contrib" >> /etc/apt/sources.list) && \
apt-get -qq update && \
apt-get install -y --no-install-recommends gnupg2 ca-certificates git curl ruby2.3 ruby-dev build-essential \
libpq-dev libpq5 libxml2 zlib1g-dev dumb-init libfontconfig ttf-mscorefonts-installer procps bzip2 && \
(curl -sL https://deb.nodesource.com/setup_8.x | bash - ) && \
gem install bundler --no-ri --no-rdoc && \
groupadd -g 1000 -o app && \
@pgaertig
pgaertig / 99-vfat-media-automount.rules
Created July 8, 2017 21:39
Ubuntu experiment to automount VFAT partitions without marking files with executable permission (fmask)
# vim:enc=utf-8:nu:ai:si:et:ts=4:sw=4:ft=udevrules:
#
# /etc/udev/rules.d/99-vfat-media-automount.rules
KERNEL!="sd[b-z]*", GOTO="vfat-media-automount_end"
IMPORT{program}="/sbin/blkid -o udev -p %N"
ENV{ID_FS_TYPE}!="vfat", GOTO="vfat-media-automount_end"
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
@pgaertig
pgaertig / ansible.cfg
Created November 23, 2016 08:19
Ansible config for local directory inventory with faster SSH pipelining
[defaults]
inventory = ./hosts
[ssh_connection]
pipelining = True
@pgaertig
pgaertig / install_docker.yaml
Last active November 23, 2016 08:16
Install Docker with registry on Debian server with Ansible
- hosts: myserver
tasks:
- name: Enable backports
apt_repository: filename="backports" repo="deb http://http.debian.net/debian jessie-backports main"
- name: Add apt http support
apt: name=apt-transport-https,ca-certificates
- name: Add docker repo key
apt_key: keyserver=hkp://p80.pool.sks-keyservers.net:80 id=58118E89F3A912897C070ADBF76221572C52609D
@pgaertig
pgaertig / utils.cljs
Created May 4, 2015 21:19
MomentJS with ClojureScript
(ns kpapi.utils)
(enable-console-print!)
(defn moment [arg] (.moment js/window arg))
(defn fmt-date-short [str]
(if str (-> (moment str) (.format "MM-DD HH:mm")) "-"))
(defn fmt-date-time [str]
@pgaertig
pgaertig / time-example.cljs
Created April 2, 2015 21:09
Time format conversion in ClojureScript with MomentJS
(enable-console-print!)
(defn moment [arg] (.moment js/window arg))
(defn json-date-short [str]
(if str
(-> (moment str)
(.format "MM-DD HH:mm"))
"-")
)
@pgaertig
pgaertig / gist:d4cde29c688b8ec6db05
Created December 21, 2014 23:59
Setup PostgreSQL 9.4 with custom locales on Debian

Add locale, e.g. pl_PL.UTF-8, you don't have to set it as system default:

dpkg-reconfigure locales

Install PostgreSQL

apt-get update
apt-get install posgresql-9.4

Installation adds a cluster with default locale, recreate it with the correct one. The operation will destroy existing data in the cluster.

@pgaertig
pgaertig / rand-url-str.clj
Last active August 29, 2015 14:10
Random URL safe string generation in Clojure
(defn rand-url-str [len]
(let [chars (concat (range 48 58) (range 97 123))]
(apply str (repeatedly len #(char (rand-nth chars))))))
(rand-url-str 12)
; => "ypua82wote07"