Skip to content

Instantly share code, notes, and snippets.

Avatar

Kosuke Yamashita ochaochaocha3

View GitHub Profile
@ochaochaocha3
ochaochaocha3 / ruby_quiz_148-postfix_to_infix.md
Last active Jul 10, 2019
Ruby Quiz - Postfix to Infix (#148) 翻訳
View ruby_quiz_148-postfix_to_infix.md

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 Jun 6, 2019
MediaWikiのページをStructured Discussionsボードに変換するメンテナンススクリプト
View convertPageToSDBoard.php
<?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 Jun 2, 2018
ファイル名の配列から .DS_Store を除外する
View exclude-DS_Store.js
// ファイル名の配列
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 Dec 27, 2017
Ubuntu 17.10でOpenCV 2.4.13.5をインストールしたときの手順
View install-opencv-2.4.13.5.sh
#!/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 Jul 1, 2017
bcdice-apiの全ダイスボットの情報収集処理を簡単にする
View bcdice_wrap.rb
# 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 Jun 24, 2017
指定したキーワードからDodontoFServer.rb内のコールグラフを作るスクリプト
View DodontoFServer_callgraph.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 Jun 14, 2017
CentOS 7でHTTP/2に対応したnginxのRPMを自動生成する
View README.md
@ochaochaocha3
ochaochaocha3 / bcdiceCui.rb
Created May 29, 2017
BCDiceのCUI(手抜き)。設定はconfigBcDice.rbで行う。
View bcdiceCui.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'
@ochaochaocha3
ochaochaocha3 / tact_switch.cpp
Created Nov 11, 2016
Raspberry Pi:チャタリング対策付き負論理タクトスイッチのC++クラス
View tact_switch.cpp
/**
* @file tact_switch.cpp
* @brief タクトスイッチ
*/
#include "tact_switch.h"
#include <wiringPi.h>
@ochaochaocha3
ochaochaocha3 / Makefile
Created Sep 18, 2016
OSXでOpenCVのテスト
View Makefile
CXX=clang++
CXXFLAGS=-Wall
LDLIBS=-lopencv_core -lopencv_highgui -lopencv_imgproc
capture: capture.cpp
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS)