Skip to content

Instantly share code, notes, and snippets.

@tsuchm
tsuchm / debian10.patch
Created August 20, 2019 08:16
Patch to build TensorFlow 1.12 for Python3.7 on Debian10. For more detail, see https://qiita.com/tsuchm/items/60e071c7e77428f5d335
diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
index aaea475c04..a860e8a107 100755
--- a/tensorflow/workspace.bzl
+++ b/tensorflow/workspace.bzl
@@ -381,11 +381,11 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
)
PROTOBUF_URLS = [
- "https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz",
- "https://github.com/google/protobuf/archive/v3.6.0.tar.gz",
@tsuchm
tsuchm / cupsyslog
Last active October 23, 2019 12:49
CUPS backend script to count print pages. For more detail, see https://qiita.com/tsuchm/items/de3a28c6cf6293e0cfa3

NAME

cupsyslog

DESCRIPTION

This script works as an backend of CUPS, which counts how many pages included in a given printing document and sends the accounting

@tsuchm
tsuchm / fonts.conf
Created August 12, 2019 01:28
Specify fonts for PDF files whose Japanese fonts are not embedded.
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- http://debian.fam.cx/index.php?cmd=read&page=Software%2Ffontconfig -->
<!-- ディフォルトの表示フォントの選択 -->
<alias>
<family>serif</family>
<prefer>
<family>TakaoPMincho</family>
</prefer>
@tsuchm
tsuchm / lame-deletagion-checker.pl
Last active August 6, 2019 08:59
Simple script to check DNS health
#!/usr/bin/perl
=head1 NAME
lame-delegation-checker
=head1 SYNOPSIS
このスクリプトは,あるパターンの lame delegation を検出することを目標として作成されている.
ゾーンファイルを直接読むことができる権威 DNS サーバ上で実行することが想定されている.
@tsuchm
tsuchm / modify-mailcap-mime-data.el
Created July 28, 2019 12:35
Use neither doc-view-mode or gimp to display application/pdf part
(eval-after-load "mailcap"
'(setq mailcap-mime-data
(mapcar
(lambda (data)
(cons (car data)
(delq nil
(mapcar
(lambda (pair)
(let ((viewer (cdr (assq 'viewer (cdr pair)))))
(cond
@tsuchm
tsuchm / Template.pm
Created July 18, 2019 02:45
Extension of HTML::Template.pm to use objects which have param() accessor as loop parameters
# -*- mode: perl; coding: utf-8; -*-
package My::HTML::Template;
use Encode qw/ decode_utf8 /;
use UNIVERSAL;
use base qw/ HTML::Template /;
use utf8;
use strict;
use warnings;
=head1 NAME
@tsuchm
tsuchm / my-replace-heisei.el
Last active May 10, 2019 01:31
平成〇〇年表記を西暦表記に変換する
(defun my-replace-heisei ()
(interactive)
(while (re-search-forward "\\(H\\|平成?\\)\\([0-9][0-9]\\)\\([$.]\\|年\\)" nil t)
(let ((year (+ (string-to-number (match-string 2)) 1988)))
(goto-char (match-beginning 0))
(delete-region (match-beginning 0)
(if (string-equal (match-string 3) "年")
(match-end 3)
(match-end 2)))
(insert (format "%d年" year)))))
@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 {
@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
# -*- 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()