This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct list List; | |
typedef uint8_t Value; | |
struct list { | |
List* next; | |
Value value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
int main(int argc, char* argv[]) { | |
// 作成 | |
uint8_t numbers[3] = {1, 2, 3}; | |
// 参照 | |
for (size_t i = 0; i < (sizeof(numbers) / sizeof(numbers[0])); ++i) { | |
printf("numbers[%zd] = %u\n", i, numbers[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" radian = degrees * Math.PI / 180; | |
" degrees = radian * 180 / Math.PI; | |
function! s:rad_to_deg(r) abort | |
return a:r * 180.0 / 3.141592 | |
endfunction | |
function! s:deg_to_rad(d) abort | |
return a:d * 3.141592 / 180.0 | |
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s:right = 1 | |
let s:left = 2 | |
function! s:slide(direction) | |
let store_registor = @" | |
execute "normal yi, W" | |
let source = @" | |
execute "normal yi," | |
let dist = @" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 定数を使いたい | |
let lst = ['a', 'b', 'c'] | |
lockvar lst " 変数を書き換えられないようにする | |
" let lst[0] = 'd' -> ERROR! | |
unlockvar lst " 解除 | |
" Vim script以外のファイルを読み込みたいとき | |
" 結果はファイルの行がリストとしてかえる | |
let lst = readfile('hogehoge.txt') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void* malloc(size_t size_byte) { | |
size_t size = size_byte * 8; | |
Dlinked_list_node lst = mem_manager->mem_lst; | |
Memory_info* mi = lst->data; | |
while (lst->tail != DUMMY) { | |
if (mi->state == MEM_INFO_STATE_FREE && size < mi->size) { | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum memory_manager_constants { | |
MAX_MEM_NODE_NUM = 4096, | |
MEM_INFO_STATE_LOST = -1, | |
MEM_INFO_STATE_FREE, | |
MEM_INFO_STATE_ALLOC, | |
}; | |
/* 管理対象のメモリ情報 */ | |
struct memory_info { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Segment_descriptor *gdt = (Segment_descriptor*)0x270000; | |
/* 全セグメントを初期化 */ | |
for (int i = 0; i < GDT_MAX_NUM; ++i) { | |
set_segment_descriptor(gdt + i, 0, 0, 0, 0, 0, 0, 0, 0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ps = vimproc#popen3('path/to/t_sample') | |
call ps.stdin.write('write_test!') | |
call ps.stdin.close() | |
" close無しだと以下のreadで空 | |
let output = ps.stdout.read() | |
echomsg " 2 stdout echos " . output | |
" finish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) { | |
char buf[100]; | |
printf("mopp test\n"); | |
fflush(stdout); | |
scanf("%s", buf); | |
printf("%s\n", buf); |
NewerOlder