Skip to content

Instantly share code, notes, and snippets.

@fjkz
fjkz / deploy.py
Created April 21, 2015 15:44
FTP deployer
#!/usr/bin/env python
import argparse
from ftplib import FTP
host = 'HOSTNAME'
user = 'USERNAME'
passwd = 'PASSWORD'
parser = argparse.ArgumentParser(
description='Put a file to the FTP server.')
@fjkz
fjkz / ca.py
Created April 22, 2015 13:22
1D cellular automaton in terminal
#!/bin/python3
from termcolor import colored
import os
import random
import sys
import time
def black_or_white(cell):
if cell > 0:
@fjkz
fjkz / mandel.py
Created April 29, 2015 20:19
Mandelbrot set drawer
from sys import argv
from math import sqrt, pi, tan, atan2
def mandelbrot(r, i):
limit = 256
threshold = 1e10
zr = 0.0
zi = 0.0
for n in range(limit):
@fjkz
fjkz / settings.json
Last active October 6, 2015 02:13
A configuration of Visual Studio Code.
// Configurations of Visual Studio Code.
{
//-------- Editor configuration --------
// Controls the font family.
"editor.fontFamily": "源ノ角ゴシック Code JP",
// Controls the font size.
"editor.fontSize": 12,
@fjkz
fjkz / paxos.py
Created October 10, 2015 15:28
A simple Paxos implementation for study.
"""
A simple Paxos implementation for study.
"""
from collections import Counter
class Proposer:
def __init__(self, acceptors):
self.acceptors = acceptors
@fjkz
fjkz / create_rootfs.sh
Last active November 30, 2022 22:59
Create a rootfs environment for chroot building.
#!/bin/sh
#
# Create a rootfs environment for chroot building.
#
# Requires
# - OS installing CDROM at the current directory,
# - the root authority.
#
# mount install cd
@fjkz
fjkz / kdv.py
Created May 11, 2016 10:26
KdV equation solver with pseudo-spectrum method
#!/usr/bin/env python3
"""
KdV equation solver
"""
from numpy import pi, cos, linspace, arange
from numpy.fft import rfft, irfft
# Constant in Zabusky & Kruskal (1965)
@fjkz
fjkz / oxgame.py
Created May 29, 2016 13:48
A maru-batu game (tic tac toe) solver Raw
#!/usr/bin/env python3
from copy import deepcopy
from enum import Enum
from random import shuffle
class Simbol(Enum):
empty = 0
maru = 1
batu = 2
@fjkz
fjkz / gitdiff.py
Created October 8, 2016 04:26
Git interface to Python difflib module
#!/usr/bin/env python3
"""
Git interface to difflib.py
"""
import sys
import os
import time
import difflib
import re
@fjkz
fjkz / SshClient.java
Created February 23, 2020 04:15
Builder pattern
class SshClient {
SshClient(String user, String host, int port, int timeout) {
// ...
}
SshClient(String user, String host) {
this(user, host, 22, 60);
}
SshClient(String user, String host, int port) {