Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
yuroyoro / Main.scala
Created April 18, 2011 06:52
Scalaの無限リスト(Stream)でいろいろと
// 初期値とstepを指定して永遠にカウントするItrator
class Counter[T:Numeric](init:T = 0,step:T = 1) extends Iterator[T] {
var cnt = init
def hasNext = true
def next = {
cnt = implicitly[Numeric[T]].plus(cnt, step)
cnt
}
// 自分をStreamにする
def asStream = Stream.continually( next )
$ find path_to_sourcedir/ -name '*.php' > cscope.files
$ cscope -b
$ cat ~/.vimrc
...
if has('cscope')
nnoremap <Leader>s :<C-u>scs find s <C-R>=expand("<cword>")<CR><CR>
nnoremap <Leader>g :<C-u>scs find g <C-R>=expand("<cword>")<CR><CR>
nnoremap <Leader>c :<C-u>scs find c <C-R>=expand("<cword>")<CR><CR>
nnoremap <Leader>t :<C-u>scs find t <C-R>=expand("<cword>")<CR><CR>
@emonkak
emonkak / inherit.js
Created December 11, 2011 16:11
inherit.js
function Klass(x)
{
this.member = {
x: x,
};
}
Klass.prototype = {
get x() {
return this.member.x;
@repeatedly
repeatedly / downloader.d
Last active October 1, 2015 23:18
D言語でいかにしておっぱい画像をダウンロードするか〜2013
// Written in the D programming language.
/**
* High peformance downloader
*
* Implemented according to <a href="http://yusukebe.com/archives/20120229/072808.html">this implementation</a>.
*
* Example:
* -----
* dmd -L-lcurl -run downloader.d
@repeatedly
repeatedly / d_master.md
Last active December 17, 2024 10:01
D言語基礎文法最速マスター

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

1. 基礎

ソースファイル

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

main

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

// Inversefizzbuzz
// http://www.jasq.org/2/post/2012/05/inverse-fizzbuzz.html
//
object InverseFizzbuzz extends App {
type E = (String,Int)
def zzubzzif(pattern:Seq[String]) = {
val fizzbuzz = (n:Int) => (n%3, n%5) match{
case (0,0) => ("fizzbuzz", n)
case (0,_) => ("fizz", n)
-- -*- coding: utf-8 -*-
import Test.HUnit
deal :: Int -> String -> [String]
deal n s = deal_ 0 (take n $ repeat "") (take ((length s) - (length s `mod` n)) s)
where deal_ _ ys [] = ys
deal_ m ys (x:xs) = deal_ ((m + 1) `mod` n) ((take m ys) ++ [(ys!!m) ++ [x]] ++ (drop (m + 1) ys)) xs
tests = test [
["111", "222", "333"] ~=? deal 3 "123123123",
@hayajo
hayajo / changelog_en.md
Last active April 1, 2025 14:37
ChangeLog を支える英語

ChangeLog を支える英語

ChangeLog を書く際によく使われる英語をまとめました。

ほとんど引用です。

基本形

花火~ 最高な俺たちと糞コードの海

written by mizchi at 小物エンジニアの会.

最高の夏の花火について 花火

自己紹介

@k0f1sh
k0f1sh / zone-pgm-rainbow
Last active April 27, 2018 15:51
虹色zone
;; zone-pgm-rainbow
(defun decimal->hex (n)
(format "%02X" n))
(defun hsv->rgb (h s v)
(let ((h (max 0 (min 360 h)))
(s (/ (max 0 (min 100 s)) 100.0))
(v (/ (max 0 (min 100 v)) 100.0)))
(if (= 0 s)