Skip to content

Instantly share code, notes, and snippets.

View uchida's full-sized avatar

Akihiro Uchida uchida

View GitHub Profile
@uchida
uchida / load_complex.py
Created September 6, 2012 06:54
sample shot how to load from the complex number array saved with iostream such as (x, y) for x + y i by numpy.loadtxt
import sys
import numpy
array = numpy.loadtxt("test.npy", converters={0: lambda s: eval(s)}).view(complex).reshape(-1)
print array
@uchida
uchida / rand.cpp
Created September 14, 2012 05:31
boost random distribution usage sample
#include <iostream>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_real_distribution.hpp>
#include <boost/random/normal_distribution.hpp>
int main(int argc, char* argv[])
{
size_t seed = 1234567890;
@uchida
uchida / fill.py
Created October 26, 2012 08:56
hist like plot with stepfilled
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
from matplotlib import pyplot as plt
histc = np.loadtxt("test.npy")
n_bins = histc.size
edges = np.linspace(-5, 5, n_bins)
edges2 = np.repeat(histc, 2)[1:-1]
histc2 = np.repeat(histc, 2)[:-2]
@uchida
uchida / macro.js
Created November 2, 2012 12:28
mathjax config sample to use personal macros
MathJax.Hub.Config({
TeX: {
Macros: {
dif: ["\\frac{d{#1}}{d{#2}}", 2],
pdif: ["\\frac{\\partial{#1}}{\\partial{#2}}", 2],
Tr: "\\mathop{\\rm Tr}\\limits",
real: "\\mathop{\\rm Re}\\nolimits",
imag: "\\mathop{\\rm Im}\\nolimits",
Res: "\\mathop{\\rm Tr}\\limits",
sn: "\\mathop{\\rm sn}\\nolimits",
@uchida
uchida / texmacro.rst
Created November 3, 2012 03:04
Sphinx + MathJax で自作 TeX マクロを使う

Sphinx + MathJax で自作 TeX マクロを利用する

sphinx の mathjax 拡張に手を加えて簡単な TeX マクロを使えるようにしてみました。

使い方

  1. 改造した mathjax.py を conf.py のある場所に置く
@uchida
uchida / class_dlitems.py
Created November 11, 2012 16:51
classify download items into date directories
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# classify downloaded items into date directory
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
import os
import time
import shutil
import itertools
from datetime import datetime
@uchida
uchida / 20121227.rst
Last active December 10, 2015 05:08
@uchida
uchida / proxy.pac
Last active December 10, 2015 22:38
A proxy script for Ritsumeikan University with some private address handling
function FindProxyForURL(url, host) {
var proxy = "PROXY proxy.ritsumei.ac.jp:3128";
var domain = ".ritsumei.ac.jp";
if (dnsDomainIs(host, domain) ||
isPlainHostName(host) ||
isInNet(host, "127.0.0.1", "255.255.255.255") ||
isInNet(host, "192.168.0.0", "255.255.0.0") ||
isInNet(host, "172.16.0.0", "255.240.0.0") ||
isInNet(host, "10.0.0.0", "255.0.0.0"))
return "DIRECT";
@uchida
uchida / Tweaks.rst
Last active January 1, 2021 04:35
Sphinx と LaTeX を使うときの 小技

Sphinx と LaTeX を使うときの 小技

著者:打田 旭宏
ライセンス:CC-BY 3.0
更新日時:|time|

Sphinx の LaTeX 出力を利用するときに見栄えを凝るのに知っておくとよいかもしれない小技をまとめました。

@uchida
uchida / uninstall_mactex.sh
Last active October 9, 2025 17:16
MacTeX uninstaller script based on pkgutil command
#!/bin/bash
# MacTeX uninstaller script based on pkgutil command
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
IFS=$(echo -en "\n")
for pkg in $(pkgutil --pkgs|grep org.tug.mactex); do
volume="$(pkgutil --pkg-info "$pkg"|grep volume|cut -d' ' -f2-)"
location="$(pkgutil --pkg-info "$pkg"|grep location|cut -d' ' -f2-)"
echo "remove all of the files installed under the $pkg"
for file in $(pkgutil --files "$pkg"); do