Skip to content

Instantly share code, notes, and snippets.

View ochaochaocha3's full-sized avatar

Kosuke Yamashita ochaochaocha3

View GitHub Profile
@ochaochaocha3
ochaochaocha3 / munin_http_loadtime.go
Created September 5, 2019 18:53
Muninのhttp_loadtimeをGolangで
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
"strings"
"time"
@ochaochaocha3
ochaochaocha3 / router.go
Created August 19, 2019 15:20
controllers/router.go の Setup 関数の引数を変える
package controllers
import (
"github.com/labstack/echo"
"github.com/raa0121/GoBCDice/cmd/GoBCDiceAPI/controllers/v1"
)
// Setup sets up all controllers.
func Setup(e *echo.Echo) {
cRoot := RootController{Router: e.Router()}
@ochaochaocha3
ochaochaocha3 / ruby_quiz_148-postfix_to_infix.md
Last active July 10, 2019 02:55
Ruby Quiz - Postfix to Infix (#148) 翻訳

Ruby Quiz(James Edward Gray II氏が管理)の#148「Postfix to Infix」の一部の翻訳(意訳を含む)。

クイズの概要 Quiz Summary

The big advantage of postfix expressions is that they are built with a stack in mind. This turns out to be a powerful way to do math both for computers and humans. HP makes some great RPN calculators that literally display a stack on the screen and give you the tools the manipulate it. To handle the expression:

2 3 +

>

@ochaochaocha3
ochaochaocha3 / convertPageToSDBoard.php
Last active June 6, 2019 14:15
MediaWikiのページをStructured Discussionsボードに変換するメンテナンススクリプト
<?php
require_once __DIR__ . '/maintenance/Maintenance.php';
/**
* ページを Structured Discussions ボードに変換する。
*/
class ConvertPageToSDBoard extends Maintenance {
public function __construct() {
parent::__construct();
@ochaochaocha3
ochaochaocha3 / exclude-DS_Store.js
Created June 2, 2018 02:07
ファイル名の配列から .DS_Store を除外する
// ファイル名の配列
var files = [
'dir/.DS_Store', 'dir/img.jpg', 'dir2/img2.png'
];
// filterで.DS_Storeを除外する
files
.filter(filename => !filename.endsWith('.DS_Store'));
/*
dir/img.jpg,dir2/img2.png
@ochaochaocha3
ochaochaocha3 / install-opencv-2.4.13.5.sh
Last active December 27, 2017 14:13
Ubuntu 17.10でOpenCV 2.4.13.5をインストールしたときの手順
#!/bin/bash
# ライブラリのインストール
# 参照: https://docs.opencv.org/2.4.13.5/doc/tutorials/introduction/linux_install/
sudo apt install build-essential
sudo apt install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt install qtbase5-dev libvtk6-dev
# CMakeでMakefileを作る
@ochaochaocha3
ochaochaocha3 / bcdice_wrap.rb
Created July 1, 2017 11:18
bcdice-apiの全ダイスボットの情報収集処理を簡単にする
# frozen_string_literal: true
require "bcdiceCore"
require "diceBot/DiceBot"
require "diceBot/DiceBotLoader"
class BCDice
VERSION = "2.02.70"
# BCDiceのコミット11ee56c以降で可能
# @see https://github.com/torgtaitai/BCDice/commit/11ee56c8dfdb00ac232c8b5cbf87a963d37df974
@ochaochaocha3
ochaochaocha3 / DodontoFServer_callgraph.rb
Last active June 24, 2017 16:49
指定したキーワードからDodontoFServer.rb内のコールグラフを作るスクリプト
IDENTIFIER_PATTERN = /[A-Za-z_][A-Za-z0-9_]*/
FUNC_PATTERN = /\Adef\s*((?:DodontoFServer|self)\.)?(#{IDENTIFIER_PATTERN})/o
class DodontoFMethod < Struct.new(:name, :decl_line, :lines, :class_method)
def to_s
"<#{self.class_method ? 'class_method' : 'method'} #{self.name}>"
end
end
dodontof_methods = []
@ochaochaocha3
ochaochaocha3 / README.md
Last active June 14, 2017 15:32
CentOS 7でHTTP/2に対応したnginxのRPMを自動生成する
@ochaochaocha3
ochaochaocha3 / bcdiceCui.rb
Created May 29, 2017 15:36
BCDiceのCUI(手抜き)。設定はconfigBcDice.rbで行う。
bcdice_root = File.expand_path(File.dirname(__FILE__))
irc_dir = "#{bcdice_root}/irc"
$LOAD_PATH.unshift(irc_dir)
$LOAD_PATH.unshift(bcdice_root)
require 'bcdiceCore'
require 'net/irc'
require 'irc/ircBot'