Skip to content

Instantly share code, notes, and snippets.

Mark Koester markwk

View GitHub Profile
@markwk
markwk / text-renamer.sh
Created Apr 5, 2019
Bash script to append date of creation to a text file.
View text-renamer.sh
#!/bin/bash
cd /Users/markkoester/Desktop/
for f in *.txt ; do
if [ -f "$f" ]
then
filedatetime=$(stat -f '%Sm' -t '%Y%m%d%H%M' "$f")
filename=$(basename -- "$f")
extension="${filename##*.}"
filename="${filename%.*}"
filename="${filename// /_}"
@markwk
markwk / screenshot-renamer.sh
Created Apr 5, 2019
Mac Screenshot and Images Renamer: Run with the command line or via Alfred to give your images better titles.
View screenshot-renamer.sh
#!/bin/bash
cd /Users/markkoester/Desktop/
clipboard=''
NL=$'\n'
for f in Screenshot*.png ; do
if [ -f "$f" ]
then
filedatetime=$(stat -f '%Sm' -t '%Y%m%d%H%M.%S' "$f")
mv "$f" $filedatetime.png
# $(exiftool -d "%Y%m%d%H%M.%S" -CreateDate "$f" | awk '{print $4".png"}')"
@markwk
markwk / readings-tracker.sh
Last active Apr 7, 2019
Readings Files Tracker: Ebooks and PDFs Files Tracking, including number of files tagged with blue, red, etc.
View readings-tracker.sh
# !/bin/bash
#############################
# Readings Tracker
#
# Watch Directories of Articles and Book Files for new and modified files
#
# (Mac) Track Tagged PDF and other Files using command line tool Tag: https://github.com/jdberry/tag
#
# Data Tracking and Log Files
DATA_FILE="/Users/user/Development/data/files-reading-stats.csv"
@markwk
markwk / zettel_identifier_note_creator.bash
Created Feb 11, 2019
Generate a unique identifier for plain text file names, including optional title and opening in target app
View zettel_identifier_note_creator.bash
#!/bin/bash
#
# Bash script to generate a unique identifier for file name
# Used for a Plain Text Writing, Knowledge or Notes System
#
# Allows for following Options:
# -o: opening file in a target program
# Additional Title or name appended to end of file name
#
# Examples
@markwk
markwk / daily_morning_pages_template_note.sh
Created Nov 25, 2018
Generate plain text markdown file for morning pages.
View daily_morning_pages_template_note.sh
#!/bin/bash
# Bash script to generate a daily morning pages template
# includes file name and various date references
cd /Users/markkoester/Library/Mobile\ Documents/9CR7T2DMDG~com~ngocluu~onewriter/Documents/Notes_TheArchive
file_date=$( date '+%Y-%m-%d' )
filename="mp_$file_date.md" # prepending mp to files named according to date.
if [ -f $filename ]
@markwk
markwk / writings-tracking-with-git.bash
Last active Nov 22, 2018
My Writings Tracker with Git: A bash script for tracking my writings in plain tex files, calculate stats like word count, hashtags and new files, store stats to csv and commit to git.
View writings-tracking-with-git.bash
#!/bin/bash
##################################
#
# THE ARCHIVE TRACKER
#
# REF: https://gist.github.com/markwk/c85a8a72bc8c03d0f510262bb5219a34/
#
# INTRODUCTION:
# Daily script to navigate to a directory of plain text files,
# add files to git repo, calculate key stats, store stats to csv
@markwk
markwk / reboot_ec2.py
Created Nov 17, 2018
Reboot an ec2 instance using python and boto3
View reboot_ec2.py
# -*- coding: utf-8 -*-
##############################################
# Reboot an ec2 instance using python and boto3
#
# Boto3 Documenation Reference:
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.reboot_instances
##############################################
import boto3
s3 = boto3.client(
@markwk
markwk / rescuetime_running.py
Created Oct 31, 2018
Python Script for Mac to Check if a process is running. If not, restart and post a notification.
View rescuetime_running.py
#!/usr/bin/env python
"""
Check to see if an process is running. If not, restart.
Run this in a cron job
"""
import os
import subprocess
# notification via osascript
# TODO: Is there a better way to do this?
@markwk
markwk / read_daily_word_count_scores.py
Created Dec 7, 2017
Scripts for Stats from WordCounter App for Mac
View read_daily_word_count_scores.py
# Python Script for Word Counter for Mac
# Collects Daily Score
import plistlib
import os
import time
def add(x, y): return x + y
today = time.strftime("%Y-%m-%d")
@markwk
markwk / local.settings.php
Created Sep 28, 2011
Adds multilingual variables
View local.settings.php
/**
* Multilingual settings
*
* This is a collection of variables that can be set up for each language when i18n is enabled.
* These are the basic ones for Drupal core, but you can add your own here.
*/
$conf['i18n_variables'] = array(
// Site name, slogan, mission, etc..
'site_name',
'site_slogan',
You can’t perform that action at this time.