Skip to content

Instantly share code, notes, and snippets.

View ochaochaocha3's full-sized avatar

Kosuke Yamashita ochaochaocha3

View GitHub Profile
@ochaochaocha3
ochaochaocha3 / script.rb
Created November 24, 2014 09:46
スパロボ風会話画面試作版
require 'gosu'
require 'yaml'
Character = Struct.new(:nick_name, :image)
Page = Struct.new(:chara, :text)
class Script
attr_reader :chara
attr_reader :pages
@ochaochaocha3
ochaochaocha3 / irc_codeconv.rb
Created December 6, 2014 15:11
IRC メッセージの文字コード変換:ISO-2022-JP -> UTF-8
# vim: fileencoding=utf-8
s = "\x31\x33\x3A\x35\x39\x3A\x34\x36\x20\x3C\x23\e\x24\x42\x24\x62\x24\x4E\x3D\x71\x24\x2D\e\x28\x42\x3A\x4C\x65\x6F\x5F\x47\x75\x6E\x7A\x3E\x20\e\x24\x42\x21\x44\x21\x44\x24\x3D\x24\x6C\x24\x4F\e\x28\x42\x02\e\x24\x42\x36\x58\x34\x77\e\x28\x42\x0F\e\x24\x42\x21\x4A\x47\x7A\x21\x4B\x21\x64\x24\x4A\x24\x4E\x24\x4F\e\x28\x42"
s.force_encoding('ISO-2022-JP')
replaced_chars = s.chars.map do |ch|
ch.bytes[0] == 0x0F ? "\x18".encode('ISO-2022-JP') : ch
end
p replaced_chars.join.encode('UTF-8').gsub("\x18", "\x0F")
@ochaochaocha3
ochaochaocha3 / go-dicebot.go
Created December 7, 2014 13:46
Go 言語でダイスロール IRC ボット
package main
import (
"fmt"
"github.com/thoj/go-ircevent"
"log"
"math/rand"
"regexp"
"strconv"
"strings"
@ochaochaocha3
ochaochaocha3 / Makefile
Created December 25, 2014 04:12
Raspberry Pi 電子工作:CPU 温度を LED に表示する
CC=gcc
CFLAGS=-Wall
LIBS=-lwiringPi
TARGETS=led-cputemp
led-cputemp: led-cputemp.c
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
all: $(TARGETS)
@ochaochaocha3
ochaochaocha3 / Gemfile
Created December 27, 2014 05:55
TRPG 百科事典のリンク可視化
source 'https://rubygems.org/
gem 'nokogiri'
gem 'gviz'
gem 'colorable'
@ochaochaocha3
ochaochaocha3 / Makefile
Last active August 29, 2015 14:12
pthread の例
CC=gcc
CFLAGS=-Wall
LIBS=-lpthread
TARGETS=pthread-test
pthread-test: pthread-test.c
$(CC) $(CFLAGS) -o $@ $< $(LIBS)
all: $(TARGETS)
@ochaochaocha3
ochaochaocha3 / array-ref.php
Created January 3, 2015 13:58
PHP:配列の値渡しと参照渡し
<?php
# 配列の 0、1 番目を交換する(値渡し)
function swap01(Array $array) {
$temp = $array[0];
$array[0] = $array[1];
$array[1] = $temp;
return $array;
}
@ochaochaocha3
ochaochaocha3 / index.html
Last active August 29, 2015 14:13
enchant.js: Hello World
<!DOCTYPE html>
<html lang='ja'>
<head>
<meta charset='UTF-8'>
<title>Hello World</title>
</head>
<body>
<!-- https://github.com/uei/enchant.js-builds/blob/master/build/enchant.js からダウンロードしてくる -->
<script src='enchant.js'></script>
<script src='main.js'></script>
@ochaochaocha3
ochaochaocha3 / state-test.c
Created January 19, 2015 09:58
状態遷移の例
// 状態遷移の例
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum state { STATE_A, STATE_B, STATE_C };
// 状態 A〜C の処理
void a(void);
void b(void);
@ochaochaocha3
ochaochaocha3 / a.html
Created February 5, 2015 06:23
HTML エスケープされた title
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>K &amp; R</title>
</head>
<body>
<p>K &amp; R(けーあんどあーる)</p>
</body>
</html>