Skip to content

Instantly share code, notes, and snippets.

View tsukkee's full-sized avatar

Takayuki Tsukitani tsukkee

View GitHub Profile
@tsukkee
tsukkee / define_function_in_python.vim
Created February 24, 2011 11:53
PythonのデコレータでVim ScriptからでもPythonからでも呼べる関数を定義する
python <<EOM
# coding=utf-8
import vim
vim.command("""
function! Hoge(str)
return a:str . a:str
endfunction
""")
@tsukkee
tsukkee / wrapper_for_afxbeginthread.cpp
Created January 26, 2011 10:44
A wrapper function for AfxBeginThread
// [Reference]
// Cのコールバック関数をC++のメンバ関数にバインディングする方法 - kazuhoのメモ置き場
// http://d.hatena.ne.jp/kazuhooku/20110126/1296031454
template <typename T, UINT (T::*THREAD_PROC)()>
UINT ToThreadCallback(LPVOID pParam)
{
return (static_cast<T *>(pParam)->*THREAD_PROC)();
}
@tsukkee
tsukkee / fizzbuzz-c++0x.cpp
Created January 25, 2011 13:11
FizzBuzz with C++0x lambda
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <iterator>
static const int SIZE = 100;
int main(int argc, char const* argv[])
{
@tsukkee
tsukkee / Omake.cs
Created January 21, 2011 07:03
C#'s ternery operator needs left hand side?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TernaryOperatorTest
{
class Program
{
static void Main(string[] args)
@tsukkee
tsukkee / tabnumber.css
Created December 8, 2010 18:49 — forked from caisui/gist:733339
numbering on each tab for Firefox
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
#TabsToolbar {
counter-reset: tabnumber;
}
#TabsToolbar tab {
counter-increment: tabnumber;
}
@tsukkee
tsukkee / nerdtree_unite_filerec.vim
Created October 31, 2010 13:54
NERDTreeで選択したノードからUnite file_recする
if exists("g:loaded_nerdtree_unite_filerec")
finish
endif
let g:loaded_nerdtree_unite_filerec = 1
if !exists(':Unite')
echoerr 'This plugin requires unite.vim'
finish
endif
@tsukkee
tsukkee / unite_kind_jump_list.diff
Created October 22, 2010 18:35
autoload/kinds/jump_list.vim (2010/10/22 19:27:02, 9c0fd7eb049708de6a4e3256fb090b0072c51c68) に対するパッチです
diff --git a/autoload/unite/kinds/jump_list.vim b/autoload/unite/kinds/jump_list.vim
index 15d6603..6c7b494 100644
--- a/autoload/unite/kinds/jump_list.vim
+++ b/autoload/unite/kinds/jump_list.vim
@@ -61,8 +61,8 @@ let s:kind.action_table.preview = {
function! s:kind.action_table.preview.func(candidate)"{{{
execute 'pedit'
\ (has_key(a:candidate, 'line') && a:candidate.line != '' ? '+'.a:candidate.line : '')
- \ (has_key(a:candidate, 'pattern') && a:candidate.pattern != '' ? '+/'.substitute(escape(a:candidate.pattern, '\. ', 'g'), '[\[\]~/^$]', '\\\\\0', 'g') : '')
- \ '`=a:candidate.word`'
@tsukkee
tsukkee / unite_sources_tags.vim
Created October 20, 2010 14:22
tags and tags/help sources for unite.vim
" tags, tags/help sources for unite.vim
" Version: 0.0.1
" Last Change: 20 Oct 2010
" Author: tsukkee <takayuki0510 at gmail.com>
" Licence: The MIT License {{{
" Permission is hereby granted, free of charge, to any person obtaining a copy
" of this software and associated documentation files (the "Software"), to deal
" in the Software without restriction, including without limitation the rights
" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
" copies of the Software, and to permit persons to whom the Software is
@tsukkee
tsukkee / move_cursor_with_tmux.vim
Created October 17, 2010 13:32
Vimとtmuxのウィンドウを区別せずに移動したい
function! MoveCursorWithTmux(vim_dir, tmux_dir)
let old_winnr = winnr()
execute "normal! \<C-w>" . a:vim_dir
" フォーカスがうつってなかったら
if old_winnr == winnr()
silent call system('tmux select-pane -' . a:tmux_dir)
endif
endfunction
@tsukkee
tsukkee / scroll_bench.c
Created October 1, 2010 03:55
scroll benchmark script for iTerm2
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
void setline(char *s, int n)
{
int l = random() % n;
int j;
for(j = 0; j < l; ++j) {
s[j] = 'A' + (random() % 60);