Skip to content

Instantly share code, notes, and snippets.

View tenomoto's full-sized avatar

Takeshi Enomoto tenomoto

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / mayavi_transparent_background.py
Created November 22, 2017 07:41
Mayavi transparent background
# https://stackoverflow.com/questions/23703417/can-mayavi-render-a-figure-scene-with-a-transparent-background
import numpy as np
from mayavi import mlab
import matplotlib.pyplot as plt
d = 3
n = 100
x = np.arange(-d, d, 2 * d / n)
y = np.arange(-d, d, 2 * d / n)
@tenomoto
tenomoto / read_automountdisk.sh
Created December 12, 2017 05:03
Examine if Mac mounts disks without user login
defaults read /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisksWithoutUserLogin
@tenomoto
tenomoto / .maintenance
Created December 24, 2017 05:22
Set WordPress into maintenance mode
<?php
// https://wordpress.stackexchange.com/questions/211303/wp-cli-enabling-maintainance-mode
$upgrading = time();
@tenomoto
tenomoto / rotate.ncl
Last active January 9, 2023 01:20
Calculate tangential and radial winds by locating the typhoon centre at the North Pole
pi = acos(-1.0)
tau = 2 * pi
deg2rad = pi / 180.0
rad2deg = 180.0 / pi
procedure lonlat2xyz(lon, lat, x, y, z)
begin
x = cos(lon) * cos(lat)
y = sin(lon) * cos(lat)
z = sin(lat)