Skip to content

Instantly share code, notes, and snippets.

@m-mizutani
m-mizutani / pthread_cs_benchmark.sh
Created October 11, 2011 00:18
pthread_cond_signal benchmark script
#!/bin/sh
mkdir psc_benchmark
cd psc_benchmark
wget -O cond_signal_benchmark.c https://raw.github.com/gist/1273378/3cfe340710f469fdcfa623653f350184a99679c4/cond_signal_benchmark.c
gcc -o cond_signal_benchmark cond_signal_benchmark.c -lpthread
base=100000
c=$base
@m-mizutani
m-mizutani / code_reading.md
Created May 17, 2012 21:48 — forked from taichi/code_reading.md
太一のコードの読み方メモ

太一のコードの読み方メモ

全体として太一が感覚的に実践している事を論理的に説明しようと試みている為、
説明の粒度が適切でなかったり一貫性が無いように見える部分があるかもしれない。
普段やっているけども書ききれていない事も多分きっとある。

コードを読むとは何か

  • コードを嗜む
  • コードを学ぶ
  • 武器を手に入れる
@m-mizutani
m-mizutani / gist:3829587
Created October 3, 2012 20:19
Self class verification in C++
#include <stdlib.h>
#include <iostream>
class ChildA;
class ChildB;
class Base {
public:
bool isChildA ();
bool isChildB ();
@m-mizutani
m-mizutani / gist:4173094
Created November 30, 2012 01:16
Proxy settings
  • CentOS yum

/etc/yum.conf

proxy=http://localhost:3128/
  • npm

by npm command

@m-mizutani
m-mizutani / gist:4464986
Last active April 6, 2022 07:07
node addon sample
#define BUILDING_NODE_EXTENSION
#include <node.h>
#include <unistd.h>
// 趣味。特にnamespaceを切る必要はない
namespace addon {
// ----------------------------------------------------------------------------
// 引数を受け取って、普通に結果を返すだけの関数
v8::Handle<v8::Value> Add(const v8::Arguments& args) {
@m-mizutani
m-mizutani / jenkins_check.py
Created March 19, 2013 23:30
For Post build task of Jenkins
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib
import json
import subprocess
import os
import time
conf = {'host': 'localhost',
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
## 実行方法
# /usr/bin/env rubyと書く文化と/usr/bin/ruby と書く文化の両方があるらしい。
# /usr/bin/rubyと書いてもパス検索されるのでほとんどの環境では
# 両方動くらしいという記述を見かけた。未検証
puts '--- Syntax --------------'
# - 終端記号なしで基本1行1ステートメント、文法上、インデントの制約は無い
[forge(Darwin):~] % brew -v install R
Homebrew 0.9.4
==> Installing dependencies for r: cloog, gfortran
==> Installing r dependency: cloog
==> Downloading http://www.bastoul.net/cloog/pages/download/count.php3?url=./cloog-0.18.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/cloog-0.18.0.tar.gz
tar xf /Library/Caches/Homebrew/cloog-0.18.0.tar.gz
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/cloog/0.18.0 --with-isl-prefix=/usr/local/opt/isl
./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/cloog/0.18.0 --with-isl-prefix=/usr/local/opt/isl
checking for a BSD-compatible install... /usr/bin/install -c

他の言語をある程度知っている人はこれを読めばD言語の基礎をマスターでき,D言語の氷山の一角くらいは知ることができると思います.対象バージョンはdmd 2.059です.

1. 基礎

ソースファイル

ASCIIかUTFしか受け付けません.それ以外の文字コードで書くとコンパイルエラーになります.

main

D言語のmainはCとは違い以下のようなシグネチャです.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<div id="chart" style='overflow:auto; width:960px; height:480px; background: #eee;'></div>
</body>
<script type="text/javascript">