Skip to content

Instantly share code, notes, and snippets.

@koturn
koturn / binLiteral.c
Created October 13, 2014 16:26
Binary literal macro
#include <stdio.h>
#include <stdlib.h>
#define BIN_LITERAL_8(bin) \
( \
((0x0000000f & (0x ## bin)) != 0 ? 1 : 0) | \
((0x0000000f & (0x ## bin >> 4)) != 0 ? (1 << 1) : 0) | \
((0x0000000f & (0x ## bin >> 8)) != 0 ? (1 << 2) : 0) | \
((0x0000000f & (0x ## bin >> 12)) != 0 ? (1 << 3) : 0) | \
((0x0000000f & (0x ## bin >> 16)) != 0 ? (1 << 4) : 0) | \
@koturn
koturn / sort_alpha.c
Created October 17, 2014 08:50
後輩の課題
#include <ctype.h>
#include <stdio.h>
#define BUF_SIZE 1024
#define N_ALPHA 26
#define LALPHA_TO_NR(c) (c - 'a')
#define NR_TO_LALPHA(n) (n + 'a')
#define LENGTH(array) (sizeof(array) / sizeof((array)[0]))
#define SWAP(type, a, b) \
do { \
#####
##### 環境変数
#####
# LANGの設定
export LANG=ja_JP.UTF-8
case ${UID} in
0)
LANG=C
;;
@koturn
koturn / win32.c
Last active August 29, 2015 14:14
配列プログラミング
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
static int stack[128 * 1024];
static unsigned char code[] = {
0x55, 0x56, 0x57, 0x8b, 0x74, 0x24, 0x10, 0x8b, 0x7c, 0x24, 0x14, 0x8b, 0x6c, 0x24, 0x18, 0x83,
0x45, 0x00, 0x09, 0x8b, 0x45, 0x00, 0x85, 0xc0, 0x0f, 0x84, 0x1d, 0x00, 0x00, 0x00, 0x83, 0xc5,
0x04, 0x83, 0x45, 0x00, 0x08, 0x83, 0xc5, 0x04, 0x83, 0x45, 0x00, 0x0b, 0x83, 0xc5, 0x04, 0x83,
0x45, 0x00, 0x05, 0x83, 0xed, 0x0c, 0xff, 0x4d, 0x00, 0xeb, 0xd8, 0x83, 0xc5, 0x04, 0xff, 0x75,
@koturn
koturn / 2015-02-KanColleEvent.md
Last active August 29, 2015 14:15
艦隊これくしょんの2015年の2月に行われた冬イベントのゲージ破壊時のメンバーです

2015 2月 冬イベント

E1 泊地周辺の敵潜を叩け

  • 初霜改(Lv.70)
    • 三式爆雷投射機
    • 三式水中探信儀
    • 三式水中探信儀
  • 神通改二(Lv.70)
@koturn
koturn / 2015-04-KanColleEvent.md
Last active August 29, 2015 14:20
艦隊これくしょんの2015年の4月に行われた春イベントのゲージ破壊時のメンバーです

2015 4月 春イベント

E-1 発動準備、第十一号作戦!

艦隊

  • 潮改二(Lv.75)
    • 10cm連装高角砲
  • 10cm連装高角砲
@koturn
koturn / anchorgum.md
Last active August 29, 2015 14:23
アンカーガムの最速タイムとハイスコア

アンカーガムの最速タイムとハイスコア

フリーゲーム:「アンカーガム」の最速タイムとハイスコア

各ステージの記録

ステージ番号 ステージ名 最速タイム ハイスコア
if executable('sudo')
function! s:save_as_root(is_bang, filename)
if a:filename ==# ''
let l:filename = '%'
else
let l:filename = a:filename
endif
execute 'write' . a:is_bang ' !sudo tee > /dev/null ' . l:filename
endfunction
else
@koturn
koturn / .gvimrc
Last active August 29, 2015 14:25
2015/07/20の.vimrc
" ============================================================
" __ __ ____
" / /______ / /___ ___________ / __ \ _
" / //_/ __ \/ __/ / / / ___/ __ \ / / / /(_)
" / ,< / /_/ / /_/ /_/ / / / / / / / /_/ / _
" /_/|_|\____/\__/\__,_/_/ /_/ /_/ \____/ ( )
" |/
"
" The setting file for GUI only.
" ============================================================
@koturn
koturn / destroy.vim
Last active August 29, 2015 14:25
編集中のファイルを(ほぼ)二度と読めなくするコマンド
" Joke!
if has('cryptv')
function! s:destroy_file(has_bang) abort
if !filereadable(expand('%:p'))
echoerr 'Current buffer is not write out to file'
return
endif
if !a:has_bang
echoerr "Must to add '!' to destroy this file"
return