Skip to content

Instantly share code, notes, and snippets.

@kapad
kapad / toggle-nightlight.sh
Created July 3, 2018 20:30
Script to toggle the Gnome nightlight setting.
#!/bin/bash
setting=$(gsettings get org.gnome.settings-daemon.plugins.color night-light-enabled)
if [[ $setting == "true" ]]; then
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled false
else
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
fi
@kapad
kapad / dataUriToBinary.js
Created June 13, 2017 07:45
Convert a base64 encoded data URI to binary
let convertDataURIToBinary = (dataURI) => {
var BASE64_MARKER = ';base64,';
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = window.atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(var i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
@kapad
kapad / screen-man-simple.md
Last active August 1, 2018 21:23
Simplified man page/usage instructions for Linux screen command

Starting or re-entering an already running session (Works regardless of whether the session was detached properly or the internet connection went kaput)

Command: screen -D -RR If multiple users are going to share the same machine and all want to use screen, then use screen -D -RR <screen-alias>

To start with screen will only have one screen.

To start a new screen keyboard shortcut is

8.2.3. HTTP log format
----------------------
The HTTP format is the most complete and the best suited for HTTP proxies. It
is enabled by when "option httplog" is specified in the frontend. It provides
the same level of information as the TCP format with additional features which
are specific to the HTTP protocol. Just like the TCP format, the log is usually
emitted at the end of the session, unless "option logasap" is specified, which
generally only makes sense for download sites. A session which matches the
"monitor" rules will never logged. It is also possible not to log sessions for
@kapad
kapad / docker-compose.yml
Created March 7, 2018 11:26
docker compose redis cluster
version: '2'
services:
redis-cluster:
image: grokzen/redis-cluster
hostname: redis-cluster
ports:
- "7000:7000"
- "7001:7001"
- "7002:7002"
- "7003:7003"
@kapad
kapad / docker-compose.yml
Created March 7, 2018 11:25
docker compose master slave configuration
version: '3'
networks:
redismasterslave:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.18.0.0/16
/*
* Copyright 2013 Alex Pacini.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software