Skip to content

Instantly share code, notes, and snippets.

@xcsrz
xcsrz / install-python-3.9-on-centos.sh
Created May 13, 2022 15:52
Install Python 3.9 on CentOS or Amazon Linux
#!/bin/sh
sudo yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel
cd /tmp
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
tar -xvf Python-3.9.6.tgz
cd Python-3.9.6
./configure --enable-optimizations
sudo make altinstall
python3.9 --version
@xcsrz
xcsrz / FLSTN Rear Shock Adjustment.md
Created February 10, 2024 20:33
How to adjust Softail rear shock preload

FLSTN Rear Shock Adjustment

So Softails's come from the factory with the lightest setting on the read shocks which is only good for solo riders weighing less than 180 lbs. If you weigh more yourself or you want to ride with a pack, a passenger or both - you need to adjust the preload on the rear shocks to safe your back, your passengers back and potentially your ride. A properly adjusted suspension makes all the difference!

Both the owners manual and service manual have a section describing the basics of adjusting the preload, but nothing from HD offers the actual steps to take or any guide to adjust for a specific weight. The procedure is very simple but without a guide you're left to trial and error and a lot of jacking or relying on a shop to make the adjustment for you. This is based on articles posted online by dealers and HD service shops (and doesn't that defeat the purpose of having an HD in the first place?).

This is not an exact adjustment, and perhaps that's why HD doesn't spell it out. B

@xcsrz
xcsrz / center_text_on_image.py
Created March 8, 2017 00:17
Center text on an image with Python and OpenCV. Had to come up with it myself as no one was spelling this out anywhere (or google couldn't find it)
#!/usr/bin/env python
import numpy as np
import cv2
from time import sleep
# create blank image - y, x
img = np.zeros((600, 1000, 3), np.uint8)
# setup text
@xcsrz
xcsrz / a-stylized-message.php
Last active September 18, 2023 17:32
The most simple method to post a message to slack via an 'incoming webhook' from PHP
<?php
function post_slack_message($msg) {
$opts = [
'http' => [
'method' => 'POST',
'header' => "Content-type: application/json\r\n",
'content' => json_encode([
'attachments' => [
[
@xcsrz
xcsrz / add-fades-to-video.sh
Last active February 26, 2023 16:36
Add a gentle fade-in from black to the beginning and a matching fade-out to the end of a video clip
#!/bin/bash
destfile() {
dir=$(dirname "$1")
filename=$(basename -- "$1");
extension="${filename##*.}";
basename="${filename%.*}";
filepath="${dir}/${basename}-faded.${extension}";
c=0
@xcsrz
xcsrz / post_request_with_redirect_result.dart
Last active February 14, 2023 19:31
Posting from Dart to a URL with a redirect: Since Dart's stock http package (and even the dio package) chose to handle redirects differently than basically every other language+package out there and disregard redirect responses returned to a POST request you have to do a little extra work. Worse than anything is every solution I have found was #…
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart';
String url =
"https://script.google.com/macros/s/YOUR_DEPLOYMENT_HASH_HERE/exec";
final data = {
'foo': 456,
@xcsrz
xcsrz / server.go
Created January 2, 2016 07:12
A golang web server on a randomly (os) chosen port.
package main
import (
"fmt"
"github.com/skratchdot/open-golang/open"
"net"
"net/http"
)
func main() {
@xcsrz
xcsrz / es-doc-accounting.py
Created March 7, 2022 15:57
Reconcile descrepencies in document counts within elasticsearch
from requests import get
from json import dumps, loads
from prettytable import PrettyTable
src_server = 'http://localhost:9200'
def docCount(idx=None, typ=None):
url = src_server
if idx:
@xcsrz
xcsrz / amazon2-linux-amis-for-cloudformation.py
Created February 25, 2022 21:20
This script prints out the current list of Amazon2 Linux AMI's by region (kernel 5.10, HVM, x86_64, gp2). Changing the image variable and the Path filter make this capable of searching for any public/shared image.
import boto3
from json import dumps
from yaml import dump
image = 'amzn2-ami-kernel-5.10-hvm-x86_64-gp2'
regions = [
'ap-northeast-1',
'ap-northeast-2',
'ap-northeast-3',
@xcsrz
xcsrz / list-timezones-with-winter-and-summer-offsets.py
Created January 16, 2022 17:46
Sometimes you just want a list of timezones with their offsets. From this you can find the offset for a given timezone on a specific date.
from datetime import datetime
import pytz
UTC = pytz.timezone("UTC")
for tzn in pytz.common_timezones:
tz = pytz.timezone(tzn)
print(
tzn,
UTC.localize(datetime(2020, 12, 15)).astimezone(tz).strftime('%z'),
UTC.localize(datetime(2020, 6, 15)).astimezone(tz).strftime('%z'),