Skip to content

Instantly share code, notes, and snippets.

@himalay
himalay / auto-dns.sh
Last active July 9, 2023 13:14
[Pi-hole auto DNS switch] The script automatically switches the DNS servers between Pi-hole and Cloudflare based on Pi-hole DNS Server status. #pihole #openwrt
#!/bin/sh
# The script automatically switches the DNS servers between Pi-hole and Cloudflare based on Pi-hole DNS Server status.
TARGET=192.168.0.7 # Pi-hole
FALLBACK_A=1.1.1.1 # Cloudflare
FALLBACK_B=1.0.0.1 # Cloudflare
function set_fallback_dns() {
echo $(date)
@jesster2k10
jesster2k10 / README.md
Last active April 25, 2024 00:54
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@kylehowells
kylehowells / correct_dates.py
Created February 14, 2020 21:18
Automatically Corrects Insta360 Studio Snapshot Dates according to the filename.
import os
import re
import datetime
import piexif
filepath = os.path.abspath(".")
# Find files with `screenshot` in the name.
files = [f for f in os.listdir(filepath) if "screenshot" in f and f.endswith(".jpg")]
print(files)
@klingtnet
klingtnet / Viewsonic-VG2755-2k.md
Created January 14, 2020 15:14
Viewsonic VG2755-2k

Viewsonic VG2755-2k

A 27" WQHD business IPS display: specs.

Often customers report problems about humming or buzzing noises caused by badly designed power supplies when a device is connected and charged via USB-C to a display. One very bad example of this is the Lenovo ThinkVision P27h-10, but also devices from Dell and Philips seem to be noisy when USB-C charging is active. I owned one of the P27h-10 for a short time and the noise was unbearable so I returned the display to the seller. Except that the monitor was very good, sturdy built, crisp and very bright diplay. Nonetheless, I wanted to have a display where I can connect my X1 through a single cable.

The Viewsonic VG2755-2k works fine when connected via USB-C, it can provide up to 60W charging power (15W more than the Lenovo) and makes absolutely no noise.

@naesean
naesean / jsonapi_oas.yml
Last active May 6, 2024 00:41
OpenAPI 3.0 schemas that comply with the JSON:API 1.0 specification
JSONAPIObject:
description: Includes the current JSON:API version for this specification as well as optional meta information
type: object
required:
- version
properties:
version:
type: string
default: '1.0'
example: '1.0'
@phansch
phansch / yardoc_cheatsheet.md
Last active March 1, 2024 18:17 — forked from chetan/yardoc_cheatsheet.md
Improved YARD cheatsheet
@tkrajina
tkrajina / unmarshal_interface.go
Last active May 21, 2024 17:21
Unmarshal JSON to specific interface implementation
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type Something interface{}
@fxn
fxn / init.coffee
Created January 31, 2016 10:59
Easy pipeline entry in Atom (Elixir)
# ~/.atom/init.coffee
atom.commands.add 'atom-text-editor', 'elixir:pipeline': ->
editor = atom.workspace.getActiveTextEditor()
editor.moveToEndOfLine()
editor.insertNewline()
editor.insertText("|> ")
@cabal95
cabal95 / vm-backup.sh
Created July 25, 2015 17:53
I use this script to backup my QEMU/KVM/libVirt virtual machines. The script requires KVM 2.1+ since it uses the live blockcommit mode. This means the data in the snapshot disk is rolled back into the original instead of the other way around. Script does NOT handle spaces in paths.
#!/bin/bash
#
BACKUPDEST="$1"
DOMAIN="$2"
MAXBACKUPS="$3"
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]"
exit 1
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then