Skip to content

Instantly share code, notes, and snippets.

@toshinarin
toshinarin / convert-flac-to-alac.sh
Created July 28, 2020 06:26
Convert flac to alac
find . -type f -name "*.flac" | while read f; do ffmpeg -i "$f" -vsync 0 -c:v png -c:a alac "${f%.flac}.m4a"; done
@toshinarin
toshinarin / nature-remo-e.30s.sh
Last active June 21, 2020 00:50
Bitbar plugin to show current power consumption with Nature Remo E
#!/bin/bash
# Preparation: Please install jq with homebrew
# API Reference: https://developer.nature.global/
# Get token from https://home.nature.global/
token="${NatureAPIToken}"
# Get id from `GET /1/appliances` API
# https://swagger.nature.global/
appliancesId="${NatureRemoEApplianceId}"
Array.from(document.querySelectorAll('.markdown-body details')).forEach((obj, idx) => { obj.open = true; });
@toshinarin
toshinarin / convert_png_to_jpg.sh
Created March 22, 2018 06:31
Convert png files to jpg
#!/bin/bash
for file in `\find . -maxdepth 2 -name '*.png'`; do
convert $file -quality 90 ${file%.*}.jpg
done
@toshinarin
toshinarin / iterate_over_elements.js
Created October 6, 2017 02:52
Iterate over elements
Array.prototype.forEach.call(document.querySelectorAll('.someClass'), function(node) {
console.log(node)
});
@toshinarin
toshinarin / rename_file.sh
Last active September 7, 2017 00:23
Renaming files to sequential numbers
#!/bin/bash
# Reference: https://www.raspberrypi.org/forums/viewtopic.php?t=72435
# https://stackoverflow.com/questions/3211595/renaming-files-in-a-folder-to-sequential-numbers
ls -l *.jpg | awk '{print $NF}' | gawk 'BEGIN{ a=1 }{ printf "mv %s %06d.jpg\n", $0, a++ }' | bash
#!/bin/bash
FILENAME=$1
if [ ! -n "${FILENAME}" ]; then
echo "Please specify input file"
exit 1
fi
ffmpeg -y -i ${FILENAME} -preset slower -c:v libx264 -b:v 320k -pass 1 -an -f mp4 /dev/null && ffmpeg -y -i ${FILENAME} -c:v libx264 -preset slower -b:v 320k -pass 2 -an "${FILENAME%.*}.mp4"
@toshinarin
toshinarin / check-chatwork-unread-count.10s.py
Last active March 16, 2016 06:43
BitBar plugin for check unread count of ChatWork
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# <bitbar.title>ChatWork unread count check</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>toshinarin</bitbar.author>
# <bitbar.author.github>toshinarin</bitbar.author.github>
# <bitbar.desc>This plugin displays my unread count of ChatWork.</bitbar.desc>
# <bitbar.image>https://www.chatwork.com/imagenew/all/common/logo/img_logo_chatwork.svg?1458088542</bitbar.image>
# <bitbar.dependencies>python</bitbar.dependencies>
var e=document.createEvent('MouseEvents'),t=true,f=false;
e.initMouseEvent("click",t,t,window,0,0,0,20,10,f,f,f,f,0,null);
setInterval(function(){Array.prototype.forEach.call(document.querySelectorAll('#box span'),function(n){
n.dispatchEvent(e);
})},4);
@toshinarin
toshinarin / download_asana_task_attachments.sh
Last active August 29, 2015 14:14
downloader for attachments of an asana task
#!/bin/bash
if [ $# -ne 3 ]; then
echo "Please specify asana API key, dest dir, task id." 1>&2
exit 1
fi
API_KEY=$1
TASK_ID=$3
SAVE_DIR="${2}/task_${TASK_ID}"