Skip to content

Instantly share code, notes, and snippets.

@tsuchm
tsuchm / azure-cli.yml
Last active March 9, 2020 02:48
Ansible task file to install Azure CLI
# Ansible task to install Azure CLI.
# These steps are re-implementation of the procedure descrbed at
# https://docs.microsoft.com/cli/azure/install-azure-cli-apt
- name: Install packages required by Azure CLI
apt:
name: ['ca-certificates', 'curl', 'apt-transport-https', 'lsb-release', 'gnupg']
state: present
- name: Add Azure CLI repository key
from chainer import function, training
from chainer import reporter as reporter_module
from chainer.dataset import convert
from collections import defaultdict
class PreciseEvaluator(training.extensions.Evaluator):
""":class:`chainer.training.extensions.Evaluator` module uses
:func:`chainer.reporter.compute_mean` to calculate the mean
accuracy and the mean loss over the multiple mini batches.
@tsuchm
tsuchm / mecab_swig.diff
Created January 17, 2020 09:29
Enforce to use bytes for MeCab even if Python3 is used
--- a/swig/MeCab.i
+++ b/swig/MeCab.i
@@ -3,6 +3,7 @@
%{
#include "mecab.h"
+#define SWIG_PYTHON_STRICT_BYTE_CHAR
/* Workaround for ruby1.9.x */
#if defined SWIGRUBY
#include "ruby/version.h"
@tsuchm
tsuchm / error.log
Created January 17, 2020 08:59
error message when building mecab package from salsa git repo
$ git clone [email protected]:nlp-ja-team/mecab.git
$ cd mecab
$ gbp buildpackage -us -uc --git-dist=stable --git-arch=amd64
(snip)
dpkg-genchanges: warning: debian/changelog(l8): found end of file where expected more change data or trailer
dpkg-genchanges: warning: unknown information field '' in input data in parsed version of changelog
dpkg-genchanges: error: unknown is not a valid version
dpkg-buildpackage: error: dpkg-genchanges subprocess returned exit status 2
@tsuchm
tsuchm / ldapsearch.sh
Created December 10, 2019 00:18
ldapsearch with Base64 decode
#!/bin/sh
/usr/bin/ldapsearch -o ldif-wrap=no "$@" | perl -MMIME::Base64 -Mutf8 -pe 's/^([-a-zA-Z0-9;]+):(:\s+)(\S+)$/$1.$2.&decode_base64($3)/e'
@tsuchm
tsuchm / DKIMModerate.py
Created December 6, 2019 09:16
Mailman module to allow posts of DKIM-signed messages which sent from specific domains
# Copyright (C) 2019 by TSUCHIYA Masatoshi <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@tsuchm
tsuchm / openssl.cnf.diff
Created December 4, 2019 14:33
Adhoc change to avoid "SSL connect attempt failed error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small" error
--- /etc/ssl/openssl.cnf
+++ /etc/ssl/openssl.cnf
@@ -359,4 +359,4 @@ system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1.2
-CipherString = DEFAULT@SECLEVEL=2
+#CipherString = DEFAULT@SECLEVEL=2
case "$1" in
*/*)
executable=`readlink -f $1`
;;
*)
executable=`pwd`/$1
;;
esac
echo ${executable}
@tsuchm
tsuchm / Dockerfile
Created October 24, 2019 07:11
Dockerfile to build a container environment which is similar to a login server
FROM centos:centos7
RUN yum update -y
RUN yum install epel-release centos-release-scl -y
# yum groupinstall "Development Tools" causes an error, described at https://qiita.com/madaran0805/items/1cac9c921cec4e8a23e7
RUN yum groupinstall base "Development Tools" --setopt=group_package_types=mandatory,default,optional -y
RUN yum install \
tcsh \
@tsuchm
tsuchm / ntp-or-chrony-playbook.yml
Last active October 18, 2019 04:40
Ansible playbook to install NTP or Chrony
- name: Decide whether ntp or chrony is used for the target
set_fact:
use_chrony: true
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version >= '7'
- name: Install either ntp or chrony
package:
name: >-
{%- if use_chrony is defined -%}chrony
{%- else -%}ntp