Skip to content

Instantly share code, notes, and snippets.

View tex2e's full-sized avatar
🕶️
Ready to engage

Mako tex2e

🕶️
Ready to engage
View GitHub Profile
@tex2e
tex2e / setup.sh
Created January 12, 2018 07:27
Install texlive with tlmgr
#!/bin/bash
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar xvf install-tl-unx.tar.gz
cd install-tl-*
sudo ./install-tl
# export PATH="$PATH:/usr/local/texlive/2017/bin/x86_64-linux"
sudo tlmgr path add
sudo tlmgr install --self --all
sudo tlmgr install \
collection-langjapanese \
nag here \
newtx txfonts helvetic fontaxes boondox \
kastrup tex-gyre \
standalone multirow letltxmacro \
beamer bxdpx-beamer pgfplots \
refcheck
@tex2e
tex2e / DictDiffer.py
Created March 2, 2018 02:25
Calculate the difference between two dictionaries
class DictDiffer(object):
"""
Calculate the difference between two dictionaries as:
(1) items added
(2) items removed
(3) keys same in both but changed values
(4) keys same in both and unchanged values
"""
def __init__(self, current_dict, past_dict):
@tex2e
tex2e / main.py
Created September 17, 2018 06:36
command line waiting animation
import time
import threading
class WaitingAnimation:
def __init__(self):
self.finished = False
def animation(self):
animation = "|/-\\"
@tex2e
tex2e / get_ip_address.py
Last active December 13, 2018 09:59
get ip address of interface + smtplib sends with given source_address in python2
import socket
import fcntl
import struct
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
@tex2e
tex2e / make_bound_socket.py
Created December 13, 2018 10:07
make bound socket with source_addr
import socket
import urllib2
true_socket = socket.socket
def make_bound_socket(source_ip):
def bound_socket(*a, **k):
sock = true_socket(*a, **k)
sock.bind((source_ip, 0))
return sock
return bound_socket
@tex2e
tex2e / binaryGCD.py
Created December 30, 2018 00:36
binary GCD (バイナリ・ユークリッドの互除法)
# https://en.wikipedia.org/wiki/Binary_GCD_algorithm
def binary_gcd(a, b):
g = 1
odd = 1
while a > 0:
if (a & odd) == 0 and (b & odd) == 0:
a >>= 1 # g /= 2
b >>= 1 # b /= 2
g <<= 1 # g *= 2
@tex2e
tex2e / config
Created January 14, 2019 12:07
多段ssh
# ~/.ssh/config
Host local1
Port 22
HostName 127.0.0.1
User root
Host local2
Port 22
HostName 192.168.1.2
@tex2e
tex2e / ifcfg-enp0s8
Created January 14, 2019 12:17
centos7 network config on virtual box
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=enp0s8
DEVICE=enp0s8
ONBOOT=yes
ZONE=public
@tex2e
tex2e / ntt-poly-verify.py
Last active May 23, 2019 13:22
数論変換 (NTT) による有限体上の多項式環の乗算:p1, p2 ∈ Z_337[x] / (x^9 + 1)
# 答えの確認用
import numpy as np
p = 337
f = np.poly1d([1,0,0,0,0,0,0,0,1])
p1 = np.poly1d([334, 180, 335, 283, 72, 123, 112, 19])
p2 = np.poly1d([325, 304, 135, 76, 127, 83, 191, 272])