Skip to content

Instantly share code, notes, and snippets.

@samuelharmer
samuelharmer / README.md
Last active June 29, 2022 21:38
Amazon Photos, re-run failures

There's no Desktop application for Amazon Photos on Linux. Your only option is to upload through the web user interface.

If you have failures, a <div> pops up in the lower left telling you there are failures, but there's no real way to do anything with that information. Assuming the errors were not serious (e.g. you ran out of upload space for videos) you probably just want to retry the failures: especially if you have 25 thousand files.

The only sensible way to extract the list of failures (there were 170 odd in my case) was to inspect the page and copy the HTML node containing the errors.

@samuelharmer
samuelharmer / go-os-arch.md
Created April 29, 2021 07:13 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.14.7 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • aix
  • android
@samuelharmer
samuelharmer / README.md
Last active December 9, 2020 09:58
Ansible Demo: Compare

Ansible Compare

Frequently we might need to make a change to a file and respond to removals as well as additions.

This playbook demonstrates how we can detect changes (using the Ansible host).

  1. Run the playbook in regular mode ansible-playbook demo-compare.yaml. Look for a file named demo-compare.txt alongside the playbook.
  2. Change a name in the file_data list.
  3. Re-run the playbook in --check mode.
@samuelharmer
samuelharmer / ks-centos7-pxe-server.cfg
Created October 27, 2020 18:37 — forked from wilkersoncs/ks-centos7-pxe-server.cfg
Kickstart to create CentOS 7 PXE Server with sample network install kickstart
#version=DEVEL
##Adapted from procedures from https://www.linuxtechi.com/configure-pxe-installation-server-centos-7/
##Use by pressing tab on CentOS install screen and adding
## ks=hd:sdb1:/ks-pxe.cfg
##Make sure target system has 2GB of RAM
firewall --disabled
selinux --disabled
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
@samuelharmer
samuelharmer / Use-Impersonation.ps1
Created September 16, 2020 12:17 — forked from idavis/Use-Impersonation.ps1
Impersonate a user and execute a script block as that user
param( [ScriptBlock] $scriptBlock )
<#
.SYNOPSIS
Impersonates a user and executes a script block as that user. This is an interactive script
and a window will open in order to securely capture credentials.
.EXAMPLE
Use-Impersonation.ps1 {Get-ChildItem 'C:\' | Foreach { Write-Host $_.Name }}
This writes the contents of 'C:\' impersonating the user that is entered.
#>
@samuelharmer
samuelharmer / bash_history.sh
Last active September 16, 2020 08:56 — forked from ckabalan/best_bash_history.sh
The Best Bash History Settings Ever
# /etc/profile.d/bash_history.sh
# Save 5,000 lines of history in memory
HISTSIZE=10000
# Save 2,000,000 lines of history to disk (will have to grep ~/.bash_history for full listing)
HISTFILESIZE=2000000
# Append to history instead of overwrite
shopt -s histappend
# Ignore redundant or space commands
HISTCONTROL=ignoreboth
# Ignore more
#!/usr/bin/bash
which ansible >/dev/null 2>&1
if [ $? -ne 0 ];
then
echo "Installing Ansible..."
sleep 5
pushd .
cd ~
pacman -S libyaml-devel python2 tar libffi libffi-devel gcc pkg-config make openssl-devel openssh libcrypt-devel --noconfirm --needed
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
@samuelharmer
samuelharmer / reportlab_list_formatting.py
Created June 17, 2020 11:13
Custom formatting of reportlab lists
#!/usr/bin/env python3
import unicodedata
from pathlib import Path
from reportlab.platypus import SimpleDocTemplate, Paragraph, ListFlowable, Spacer
from reportlab.lib.styles import getSampleStyleSheet
output = Path.cwd() / Path(__file__).with_suffix(".pdf").name
doc = SimpleDocTemplate(str(output))
@samuelharmer
samuelharmer / one_flask.py
Created May 12, 2020 07:15 — forked from mikefromit/one_flask.py
a one file flask app for trying stuff
# THIS PROJECT IS AN EXAMPLE APP. SOME CODE MAY NOT BE ACTUALLY USEFUL
# FOR DEMONSTRATION PURPOSES ONLY
# YOUR MILEAGE MAY VARY
# Requirements are Flask, Flask-WTF, Flask-SQLAlchemy
import os
from flask import (Flask,
Blueprint,
redirect,
@samuelharmer
samuelharmer / server.py
Created February 13, 2020 11:08 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):