他の言語をある程度知っている人はこれを読めばD言語の基礎をマスターでき,D言語の氷山の一角くらいは知ることができると思います.対象バージョンはdmd 2.059です.
ASCIIかUTFしか受け付けません.それ以外の文字コードで書くとコンパイルエラーになります.
D言語のmainはCとは違い以下のようなシグネチャです.
| require 'sinatra' | |
| require 'haml' | |
| # 静的コンテンツ参照のためのパス設定 | |
| set :public, File.dirname(__FILE__) + '/public' | |
| # アップロード | |
| get '/' do | |
| haml :index |
| # coding: utf-8 | |
| require 'sinatra' | |
| set server: 'thin', connections: [] | |
| get '/' do | |
| halt erb(:login) unless params[:user] | |
| erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
| end | |
| get '/stream', provides: 'text/event-stream' do |
| # Basic Keygen | |
| # Briefly used at my startup | |
| # Note: be mindful of any console logging or stdout logging when running this. | |
| # | |
| # By Jason Giedymin | |
| # jasong _-@-_ apache -dot- org | |
| # | |
| crypto = require "crypto" | |
| rbytes = require "rbytes" |
| thumbnail: http://pds.exblog.jp/pds/1/201101/16/02/d0055302_13383029.jpg | |
| video: http://www.youtube.com/watch?v=UE27t_LJpx0 |
| module Sinatra | |
| module Flash | |
| module Style | |
| def styled_flash(key=:flash) | |
| return "" if flash(key).empty? | |
| id = (key == :flash ? "flash" : "flash_#{key}") | |
| close = '<a class="close" data-dismiss="alert" href="#">×</a>' | |
| messages = flash(key).collect {|message| " <div class='alert alert-#{message[0]}'>#{close}\n #{message[1]}</div>\n"} | |
| "<div id='#{id}'>\n" + messages.join + "</div>" | |
| end |
| # source : http://code.google.com/p/natvpn/source/browse/trunk/stun_server_list | |
| # A list of available STUN server. | |
| stun.l.google.com:19302 | |
| stun1.l.google.com:19302 | |
| stun2.l.google.com:19302 | |
| stun3.l.google.com:19302 | |
| stun4.l.google.com:19302 | |
| stun01.sipphone.com | |
| stun.ekiga.net |