Skip to content

Instantly share code, notes, and snippets.

View ochaochaocha3's full-sized avatar

Kosuke Yamashita ochaochaocha3

View GitHub Profile
@ochaochaocha3
ochaochaocha3 / codeiq-q431.c
Last active December 23, 2015 10:18
CodeIQ Q431 Restricted Words。リテラルを使わずに「Hello World」を出力する。整数拡張を忘れていて int ではなく char を使っていたり、変数に格納している数値が中途半端だったり、改めて見ると粗が目立つ。
#include <stdio.h>
int
main(void) {
char one = sizeof(char); /* is 1 by definition */
char zero = one >> one;
char two = one << one;
char four = two << one;
char five = four | one;
char six = four | two;
@ochaochaocha3
ochaochaocha3 / read_dodontof_chat_log.php
Created June 10, 2014 14:55
【PHP】どどんとふチャットログ HTML ファイルからチャットログ部分を抽出する
<?php
/**
* どどんとふチャットログ HTML ファイルからチャットログ部分を取り出して返す
* @param string $filename ファイル名
* @return string チャットログ部分を含む HTML コード
* @return NULL 読み込みに失敗した場合
*/
function read_dodontof_chat_log($filename) {
# ファイルポインタを取得する
@ochaochaocha3
ochaochaocha3 / struct-sortby.c
Last active August 29, 2015 14:06
構造体中のメンバでソート
#include <stdio.h>
#define C_SIZE 3
typedef enum {
X,
Y,
Z
} coordinate;
@ochaochaocha3
ochaochaocha3 / struct-sortby-2.c
Last active August 29, 2015 14:06
構造体中のメンバでソート(バブルソート効率化)
#include <stdio.h>
#define C_SIZE 3
typedef enum {
X,
Y,
Z
} coordinate;
@ochaochaocha3
ochaochaocha3 / t-ff.c
Created October 1, 2014 12:46
T-FF シミュレータ:タイムチャート描画
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int time;
int length;
} pulse;
typedef struct {
unsigned char negative_edge : 1;
@ochaochaocha3
ochaochaocha3 / counter-async.c
Last active August 29, 2015 14:07
非同期式カウンタシミュレータ:タイムチャート描画、カウント表示
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int time;
int length;
} pulse;
typedef struct {
unsigned int negative_edge : 1;
@ochaochaocha3
ochaochaocha3 / like_irc_parser.rb
Created October 16, 2014 11:02
IRC 風構文解析
require 'strscan'
module Converter
AVAILABLE_TAGS = {
/<bold>/ => {
start_tag: '<b>',
end_tag: '</b>'
},
/<underline>/ => {
start_tag: '<u>',
@ochaochaocha3
ochaochaocha3 / irc_msg_parser.rb
Last active August 29, 2015 14:08
IRC 発言内容構文解析
# vim: fileencoding=utf-8
require 'strscan'
module Converter
AVAILABLE_TAGS = {
/\u0002/ => {
start_tag: '<b>',
end_tag: '</b>'
},
@ochaochaocha3
ochaochaocha3 / install-gems.sh
Created October 25, 2014 10:15
Ruby インストール直後の Gem インストール
#!/bin/bash
# Developing
gem install bundler pry yard rspec rubocop
rbenv rehash
# Nokogiri
gem install nokogiri -- \
--with-xml2-include=`brew --prefix libxml2`/include/libxml2 \
--with-xml2-lib=`brew --prefix libxml2`/lib \
@ochaochaocha3
ochaochaocha3 / GranCrest.yaml
Created November 2, 2014 02:47
BCDice グランクレスト テストデータ
GameType: 'GranCrest'
TestData:
- Input: ['2d6>=10']
Output: |
GranCrest : (2D6>=10) > 9[3,6] > 9 > 失敗
Rands: [6/6, 3/6]
- Input: ['2d6>=10']
Output: |