Skip to content

Instantly share code, notes, and snippets.

@superdaigo
superdaigo / conv2gif.sh
Last active June 21, 2023 02:34
Convert movie file to GIF animation using ffmpeg and jq
#!/usr/bin/env bash
# Convert movie file to GIF animation using ffmpeg and jq
set -e -o pipefail
MAX_WIDTH=1200
MAX_HEIGHT=1200
# ffprobe
stream_info=$(ffprobe -v quiet -print_format json -show_streams "$1")
width=$(echo "$stream_info" | jq '.streams[0].width')

Multiples of 3

If the natural number X is a multiple of 3, the summary of each digit number of X is a multiple of 3 too.

Example:

3 = 3 * 1; For single digit, it's ovbious that the result is multiple of 3.
@superdaigo
superdaigo / zabbix-alert-smtp.sh
Created September 20, 2012 04:58
Zabbix SMTP Alert script for gmail
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Zabbix SMTP Alert script for gmail.
"""
import sys
import smtplib
from email.MIMEText import MIMEText
from email.Header import Header
@superdaigo
superdaigo / iam-user-policies.sh
Last active February 21, 2022 10:23
Download all IAM user policies
#!/usr/bin/env bash
#
# Usage: iam-user-policies.sh USERNAME PROFILE_NAME
#
# Requirements:
# - jq
# - Able to use the profile passes as the 2nd parameter
set -euo pipefail
@superdaigo
superdaigo / block_apps_from_launching.mobileconfig
Last active February 7, 2022 01:13
Block mac apps from launching. Applications that unable to uninstall form mac can be blocked.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadType</key>
<string>com.apple.applicationaccess.new</string>
@superdaigo
superdaigo / org
Created December 4, 2019 15:09
IDEA - Setup MacOS Local Environment

To use Homebrew task in the Ansible, both Homebrew and Ansible should be installed in the system. That means at least Homebrew and Ansible must be installed using shell script. Following installation and configuration will be done by Ansible, so that the shell script can be use for up-to-date the local environment.

  1. Shell script
    1. Install homebrew
    2. Install ansible using homebrew
    3. Execute ansible
      • specifying /usr/local/bin/ansible to avoid PATH configured following ansible script
@superdaigo
superdaigo / tokyo_tour_2019-08-14.rst
Last active August 14, 2019 11:34
Googled Tokyo Tour for English speakers 2019-08-14
@superdaigo
superdaigo / gist:3719990
Created September 14, 2012 05:34
Homebrew OpenVPN
$ brew install openvpn
==> Installing openvpn dependency: lzo
==> Downloading http://www.oberhumer.com/opensource/lzo/download/lzo-2.06.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/lzo/2.06 --enable-shared
==> make
==> make check
==> make install
/usr/local/Cellar/lzo/2.06: 27 files, 552K, built in 27 seconds
==> Installing openvpn
#!/bin/bash
STOP_AT=$(date -j -v "+1H" "+%H:%M")
if [ ! -z $1 ] && [[ $1 =~ ^[0-9]{1,2}:[0-9]{2}$ ]] ; then
STOP_AT="${1}"
if [ ${#1} -eq 4 ] ; then
STOP_AT="0${1}"
fi
fi
echo "Will stop at ${STOP_AT}"
@superdaigo
superdaigo / Shonan Beach FM.asx
Created December 16, 2017 04:38
Japanese Internet Radio "Shonan Beach FM" https://www.beachfm.co.jp/
<Asx Version="3.0">
<Entry>
<Title>Shonan Beach FM 78.9</Title>
<author>Shonan Beach FM 78.9</author>
<copyright>Shonan Beach FM 78.9</copyright>
<ref href="mms://simul.freebit.net/shonanbeachfm"/>
<ref href="http://150.95.174.29:8000/by_the_sea"/>
</Entry>
</Asx>