Skip to content

Instantly share code, notes, and snippets.

@Deja-Vu1
Deja-Vu1 / praytimes.py
Created August 9, 2021 12:21
Fix for the python code version 2 of the Pray Times algorithm http://praytimes.org/code/ (Berkin İlkan Seçkin)
#!/usr/bin/env python
# compatible with python 2.x and 3.x
import math
import re
'''
--------------------- Copyright Block ----------------------
praytimes.py: Prayer Times Calculator (ver 2.3)
@LeeKahSeng
LeeKahSeng / KeychainHelper.swift
Last active April 21, 2025 23:25
Swift simple keychain helper class for iOS and macOs
// MIT License
//
// Copyright (c) 2023 Lee Kah Seng
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@muripic
muripic / python_libraries_and_tools_to_make_your_scripts_suck_less.md
Last active October 6, 2025 15:54
Article: Python libraries and tools to make your scripts suck less

Python libraries and tools to make your scripts suck less

If you're an SRE or DevOps engineer, you'll usually find yourself writing scripts to automate tasks. But a collection of scripts, probably written by different members of the team, with different standards and tools, will soon become unmaintainable and trigger conversations such as "Can the script do this?" or "How do I make this change?". Sometimes, you may even have those conversations with yourself because after a while you no longer understand your own code.

If you think of your scripts not so much as a set of commands run one after another but as command-line applications, which should meet certain standards and follow good coding practices, they'll become much more user-friendly and maintainable.

Disclaimers:

  • This list should be specially useful for people writing scripts from scratch. If you're working on a big project as a developer, it's likely that many of the tools I'll describe (or some alternative) are already in use. But if the
@JensRantil
JensRantil / cassandra_netstats_progress.sh
Last active January 13, 2023 02:50
Hacky one-liner for estimating progress when adding a new Cassandra node. Run on the join that’s joining and be sure to set NODES to number of nodes in the cluster that are streaming to the new node.
#!/bin/bash
while [ 1 ];do date -Iseconds | tr -d '\n';sudo nodetool netstats | grep Receiving | grep -Eo '[0-9]* bytes' | sed 's/ bytes//' | awk 'BEGIN {NODES=6;} NR%2==1 {TOTAL+=$0;} NR%2==0 {PROGRESS+=$0;} END {NODESRUNNING=NR/2;NODESDONE=NODES-NODESRUNNING;print " progress:", 100*(NODESDONE/NODES+(NODESRUNNING/NODES)*(PROGRESS/TOTAL)) "%", "running:", NODESRUNNING, "done:", NODESDONE;}';sleep 30;done
@romanhaa
romanhaa / run.sh
Last active June 14, 2024 12:43
macOS settings
# https://macos-defaults.com/
# https://www.defaults-write.com
# reset with: defaults delete -g <FEATURE>
# dock
# position
defaults write com.apple.dock "orientation" -string "right"
# icon size
defaults write com.apple.dock "tilesize" -int "36"
@vncsna
vncsna / bash_strict_mode.md
Created June 6, 2021 01:59 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
// homerunner is Brad's shitty Docker wrapper after he got tired of running
// HA nine-VM Kubernetes clusters. Earlier versions of this tried to use podman
// and fancy cloud-init and CNI stuff but then I decided to go to the other
// extreme and write something super specific to what I need and super dumb:
// run my containers from gcr.io, and use my home Ceph cluster for mounts/state.
//
// This primarily runs Home Assistant, HomeSeer, an MQTT server, and some cameras.
// And some omitted misc stuff.
package main
@fxm90
fxm90 / Combine+Pairwise.swift
Last active August 2, 2025 21:58
Extension for a Combine-Publisher that returns the current and previous value.
//
// Combine+Pairwise.swift
//
// Created by Felix Mau on 17.05.21.
// Copyright © 2021 Felix Mau. All rights reserved.
//
import Combine
extension Publisher {
@smvd
smvd / FlappyBird.c
Last active August 20, 2025 21:29
flappy bird writen in c running in the terminal
/*
_ _ _ _____ _ ____ _
| \ | | ___ | |_ | ___| | __ _ _ __ _ __ _ _ | _ \ _ _ ___| | __
| \| |/ _ \| __| | |_ | |/ _` | '_ \| '_ \| | | | | | | | | | |/ __| |/ /
| |\ | (_) | |_ | _| | | (_| | |_) | |_) | |_| | | |_| | |_| | (__| <
|_| \_|\___/ \__| |_| |_|\__,_| .__/| .__/ \__, | |____/ \__,_|\___|_|\_\
|_| |_| |___/
compiler : GCC
command : gcc source.c -o FlappyBird.exe -Werror -Wall -W -s
license : www.unlicense.org (Please credit my channel tho)
@dims
dims / README.md
Last active January 6, 2026 15:27
Kubernetes Resources