Skip to content

Instantly share code, notes, and snippets.

@funasoul
funasoul / is_dropbox_running.sh
Last active December 2, 2021 17:28
Return 0 if dropbox is running.
is_dropbox_running() {
# Return 0 if dropbox is running.
# Thanks to Official Dropbox Command Line Interface.
# https://www.dropboxwiki.com/tips-and-tricks/using-the-official-dropbox-command-line-interface-cli
if [[ -r ~/.dropbox/dropbox.pid ]]; then
pid=$(cat ~/.dropbox/dropbox.pid)
else
return 1
fi
if [[ "$OSTYPE" == "linux-gnu" ]]; then
@funasoul
funasoul / get_nendo.sh
Created April 23, 2018 06:54
get current nendo
get_nendo() {
foreach i ({0..11}) [ ~ ]
local lmonth=`date -v-${i}m '+%m'`
if [ $lmonth = "04" ]; then
local nendo=`date -v-${i}m '+%Y'`
fi
end
echo "$nendo"
}
@funasoul
funasoul / every_weekday.py
Created January 9, 2018 11:06
Get list of given weekdays within the specified duration
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# -*- coding: utf-8 -*-
#
# Last modified: Tue, 09 Jan 2018 20:03:12 +0900
from dateutil import rrule
from datetime import datetime, time, timedelta
import locale
@funasoul
funasoul / spatial2gif.sh
Last active September 26, 2017 17:22
Create animated gif files from simulation results generated by SpatialSimulator
spatial2gif() {
# Create animated gif files from simulation results generated by [SpatialSimulator](https://github.com/funasoul/docker-spatialsim)
local width="400"
local opt_resize="${width}"
# -h, --help options
if [[ "$1" = "-h" || "$1" = "-help" || "$1" = "--help" || "$1" = "--h" ]]; then
echo "Usage: $0 [width] [height]"
echo " Create animated GIF files from simulation results generated by"
echo " SpatialSimulator."
echo " - [width] ... width of animated GIF file (default: $width)"
import datetime
today = datetime.date.today()
friday = today + datetime.timedelta( (4-today.weekday()) % 7)
for i in range(20):
s = friday.strftime(u'%Y年X%m月X%d日'.encode('utf-8')).decode('utf-8').replace('X0','X').replace('X','')
print s
friday = friday + datetime.timedelta(7)
#!/bin/zsh
#
# mpo2gif: Convert MPO file to animation GIF file.
#
# Author: Akira Funahashi <[email protected]>
# Requirement: exiftool (sudo port install p5-image-exiftool)
# ImageMagick (sudo port install ImageMagick)
# Usage: ./mpo2gif.sh file.mpo [output.gif]
#
# Reference:
@funasoul
funasoul / weather_stats_10.sh
Last active December 17, 2015 07:39
Weather stats for last 13 years (2000-) in Yokohama area (for Ogawa Cup 2013)
(( ynum = (`date +"%Y"` - 2000) * 2)); for i in {08..20}; do echo -n "9月${i}日"; curl -s "http://weather.goo.ne.jp/past/day_search.html?areacode=670&p_month=9&p_day=$i" | egrep 'weather_.\.gif' | head -$ynum | grep 'alt="雨"'| wc -l; done | sort -k 2
@funasoul
funasoul / diff.pl
Created December 28, 2012 06:38
Print diff between function a() and b() in foo.c file.
#!/usr/bin/env perl
#
# Last modified: Fri, 28 Dec 2012 15:37:46 +0900
#
# Usage: perl diff.pl foo.c func1 func2
# will compare func1() and func2() in foo.c
#
# Note: The function must finish with "}" at the beggining of line, like:
# int func(int a) {
# ...
#!/usr/bin/env perl
use strict;
use warnings;
use Net::Twitter::Lite;
use WWW::Mechanize;
use utf8;
binmode STDIN, ":utf8";
binmode STDOUT, ":utf8";
for i in {10..21}; do echo -n "9月${i}日"; curl -s "http://weather.goo.ne.jp/past/day_search.html?areacode=670&p_month=9&p_day=$i" | grep 'alt="雨"'| wc -l; done | sort -k 2