Skip to content

Instantly share code, notes, and snippets.

@funny-falcon
funny-falcon / changes.md
Last active March 23, 2024 05:53
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

概要

Fluentdは JSONストリームとしてログを扱うログ収集デーモンです。
これまでのところ、最大のユーザーではピーク時で
100台以上のサーバ、650GB daily 、70,000msgs/sec のログを収集しています。

目的

@podhmo
podhmo / cps-like-functions-example.scm
Created July 25, 2012 15:00
toy code using a cps like function (as ansync process simulation)
;; CPSスタイル.これは、実は非同期処理など結果がいつ計算されるか分からない場合のモデル。
;; 通常の同期処理とは異なり、引数のcontがいつ計算されるかは分からないが、*準備*ができたときcontに渡され次の計算が行われる。
(define (add1 x cont)
(cont (+ x 1)))
(define (mul2 x cont)
(cont (* x 2)))
;; つなげてみる。
from zope.interface.registry import Components
from zope.interface import Interface
from zope.interface import Attribute
from zope.interface import provider
from zope.interface import implementer
## global registry
_global_registry = None
def global_registry():
return _global_registry or Components()
# 参考URL: http://d.hatena.ne.jp/gmaxlab/20090329/1238329567
import httplib, ssl
#HTTPで上手くいく場合
http_session = httplib.HTTPConnection("squidのドメイン", 8080)
http_session.request("GET", "http://yahoo.co.jp/")
r1 = http_session.getresponse()
print r1.status, r1.reason
#HTTPSで失敗する場合
@Gab-km
Gab-km / smugnessProblem.rst
Created April 19, 2012 08:01
コードウォッチ:関数型プログラミングの自惚れ問題

コードウォッチ:関数型プログラミングの自惚れ問題

原文

http://www.sdtimes.com/link/36534

著者

Larry O'Brien

僕は関数型プログラミングが好きだ。次の10年にかけてコードの革命を起こしていくだろうと考えている:言語はより関数型の機能を採用していくだろうし、開発者はより関数型の技術を導入していくだろうし、いくつかの点では、関数型プログラミングの原則はコードを組み立てていく上で「自然で」もっとも明確なやり方だとみんな考えるようになっていくだろう。

だけど、僕はもうこのシナリオを本気にしちゃいない。関数型プログラミングは、ワクワクするものを学ぶことに興味があると言っている主流のプログラマにとって明白な、大きな問題を抱えている:関数型プログラマーは自惚れ野郎どもだってことだ。

import re
def fix_charref(s):
return re.sub(r'&#(\d+);', lambda m: unichr(int(m.group(1))), s)
;;
;;; u-nya-mode
(defun cyclic (xs)
(setcdr (last xs) xs)
xs)
(defvar u-nya:message-list nil)
;; (defvar u-nya:update-hook nil)
@datagrok
datagrok / gist:2199506
Last active April 8, 2023 17:36
Virtualenv's `bin/activate` is Doing It Wrong
@ultraist
ultraist / zch_sentence.rb
Created February 2, 2012 15:49
句読点のない文字列を文単位に区切る
# -*- coding: utf-8 -*-
# 句読点のない文字列を文単位に区切る
#
# 基本的にはルールベースでルールが適用できない場合は機械学習器で判定する。
# これは青空文庫のデータ( http://www.udp.jp/misc/aozora-data/ )から学習した。
# * ruby 1.8の場合は $KCODE='u'としないと動かない
=begin
s = <<TEXT
昼飯のスパゲティナポリタンを眺めながら