Skip to content

Instantly share code, notes, and snippets.

View kosh04's full-sized avatar
🎧

KOBAYASHI Shigeru kosh04

🎧
View GitHub Profile
@kosh04
kosh04 / Makefile
Last active September 7, 2018 18:55
WinSock2+FILE I/Oを利用したネットワークサーバのサンプル
CC := gcc
CFLAGS := -std=c99 -Wall -Werror -g3 -O0
LDLIBS := $(if $(findstring MINGW,$(MSYSTEM)),-lws2_32)
TARGET := http-server echo-server
default: $(TARGET)
http-server: http-server.o server.o
echo-server: echo-server.o server.o
@kosh04
kosh04 / sizseof.c
Created September 15, 2011 07:11
sizeof演算子で変数の大きさを調べる
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
#include <wchar.h>
#include <time.h>
// XXX: "%zd" format cannot work in VC, MinGW
#define prints(type) printf(#type "\t\t" "%lu\n", (unsigned long)sizeof(type))
@kosh04
kosh04 / rust-play.sh
Created February 6, 2018 15:56
Rust playground command-line tool (simple)
#!/bin/sh
set -eu
usage="usage: $0 [execute|compile] FILENAME"
url=https://play.rust-lang.org/${1?${usage}}
code=$(cat ${2?${usage}})
send() {
curl -s -X POST -H "Content-Type: application/json" -d @- ${1}
}
@kosh04
kosh04 / iconv.lsp
Created November 25, 2009 13:22
iconv library for newLISP
;;; -*- mode:newlisp; coding:utf-8 -*-
;; @module iconv.lsp
;; @description Yet Another Iconv Library
;; @version 0.5 初版
;; @version 0.6 Windows(DLL)でも使えるように
;; @version 0.7 関数を増やした
;; @version 0.8 変換後のNULL文字に対応したつもり
;; @version 0.8b newlisp_sjisでのバッファあふれ修正
;; @version 0.8c Rename iconv-handler -> call-with-iconv-descriptor
@kosh04
kosh04 / os.mk
Last active October 24, 2017 11:56
Makefileで使用するコンパイラからターゲットとなるプラットフォームを判定する
CC ?= cc
usage := make -f $(notdir $(MAKEFILE_LIST)) [CC=cc]
platform_list := linux bsd darwin mingw cygwin solaris
machine := $(shell $(CC) -dumpmachine)
# $(call grep, string, word-list)
grep = $(strip $(foreach word,$2,$(findstring $(word),$1)))
@kosh04
kosh04 / windres.md
Created September 17, 2016 18:44
リソースファイル作成時に参考にしたページ
@kosh04
kosh04 / build.bat
Last active August 2, 2016 07:41
Windows用irony-serverをビルドする
@echo off
setlocal
set LLVM_ROOT=C:\opt\LLVM
set PATH=%PATH%;C:\MinGW64\bin
set PATH=%PATH%;%LLVM_ROOT%\bin
set PATH=%PATH%;C:\opt\cmake\bin
set PATH=%PATH%;%HOME%\.emacs.d\bin
@kosh04
kosh04 / wandbox.el
Last active December 29, 2015 02:18
Wandbox を Emacs から利用する. Warning : This repo was moved to https://github.com/kosh04/emacs-wandbox
;;; wandbox.el --- Wandbox interface for Emacs
;; Let's Play Wandbox!
;; - http://melpon.org/wandbox/
;; - https://github.com/melpon/wandbox >>> /kennel/API.rst
;;; Example:
;; ## インタラクティブに利用する
;;
@kosh04
kosh04 / nl-json.c
Last active December 19, 2015 00:00
JSONパーサ <https://github.com/kgabis/parson> を #newlisp に組み込むとこんな感じになる。 エラー無視。パースのみ。シリアライズなし。追加引数を与えるとドット記法での探索が可能。 処理速度は json-parse の方が早い。
/* nl-json.c */
#include "newlisp.h"
#include "protos.h"
#include "nl-json.h"
CELL * stuffList(int length, ...)
{
CELL * list;
int i;
@kosh04
kosh04 / fibonacci.lsp
Last active December 17, 2015 18:49
ラムダ式の内部にデータを格納したフィボナッチ計算 関数に名前がないと値の参照ができないので実用的ではない
#!/usr/bin/env newlisp
;; 可能ならbigintを使用する
(when (primitive? bigint)
(constant '_+ +
'+ (lambda () (apply _+ (map bigint (args))))))
; (define (fibonacci n)
; (if (< n 2)
; 1