Skip to content

Instantly share code, notes, and snippets.

View tenomoto's full-sized avatar

Takeshi Enomoto tenomoto

View GitHub Profile
@tenomoto
tenomoto / gantt.tex
Last active October 12, 2017 07:21
pgfgantt
\documentclass[11pt,a4paper,uplatex,dvipdfmx]{ujarticle}
\usepackage{pgfgantt}
\begin{ganttchart}[
hgrid, vgrid,
y unit chart = 0.8cm,
title height = 1,
y unit title = 0.6cm]{1}{24}
\gantttitle{H30}{12} \gantttitle{H31}{12}\\
\gantttitlelist{4,...,12}{1} \gantttitlelist{1,2,3}{1}
@tenomoto
tenomoto / img2mov
Created August 2, 2017 05:04
Applescript to create mov from image sequence
tell application "QuickTime Player 7"
activate
set firstFile to choose file with prompt "Choose first image"
open image sequence firstFile seconds per frame 2
-- open image sequence firstFile frames per second 2
save document 1 as self contained
end tell
@tenomoto
tenomoto / pdf2png
Created August 2, 2017 04:49
Split pdf or ps to png for animation
#! /bin/bash
#
# synopsis: pdf2ps foo.pdf
#
FILENAME=$1
case $0 in
*pdf2png) DIRNAME=${1%.pdf};;
*ps2png) DIRNAME=${1%.ps};;
esac
OPTS="-trim $2"
@tenomoto
tenomoto / addpage.sh
Created May 25, 2017 07:39
Add page to PDF files and generate table of contents
#/bin/sh
in=$1
n=$2
sed -e "
s|N|${n}|
s|PDF|${in}|
" template.tex > foo.tex
pdflatex foo
@tenomoto
tenomoto / run_pdffonts.sh
Created May 25, 2017 07:21
Find and move PDF files without embedded fonts
#!/bin/sh
if [ ! -d pdf ]; then
echo "put PDF in pdf"
fi
if [ ! -d pdf_not_embedded ]; then
mkdir pdf_not_embedded
fi
cd pdf
for f in *.pdf; do
isEmb=`pdffonts ${f} | awk '$4=="no" {print "no"}'`
@tenomoto
tenomoto / natural_scrolling
Last active May 5, 2017 10:06
Natural (reverse) scrolling of mouse wheel using xinput
# xinput set-prop device property value [...]
# device: 10 indentified with `xinput list`
# property: 272 or Evdev Scrolling Distance indentified with `xinput list-props device`
# value: -1 1 1 changed from 1 1 1
$ xinput set-prop 10 272 -1 1 1
@tenomoto
tenomoto / cleancsv.awk
Created November 16, 2016 05:13
Remove paired double quotes and commas in between
#!/usr/bin/awk -f
# http://unix.stackexchange.com/questions/48672/remove-comma-between-the-quotes-only-in-a-comma-delimited-file
BEGIN {
FS = "\""
OFS = ""
}
{
for (i = 2; i <= NF; i += 2) {
gsub(",", "", $i)
}
@tenomoto
tenomoto / incrh
Created September 15, 2016 04:16
increment hour using date command
#!/bin/sh
incrh () {
# Arguments
# 1: yyyymmddhh
# 2: dh
yyyymmddhh=$1
dh=$2
hour2sec=3600
t0=`date -jf "%Y%m%d%H%M%S" ${yyyymmddhh}0000 "+%s"`
dh=`expr $dh \* $hour2sec`
@tenomoto
tenomoto / mum.m
Created July 12, 2016 08:29
Calculate the most developing wave number in the Eady problem
#!/usr/bin/env octave -qf
function y = f(x)
# the maximum of kci = sqrt((mu/2 - tanh mu/2)(mu/2 - cot mu/2)) is found by
# finding the zero of the derivative of the inside of sqrt.
y = x - (tanh(0.5*x) + coth(0.5*x)) - 0.5 * x * (1/(cosh(0.5*x))^2 - 1/(sinh(0.5*x))^2);
endfunction
format long
fsolve("f", 3.2)
@tenomoto
tenomoto / muc.m
Created July 12, 2016 08:22
Calculate the critical value for the non dimensional wave number in the Eady problem
#!/usr/bin/env octave -qf
function y = f(x)
y = coth(0.5*x) - 0.5*x;
endfunction
format long
fsolve("f", 1.0)