commit 079d8dec6f1637e577a35f0c0e35c415eab68920
parent 5eaf58b644c2c5d3e79f1e4b7c6a6551de341b41
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Thu, 15 Aug 2019 19:48:16 +0200
create_pocketbook_logo & google_hangouts_parser
Former-commit-id: 4458b0cbe1fb82444afdbf1bb294e6d7156c6c77
Diffstat:
3 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -16,6 +16,7 @@ If you read a script and see some improvements that could be made, let me know.
* `clonedisk`: clones one disk to another
* `colgen.rb`: a Ruby script to generate Vim colorschemes from a much simpler syntax file.
* `conf`: the script to manage dotfiles. run `conf` to show available commands.
+* `create_pocketbook_logo`: take an image and convert it into a logo for my PocketBook 603. Run with the `-h` flag for usage.
* `dashedit.rb`: script to allow Dash submissions from the commandline. Largely useless to anyone except me.
* `epr.py`: a [Python-based EPUB reader](https://github.com/wustho/epr)
* `epub-convert`: uses Calibre's ebook converter program to convert anything to an epub
@@ -23,6 +24,7 @@ If you read a script and see some improvements that could be made, let me know.
* `ffmpres`: ffmpeg presets for various files
* `ffmpeg-split.py`: split videos using ffmpeg. [Here's the README.](scripts/ffmpeg-split-README.md)
* `global-git-status`: git status of all of your cloned git repositories
+* `google_hangouts_parser.rb`: parse the JSON from google hangouts into a more coherent format. Go to a directory with a "Hangouts.json" file and run the script.
* `httpc`: an interactive http request console using httpie
* `it-style`: can find and set the genre in a track in iTunes (along with its Ruby helper), using the Discogs database (you need an API key, set $DISCOGS_API_TOKEN in your profile). Usage: click/play a track in iTunes, and run the program.
* `linkdir`: symlink all files/folders from source dir to target dir. Usage: `linkdir $source` to create symlinks in cwd, `linkdir $source $target` otherwise.
diff --git a/scripts/create_pocketbook_logo b/scripts/create_pocketbook_logo
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+if ! command -v convert &> /dev/null; then
+ echo "imagemagick not installed." >&2
+ exit 1
+fi
+
+PARAMS=""
+
+while (( "$#" )); do
+ case "$1" in
+ -p|--palette)
+ palette="$2"
+ shift 2
+ ;;
+ -o|--output)
+ outfile="$2"
+ shift 2
+ ;;
+ -h|--help)
+ echo "Usage:"
+ echo " create_pocketbook_logo [-p palette_file] input_file -o output_file"
+ exit 0
+ ;;
+ --) #end arg parsing
+ shift
+ break
+ ;;
+ -*|--*=) # unsupported
+ echo "Unsupported flag $1" >&2
+ exit 1
+ ;;
+ *) # preserve positional arguments
+ PARAMS="$PARAMS $1"
+ shift
+ ;;
+ esac
+done
+eval set -- "$PARAMS"
+
+[ -z "$outfile" ] && echo "No output file supplied." >&2 && exit 1
+[ -z "$1" ] && echo "No file supplied.">&2 && exit 1
+[ -z "$palette" ] && ! [ -d /Volumes/Pocket603 ] && echo "No palette present.">&2 && exit 1
+convert "$1" \
+ -background white \
+ -alpha remove \
+ -depth 8 \
+ -colors 256 \
+ -type grayscale \
+ -remap "${palette:-/Volumes/Pocket603/system/logo/1_st.603.bmp}" \
+ -dither FloydSteinberg \
+ -compress none BMP3:"$outfile"
diff --git a/scripts/google_hangouts_parser.rb b/scripts/google_hangouts_parser.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+require 'json'
+File.open("Hangouts.json") do |f|
+ t=JSON.parse(f.read)
+ t["conversations"].each do |conv|
+ sender_1 = { name: conv["conversation"]["conversation"]["participant_data"].first["fallback_name"], id: conv["conversation"]["conversation"]["participant_data"].first["id"] }
+ sender_2 = { name: conv["conversation"]["conversation"]["participant_data"][1]["fallback_name"], id: conv["conversation"]["conversation"]["participant_data"][1]["id"] }
+ puts "#{sender_1[:name]} & #{sender_2[:name]}"
+ conv['events'].each do |evt|
+ evt['chat_message']['message_content']['segment'].each do |seg|
+ print "#{(sender_1[:id] == evt['sender_id'] ? sender_1[:name].split.first : sender_2[:name].split.first)}: "
+ puts seg['text']
+ end
+ end
+ 10.times { print "#" }
+ puts
+ end
+end