Skip to content

Instantly share code, notes, and snippets.

View masahitojp's full-sized avatar
🎯
Focusing

Masato Nakamura masahitojp

🎯
Focusing
View GitHub Profile
@matsuu
matsuu / gist:93a8bdc496b00f767ce4
Created June 15, 2014 12:36
DTIのDNSサーバが127.0.0.1を返す件
$ dig @202.216.229.30 a cloudfront.net.
; <<>> DiG 9.9.2-P2 <<>> @202.216.229.30 a cloudfront.net.
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32100
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
package main
import (
"math/rand"
"fmt"
"strings"
)
var words = []string {
"ボ",
@hokaccha
hokaccha / sushi
Created April 30, 2014 07:52
Macのターミナルに寿司を降らせる
$ ruby -e 'C=`stty size`.scan(/\d+/)[1].to_i;S="\xf0\x9f\x8d\xa3";a={};puts "\033[2J";loop{a[rand(C)]=0;a.each{|x,o|;a[x]+=1;print "\033[#{o};#{x}H \033[#{a[x]};#{x}H#{S} \033[0;0H"};$stdout.flush;sleep 0.01}'
@gakuzzzz
gakuzzzz / 1_.scala
Last active August 29, 2015 13:59
Is Stream#addString correct?
scala> Iterator.iterate(0)(_ + 1).take(10).addString(new StringBuilder, ",")
res7: StringBuilder = 0,1,2,3,4,5,6,7,8,9
scala> Stream.iterate(0)(_ + 1).take(10).addString(new StringBuilder, ",")
res8: StringBuilder = 0,?
scala> Iterator.iterate(0)(_ + 1).take(10).toString
res9: String = non-empty iterator
scala> Stream.iterate(0)(_ + 1).take(10).toString
@gakuzzzz
gakuzzzz / 1_.md
Last active August 2, 2023 01:59
Scala の省略ルール早覚え

Scala の省略ルール早覚え

このルールさえ押さえておけば、読んでいるコードが省略記法を使っていてもほぼ読めるようになります。

メソッド定義

def concatAsString(a: Int, b: Int): String = {
  val a_ = a.toString();
  val b_ = b.toString();
@gakuzzzz
gakuzzzz / 1_.md
Last active June 19, 2023 12:53
trait と abstract class の使い分け

trait と abstract class の使い分け

  • 基本は迷ったら trait にしておけば良いと思います
    • trait は一つの class に複数 mixin できますが、class は一つしか継承できません
    • つまり、trait であれば mixin される class を気にしなくてよいですが、 abstract class にした場合は、extends される class が他に継承したい物が無いか気にする必要があります
  • trait はコンストラクタを持つ事ができませんが、abstract class はコンストラクタを持つ事ができます
    • 従って、型引数に制約をつけたい時や、共通のフィールドの初期化などがある場合は、abstract class にすると楽な場合があります。
  • 以下に具体例を示します。良くある Java の enum を Scala で定義する場合の例です。
@gin0606
gin0606 / shinchoku.coffee
Last active August 29, 2015 13:58
hubot script
# Description:
# 進捗 is the most important thing in your life
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@koron
koron / jquery.gc-helper.js
Last active December 17, 2015 11:05
Remove jQuery related objects when remove elements by DOM API
// jQuery GC Helper - v0.9.5
//
// Copyright (C) 2014 MURAOKA Taro
// Licensed under the MIT license.
(function(global, jQuery) {
var observer;
function callback(mutations) {
@slfritchie
slfritchie / presentation.md
Created March 18, 2014 09:22
Erlang tracing, for the Riak source code reading series, 2014-03-18, Tokyo, Japan

Erlang Tracing: more than you wanted to know

Rough Outline

  • What can be traced?
  • How can trace events be specified?
  • "match specifications": twisty passages, all alike
  • WTF, can I just use DTrace and drink my coffee/beer/whisky in peace?
  • Trace delivery mechanisms: pick one of two
@lestrrat
lestrrat / gist:9104980
Last active August 3, 2017 21:55
ヘビメタ英語を日常で使う風景