Skip to content

Instantly share code, notes, and snippets.

View methane's full-sized avatar

Inada Naoki methane

  • KLab Inc,
  • Japan
  • 07:35 (UTC +09:00)
  • X @methane
View GitHub Profile
@lrvick
lrvick / flask_geventwebsocket_example.py
Created September 1, 2011 07:17
Simple Websocket echo client/server with Flask and gevent / gevent-websocket
from geventwebsocket.handler import WebSocketHandler
from gevent.pywsgi import WSGIServer
from flask import Flask, request, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@hiboma
hiboma / nginx.conf
Created January 24, 2012 13:02
Nginx+Lua+Redis で動的upstream
worker_processes 1;
error_log /dev/stderr debug;
events {
worker_connections 256;
}
http {
server {
@methane
methane / flask_memcache.py
Created January 31, 2012 12:00
Sample using python-memcached in threaded Flask application.
"""Flask extension utility."""
from flask.sessions import SessionInterface, SessionMixin
from werkzeug.contrib.cache import MemcachedCache
import memcache # Use https://code.launchpad.net/~songofacandy/python-memcached/mixin-threading
def setup_cache(app):
"""
Setup ``app.cache``.
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@jedy
jedy / go_scp.go
Last active May 31, 2022 07:20
an example of scp in golang
// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
package main
import (
"fmt"
"golang.org/x/crypto/ssh"
)
const privateKey = `content of id_rsa`
@repeatedly
repeatedly / msgpack_issue_121.md
Last active November 30, 2021 02:09
MessagePackが文字列とバイナリをわけないのは問題?

MessagePackが文字列とバイナリをわけないのは問題?

msgpack/msgpack#121

Objective Cの実装使ってるとある問題にぶちあたった.なので,文字列をちゃんとバイナリ(Raw)と分けるべき,という提案

(*) 俺は熟読したわけではないので,中身が気になる人はちゃんと本スレを読みましょう

そもそもMessagePackとは

msgpackの変更案について

概要:

  • 現行のRaw型をString型として読み替える。
  • Binary型を新設する。
  • 明らかなバイナリはデフォルトでBinary型(新設型)で保存

型システムの変更

  • Binary: バイト列

msgpackの変更案について-3

概要:

  • 現行のRaw型をString型として読み替える。
    • 現行の FixRaw, raw 16, raw 32 は、FixString, string 16, string 32 になる
  • Binary型を新設する。
  • バイト列はBinary型で保存する。そうでなければString型で保存する。

背景

3からの差分:

  • 実装の後方互換性に関する記述を修正
  • 各実装へのリンクを追加
  • 背景にNoteを追加
  • 「UTF-8としてinvalidなバイトシーケンスを含む文字列が保存されていることがある」理由の修正
  • 概要から「バイト列はBinary型で保存する。そうでなければString型で保存する」を削除(背景と型システムの詳細を読んでもらう)
  • weak-string languages のシリアライザのところで、「String型はUTF-8としてinvalidなバイトシーケンスを許容する」の注釈を削除

msgpackの変更案について-4

2013-02-24 22:28:51 -0800: This is not a fixed proposal. See the second version as well: https://gist.github.com/frsyuki/5028082

Overview

  • Add "Binary" type
  • Change the current Raw type to "String" type
    • Meaning current FixRaw, raw 16, and raw 32 become FixString, string 16, and string 32

Background