Skip to content

Instantly share code, notes, and snippets.

@wonderful-panda
wonderful-panda / hgcommit.vim
Created December 17, 2014 09:36
hg commit時のメッセージエディタにvimを使う時のあれこれ(for windows)
scriptencoding utf-8
setlocal fileencoding=cp932
" カーソル下のファイルに対するdiffをvimdiffで表示
nnoremap ;d :call ShowHgDiffUnified(expand('<cfile>'))<CR>
function! ShowHgDiffSideBySide(path) abort
execute 'tabedit ' . a:path
let encoding = &encoding
@wonderful-panda
wonderful-panda / proxy.go
Created October 31, 2014 09:35
proxy.go
package main
import (
"encoding/base64"
"flag"
"fmt"
"io"
"log"
"net"
"net/http"
@wonderful-panda
wonderful-panda / paizahack_lite.md
Last active August 29, 2015 14:04
paiza オンラインハッカソン lite(https://paiza.jp/poh/kirishima) pythonによるコード #paizahack_lite

paizaオンラインハッカソン lite をPythonで解いてみた.

結果 は0.01秒.

単純に枝刈りしながら深さ優先探索するだけのコードだけど, あらかじめ単価の安い順にソートしておくのと, Solver.least_cost() あたりの処理とで出来るかぎり浅いところで枝刈りされるようにしている.

とはいえ、このコードで TestCase7が0.01秒というのはちょっと速すぎる気がしないでもない.

# -*- coding:utf-8 -*-
@wonderful-panda
wonderful-panda / Content.md
Last active August 29, 2015 14:04
複数ルートなブランチの全ての差分の取得(for Windows)
@wonderful-panda
wonderful-panda / weakevent.cs
Created July 8, 2014 22:12
オレオレWeakEvent
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Linq.Expressions;
using System.Diagnostics;
namespace WonderfulPanda.Gists
{
@wonderful-panda
wonderful-panda / eventsource.cs
Last active August 29, 2015 14:02
Weak Eventの実装?
namespace WonderfulPanda.Gist
{
public class EventSourceSample
{
WeakEvent<EventArgs> _test = new WeakEvent<EventArgs>();
public event Test
{
add { _test.AddHandler(value); }
remove { _test.RemoveHandler(value); }
}
@wonderful-panda
wonderful-panda / sphinx.vim
Last active August 29, 2015 14:01
VimでSphinxを書く時のための補完定義など
if !exists('s:loaded')
let g:sphinx_image_dirnames = ['images', 'figures', '_static']
let g:sphinx_image_ext = 'png'
let g:sphinx_image_dir_search_depth = 5
endif
" Sphinxの環境に関する情報
let s:context = {
\ 'filepath': '',
\ 'root': '',
@wonderful-panda
wonderful-panda / mercurial.ini
Created February 4, 2014 01:12
指定したリビジョンの子孫をまとめてブランチのHEADにrebaseする(for Windows)
# 指定したリビジョンの子孫をまとめて指定リビジョンを含むブランチのHEADにrebaseする。
# 主な用途は、手元で生やしまくったfeatureブランチ共をupstreamから取ってきた新しいHEADにまとめて引っ越すとか
[alias]
follow = !for /F "usebackq" %i in (`"%HG%" log -r $1 --template {branch}`) do ("%HG%" rebase -r "($1):: & !public() - ::'%i' - '%i'::" -d %i --keepbranches)
@wonderful-panda
wonderful-panda / readme.txt
Last active December 30, 2015 07:39
paiza online hackathon 1
http://paiza.jp/poh/ec-campaign/result/52532b7720a4e3584cb188e26a8a2ec1
pythonで0.08/0.11/0.45
1回の計算で何度もbisectかけるのは遅いかと思ったけど、bisectの範囲を狭めていけるのでそれほどでもでもなかった。
※コピペした時に一か所インデントが狂ってしまっていて動かなくなっていたので、修正した。
# -*- coding:utf8 -*-
# 平成変換
# https://codeiq.jp/challenge.php?challenge_id=466
# 実行には Python 3.2以降が必要です
import math
import re
from collections import namedtuple
def memoize(f):