Skip to content

Instantly share code, notes, and snippets.

@tsuchm
tsuchm / intel-mkl.yml
Last active August 12, 2019 07:59
Ansible playbook to install Intel MKL debian package (for Buster)
- name: Add Intel-MKL packages
apt:
name: intel-mkl
state: latest
- name: Install python3-pip
apt:
name: ['python3-pip',
'python3-setuptools',
'python3-numpy',
@tsuchm
tsuchm / git-lfs.yml
Last active June 17, 2019 21:31
Ansible playbook to install Git-LFS debian package
# For more detail, see https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh
# Because Git-LFS repository use HTTPS, apt-transport-https package is necessary.
- name: Install apt-transport-https
apt: name=apt-transport-https state=present
- name: Add Git-LFS repository key
apt_key:
url: https://packagecloud.io/github/git-lfs/gpgkey
state: present
#!/bin/bash
# The recent Windows 7 checks the model version of the CPU, and complains that Windows Update
# is unavailable when the modern CPU is installed.
# In order to avoid this problem, the method to change the CPU ID which is described at
# https://superuser.com/questions/625648/virtualbox-how-to-force-a-specific-cpu-to-the-guest
# is insufficient based on my experience.
# In order to avoid this problem, the method to specify the CPU profile which is described at
#!/bin/sh
# Usage: Put this script under /etc/cron.daily/.
set -e
PATH=/bin:/usr/bin:/usr/sbin:/sbin
src_vol=/dev/vg1/lv1
snap_vol=${src_vol}_snap
#!/usr/bin/python3
import pyknp
import re
# singleton pattern
class KNP:
_instance = None
_knp = None
def __new__(cls):
#!/usr/bin/python3
# When # of process is equal to 1:
# real 13m6.743s
# user 0m8.840s
# sys 0m0.308s
# When # of processes is equal to 2:
# real 6m33.596s
# user 0m9.284s
@tsuchm
tsuchm / cabocha-client.pl
Created November 28, 2018 04:40
Server and Client of CaboCha
#!/usr/bin/perl
# 指定された文を cabocha-server.pl を使って構文解析する
# libwww-perl <URL: http://search.cpan.org/~gaas/libwww-perl/> のイン
# ストールが必要.
use Getopt::Long;
use LWP::UserAgent;
use strict;
# -*- encoding: utf-8 -*-
import argparse
import sys
def parse_args():
p = argparse.ArgumentParser()
p.add_argument('inputs', type=str, nargs='*', help='[input] text files')
return p.parse_args()
@tsuchm
tsuchm / sample.tex
Last active February 12, 2025 03:58
LaTeX macro to print an equation number if and only if the label of the equation is referred
\documentclass{jarticle}
\makeatletter
\let\referred@@ref\ref
\let\referred@@label\label
\def\labelmarkasreferred#1{\global\@namedef{referred@#1}{\relax}}
\def\ref#1{\referred@@ref{#1}\protected@write\@auxout{}{\string\labelmarkasreferred{#1}}}
\def\label#1{\def\referred@@currentlabel{#1}\referred@@label{\referred@@currentlabel}}
\def\equation{$$\refstepcounter{equation}\def\referred@@currentlabel{}}
\def\endequation{
\ifcsname referred@\referred@@currentlabel\endcsname \eqno \hbox{\@eqnnum}\else\addtocounter{equation}\m@ne\fi
@tsuchm
tsuchm / GetHeaders.java
Created April 25, 2019 01:49
Sample code to use Shibboleth authentication information on Java servelet
import java.util.*;
import java.net.URLDecoder;
import javax.servlet.*;
import javax.servlet.http.*;
public class GetHeaders extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {