Skip to content

Instantly share code, notes, and snippets.

@nori3tsu
nori3tsu / JobQueue.js
Last active August 5, 2019 06:02
This is an example of job queue by JavaScript.
import * as log from 'loglevel'
export default class JobQueue {
constructor (name, options) {
this._name = name
this._queue = []
this._running = false
this._options = Object.assign({ interval: 1000 }, options)
}
@nori3tsu
nori3tsu / compat.py.patch
Created March 9, 2016 22:55
This is a patch to support the docker version 1.6.0 or greater for EB CLI 3.7.3.
--- compat.py.bk 2016-03-10 07:43:01.000000000 +0900
+++ compat.py 2016-03-10 07:45:42.000000000 +0900
@@ -29,7 +29,9 @@ def supported_docker_installed():
"""
try:
- return commands.version() >= SUPPORTED_DOCKER_V
+ # return commands.version() >= SUPPORTED_DOCKER_V
+ from distutils.version import LooseVersion
+ return LooseVersion(commands.version()) >= LooseVersion(SUPPORTED_DOCKER_V)
class StopWatch
def start
@start_time ||= Time.now
@stop_time = nil
self
end
def stop
@stop_time = Time.now
self
#import "Timer.h"
NSDate *startDate;
NSDate *endDate;
@implementation Timer
- (id)initWithStart {
self = [super init];
@nori3tsu
nori3tsu / roo-example.rb
Last active August 29, 2015 14:07
RubyのExcel操作ライブラリ'Roo'の実装例
require 'roo'
s = Roo::Excelx.new('test.xlsx')
s.default_sheet = s.sheets[0]
columns = ('A'..'Z')
rows = (1..10)
columns.each do |c|
rows.each do |r|
@nori3tsu
nori3tsu / mustache-example.rb
Last active August 29, 2015 14:07
Mustacheを1ファイルで実装する例
require 'mustache'
str = <<-EOT
a
b
c
EOT
lines = []
str.each_line do |line|
@nori3tsu
nori3tsu / MulticastNode.java
Last active August 29, 2015 14:07
マルチキャスト通信検証用
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
/**
* マルチキャスト通信検証用
* 各ホストでjarを起動してマルチキャスト通信が可能か検証する。
* $ java -jar multicast.jar [message]
*/
@nori3tsu
nori3tsu / CodePointUtils.java
Last active August 29, 2015 14:07
サロゲートペア操作クラス
public final class CodePointUtils {
private CodePointUtils() {
}
/**
* 文字列中のサロゲートペア文字を全て置換文字列に置換.
*
* @param str 文字列
* @param replacement 置換文字列
* @return 置換後文字列
#!/bin/bash -e
cd `dirname $0`
DEBUG={$DEBUG:-0}
SCRIPT_HOME=`pwd`
LOG_DIR=$SCRIPT_HOME/log
LOG_FILE_NAME=`basename $0 .sh`-`date +"%Y%m%d"`.log
LOG_FILE=$LOG_DIR/$LOG_FILE_NAME
@nori3tsu
nori3tsu / aes-cipher.py
Last active December 24, 2015 01:49
AES/ECB/PKCS5Padding
from Crypto.Cipher import AES
import base64
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s : s[0:-ord(s[-1])]
class AESCipher:
def __init__(self, key):
self.key = key