Skip to content

Instantly share code, notes, and snippets.

View dhbradshaw's full-sized avatar

Douglas H. Bradshaw dhbradshaw

  • Harvest Alabama
View GitHub Profile
@dhbradshaw
dhbradshaw / systemd_services.md
Last active April 15, 2024 11:18 — forked from leommoore/systemd_services.md
Systemd Services 101

Check that your system supports systemd

pidof systemd
2733

If this return a number then your system supports systemd. Most Linux distributions in 2017 support systemd.

Check out the processes currently running.

Since systemd starts the process then all processes will be children of systemd

@dhbradshaw
dhbradshaw / gist:e2bdeb502b0d0d2acced
Last active August 16, 2023 17:50
Rename field using migrations in django 1.7
To change a field name in django 1.7+
1. Edit the field name in the model (but remember the old field name: you need it for step 3!)
2. Create an empty migration
$ python manage.py makemigrations --empty myApp
3. Edit the empty migration (it's in the migrations folder in your app folder, and will be the most recent migration) by adding
migrations.RenameField('MyModel', 'old_field_name', 'new_field_name'),
to the operations list.

Boiled Eggs

  • Place eggs into bottom of sauce pan.
  • Cover eggs with water.
  • Bring to boil.
  • Allow to boil for 4 minutes.
  • Turn off burner and allow to cool.
  • Eat at will.
@dhbradshaw
dhbradshaw / postgres-windows.md
Last active April 21, 2022 19:08
Postgres on WSL (Windows Subsystem for Linux) ubuntu 18.04

Postgres on WSL (Windows Subsystem for Linux) ubuntu 18.04

Hint: it's not different than running it under ubuntu without Windows.

Add postgres package registry

sudo apt install postgresql-common
sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

Update apt

@dhbradshaw
dhbradshaw / safe--git-branch-delete.sh
Created February 28, 2022 15:45
Delete all redundant git branches
# Delete all redundant git branches
# 1. `git branch` lists all the branches
# 2. `xargs -L1` consumes the pipe output one line at a time, feeding it as an an arg to the target command
# 3. `git branch -d` deletes the branches that are redundant (already merged).
# Note: this print results for each branch, either
# saying it's deleted or that you need to use -D to delete it because it's not redundant.
git branch | xargs -L1 git branch -d
@dhbradshaw
dhbradshaw / validate_xlsx_xml.md
Created November 10, 2021 12:39
Validate all the xml from an Excel xlsx file

Validate Excel .xlsx file xml using linux

Unzip

A .xlsx file is roughly a zipped bundle of xml files. To unzip them, just use unzip.

Here we send the unzipped contents of myfile.xlsx to the myfile_unzipped directory, which will be created on the fly.

unzip myfile.xlsx -d myfile_unzipped
@dhbradshaw
dhbradshaw / gist:13d0ea29e4a4cea1b74c9903ed24d957
Last active October 29, 2021 10:09
Flutter .zshrc for Mac
export PATH="$PATH:/Users/doug/projects/flutter/bin" # Point to your downloaded flutter executable
# export CHROME_EXECUTABLE=/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser # Point to your chromium executable
@dhbradshaw
dhbradshaw / init.coffee
Last active September 24, 2021 08:06
Customize tab titles in atom text editor.
# place this snippet into init.coffee in ~/.atom directory
atom.workspace.observeTextEditors (editor) ->
if editor.getTitle() isnt "untitled"
sp = editor.getPath().split('/')
title = sp.slice(sp.length-2).join('/')
editor.getTitle = -> title
editor.getLongTitle = -> title
for item in atom.workspace.getPaneItems()
import boto3
s3 = boto3.resource('s3')
bucket = s3.Bucket('my-bucket-name')
bucket.object_versions.filter(Prefix='my/key/prefix').delete()
@dhbradshaw
dhbradshaw / next_image.sh
Created April 25, 2021 02:50
Command to rotate to the next image on gnome desktop (if I save images I want to rotate through to Pictures/rotate_background)
#!/bin/bash
DIR="/home/doug/Pictures/rotate_background"
# Get full path
FULL_PATH=$(gsettings get org.gnome.desktop.background picture-uri)
# Clean off quotes.
FULL_PATH=$(echo $FULL_PATH | sed 's/.$//' | sed 's/^.//')