Skip to content

Instantly share code, notes, and snippets.

View giwa's full-sized avatar

Ken Takagiwa giwa

  • Nombre Premier
  • Tokyo
View GitHub Profile
@giwa
giwa / wikipedia2dic.py
Created October 5, 2015 07:21
wikipedia2dic.py
#coding:utf-8
import codecs
import re
import unicodedata
import sys
# wikipedia2csv.py
# ref
# http://aidiary.hatenablog.com/entry/20101230/1293691668
@giwa
giwa / file0.txt
Last active October 2, 2015 13:26
Load balancing using HAProxy for MQTT broker ref: http://qiita.com/giwa/items/5da37c3aca0aee75a628
apt-get install haproxy
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
class SimpleCallback implements MqttCallback {
@giwa
giwa / 0_reuse_code.js
Created September 28, 2015 12:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@giwa
giwa / file0.txt
Last active September 22, 2015 21:31
Upload a file to Dropbox ref: http://qiita.com/giwa/items/5c7c17f382d57e11405e
import sys
import os
import argparse
import dropbox
from dropbox.files import WriteMode
from dropbox.exceptions import ApiError
# Add OAuth2 access token here.
# You can generate one for yourself in the App Console.
@giwa
giwa / ansible_dir
Last active September 13, 2015 02:35
Ansible directory generator
#!/bin/sh
# Create directories for ansible
# .
# ├── common-roles/
# │ ├── base/
# │ │ ├── defaults/
# │ │ │ └── main.yml
# │ │ ├── files/
# │ │ │ ├── ...
# │ │ │ └── ...
@giwa
giwa / coroutine_comparison.py
Last active August 29, 2015 14:27
python async
import time
import asyncio
import threading
import numpy as np
def fib(n):
if n in (1, 2):
return 1
return fib(n - 1) + fib(n - 2)
@giwa
giwa / file0.txt
Created July 3, 2015 06:22
Explicit Congestion Notification(ECN) ref: http://qiita.com/giwa/items/43a2ecd1c0ce55d0345d
$ echo 1 > /proc/sys/net/ipv4/tcp_ecn
$ cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
$ wget http://www.apache.org/dyn/closer.cgi/spark/spark-1.4.0/spark-1.4.0.tgz
$ tar zxvf spark-1.4.0-bin-hadoop2.6.tgz