Skip to content

Instantly share code, notes, and snippets.

@momijiame
momijiame / jobrunner.py
Created July 4, 2016 03:07
特定の時刻にジョブを実行する
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from abc import ABCMeta
from abc import abstractmethod
from datetime import datetime
from threading import Thread
import threading
import time
@momijiame
momijiame / Vagrantfile
Created August 12, 2016 06:37
Vagrantfile for Docker Swarm
Vagrant.configure("2") do |config|
(1..3).each do |i|
config.vm.define "node#{i}" do |node|
node.vm.hostname = "node#{i}.example.com"
node.vm.box = "bento/centos-7.2"
node.vm.network "private_network", ip: "192.168.33.1#{i}"
node.vm.provision :shell do |shell|
shell.path = "deploy.sh"
end
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import functools
import threading
import time
try:
# Python 3
from queue import Queue
@momijiame
momijiame / gnd.py
Created January 2, 2017 19:01
正規分布を描く
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
from matplotlib import pyplot as plt
def main():
x = np.arange(-5, 5.1, 0.1)
y = np.exp(-x ** 2 / 2) / np.sqrt(2 * np.pi)
@momijiame
momijiame / td.py
Created January 3, 2017 11:39
t 分布
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
from scipy import stats
from matplotlib import pyplot as plt
def main():
x = np.arange(-4, 4.1, 0.1)
@momijiame
momijiame / asyncioecho.py
Created March 28, 2017 08:06
asyncio の低レイヤーな API で書いたエコーサーバ
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import asyncio
import socket
# イベントループに使うオブジェクトを用意する
ev_loop = asyncio.get_event_loop()
# 接続してきたクライアントとの接続情報を格納する
connections = {}
@momijiame
momijiame / eventletecho.py
Created March 28, 2017 08:08
Eventlet を使って実装したエコーサーバ
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 標準ライブラリにモンキーパッチを当てる
# ブロッキング I/O を使った操作が裏側で全てノンブロッキング I/O を使うように書き換えられる
import eventlet
eventlet.monkey_patch()
def client_handler(clientsocket, client_address, client_port):
@momijiame
momijiame / Vagrantfile
Last active April 20, 2024 08:43
Vagrantfile for Hadoop Cluster with CentOS 7 and Hadoop 2.8.0 (3 hosts)
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :master, primary: true do |master|
master.vm.box = "bento/centos-7.3"
@momijiame
momijiame / Vagrantfile
Last active November 20, 2020 00:21
Vagrantfile for Spark 2.3 on YARN with CentOS 7 and Hadoop 2.8 (3 hosts)
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :master, primary: true do |master|
master.vm.box = "bento/centos-7.4"
@momijiame
momijiame / Vagrantfile
Last active August 9, 2024 10:06
Vagrantfile for Hadoop (3.3) Cluster with Hive (3.1)
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :master, primary: true do |master|
master.vm.box = "bento/rockylinux-9"