Skip to content

Instantly share code, notes, and snippets.

@m-radzikowski
m-radzikowski / script-template.sh
Last active Dec 1, 2022
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
View script-template.sh
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@Eskuero
Eskuero / synapse-tidying.py
Last active Sep 4, 2020
Tidying up a bit database and remote media from a synapse server using the admin API
View synapse-tidying.py
import requests
import time
# Login and get a token
endpoint = "http://localhost:8008/_matrix/client/r0/login"
data = {
"type": "m.login.password",
"identifier": {
"type": "m.id.user",
"user": "USER"
@MTuner
MTuner / fix-sublimetext-subpixel.txt
Last active Nov 4, 2022
Fixing font rendering/aliasing in Sublime Text in MacOS Mojave
View fix-sublimetext-subpixel.txt
Apple removed colored sub-pixel antialiasing in MacOS Mojave
(https://developer.apple.com/videos/play/wwdc2018/209/ starting from ~28min)
To make fonts look normal in Sublime Text, add to Preferences:
// For the editor
"font_options": [ "gray_antialias" ],
// For the sidebar / other elements
"theme_font_options": [ "gray_antialias" ],
@ruanbekker
ruanbekker / docker-nfs-volumes.md
Created Dec 10, 2017
NFS Volumes with Docker Swarm
View docker-nfs-volumes.md

Create NFS Volumes:

Creating the NFS Volume:

$ docker volume create --driver local \
  --opt type=nfs \
  --opt o=addr=192.168.1.115,uid=1000,gid=1000,rw \
  --opt device=:/mnt/volumes/mysql-test \
  mysql-test-1
@quelleck
quelleck / rpi-hdmi.sh
Last active Oct 28, 2022 — forked from AGWA/rpi-hdmi.sh
Enable and disable the HDMI port on the Raspberry Pi: `rpi-hdmi on` to turn on, `rpi-hdmi off` to turn off.
View rpi-hdmi.sh
#!/bin/sh
# Enable and disable HDMI output on the Raspberry Pi
is_off ()
{
vcgencmd display_power | grep "display_power=0" >/dev/null
}
case $1 in
@bcardiff
bcardiff / list-deps.cr
Last active Nov 18, 2021
List binary dependencies to build a minimal docker image from scratch
View list-deps.cr
unless ARGV.size > 0
puts " Missing executable file argument"
puts " Usage (in a Dockerfile)"
puts " RUN crystal run ./path/to/list-deps.cr -- ./bin/executable"
exit 1
end
executable = File.expand_path(ARGV[0])
unless File.exists?(executable)
@decors
decors / delegate.cr
Created Jan 26, 2017
Crystal-lang simple delegator
View delegate.cr
class Delegator(T)
def initialize(@object : T)
end
def self.delegate(object)
new(object)
end
forward_missing_to @object
end
@sagittaros
sagittaros / Dockerfile
Last active Apr 11, 2020
Docker + Rails configuration + Docker Sync
View Dockerfile
# This Dockerfile is intended to build a production-ready app image.
#
# This is not required for development environments
FROM sagittaros/rails-base:latest
MAINTAINER Felix Tioh <felix.tioh@crowdo.com>
COPY . /app
WORKDIR /app
EXPOSE 5000
@averyvery
averyvery / application.rb
Last active Jun 4, 2021
Inline CSS or JS in Rails
View application.rb
config.assets.precompile += [
# precompile any CSS or JS file that doesn't start with _
/(^inline[^_\/]|\/[^_])[^\/]*.(js|css)$/,
...
@johnbintz
johnbintz / simple-capistrano-docker-deploy.rb
Last active Aug 21, 2020
Simple Capistrano deploy for a Docker-managed app
View simple-capistrano-docker-deploy.rb
# be sure to comment out the require 'capistrano/deploy' line in your Capfile!
# config valid only for Capistrano 3.1
lock '3.2.1'
set :application, 'my-cool-application'
# the base docker repo reference
set :name, "johns-stuff/#{fetch(:application)}"