Skip to content

Instantly share code, notes, and snippets.

View methane's full-sized avatar

Inada Naoki methane

  • KLab Inc,
  • Japan
  • 02:02 (UTC +09:00)
  • X @methane
View GitHub Profile
@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:

@voluntas
voluntas / webrtc.rst
Last active January 23, 2024 06:57
WebRTC の未来
@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``.
@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とは

@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')

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

@frsyuki
frsyuki / presto-client.py
Last active October 11, 2020 09:56
Presto client for Ruby and Python
import os
import json
import httplib
import time
VERSION = "0.1.0"
class ClientSession:
def __init__(self, server, user, source=None, catalog=None, schema=None, debug=False):
self.server = server
@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 {
@gfx
gfx / foo.pl
Last active September 17, 2017 21:57
正規表現リテラルがあると便利な例。これを文字列操作メソッドで解決するとなるとかなり難しいと思われますがどうでしょう。 また、正規表現リテラルがなくてもじっさいにはあまり変わりないのですが、 \S ではなく \\S と書かなければならなかったりして注意しなければならない点が増えます。
#!perl
use 5.10.0;
use strict;
use warnings;
my $localhost = join '|', map { quotemeta } 'localhost', '127.0.0.1';
my $s = "http://localhost/foo http://127.0.0.1/bar http://127_0_0_1/foo/bar/baz";
my @matched = $s =~ m{ http:// (?:$localhost) / \S+ }xg;