Skip to content

Instantly share code, notes, and snippets.

@ynkdir
ynkdir / str_iconv.c
Created March 4, 2011 09:44
str_iconv.c
/* str_iconv() function */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <iconv.h>
static char *
str_iconv(const char *fromcode, const char *tocode, const char *str, size_t len)
@ynkdir
ynkdir / backslashreplace.py
Created March 12, 2011 16:29
codecs backslashreplace for decode()
# codecs backslashreplace for decode()
# encoding: utf-8
from __future__ import unicode_literals
import sys
import codecs
_backslashreplace_errors = codecs.backslashreplace_errors
@ynkdir
ynkdir / nsexample.vim
Created March 13, 2011 05:28
nsexample.vim
" 基本アイデア: 名前空間を実行時の環境に合わせることでファイルの変更なし
" にコピーできるようにする。
let s:ns = expand('<sfile>:p:r:gs?[\\/]?#?:s?^.*#autoload#??:s?$?#?')
function {s:ns}func()
echo "func()"
endfunction
@ynkdir
ynkdir / vim-crash.sh
Created March 22, 2011 22:18
vim-crash.sh ubuntu 10.10 glibc iconv bug
# ubuntu 10.10 glibc iconv
echo 83d9 | xxd -r -p > test.txt
vim -c "edit ++enc=cp932 test.txt"
# Vim: Caught deadly signal SEGV
# Vim: Finished.
# Segmentation fault
#
# vim/src/fileio.c
@ynkdir
ynkdir / imgdiff.html
Created March 31, 2011 14:47
github like image diff
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8" />
<title>github like image diff</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/ui-lightness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>
@ynkdir
ynkdir / getopt.js
Created April 9, 2011 23:43
getopt.js
// Python.getopt
var getopt = (function() {
var POSIXLY_CORRECT = false;
function Array_indexOf(haystack, needle, start) {
var i;
if (start === undefined) {
start = 0;
@ynkdir
ynkdir / gist:1085982
Created July 16, 2011 03:48
:syntax の \zs と \@<=
等幅フォント表示
単純化して説明してみます。
\zs について。
:syntax match Attr1 /\(http:\/\/\S\+\s\+\)\zs\(\S\+\)/
\zs と \ze はパターンとしては意味を持ちません。
@ynkdir
ynkdir / gist:1241997
Created September 26, 2011 10:38
ファイルを開き直したときのカーソルのあやしい移動
ファイルを開き直したときのカーソルのあやしい移動
# make test file
$ vim -u NONE -c "call setline('.', range(1, 100))" -c "wq" foo.txt
$ vim -u NONE
:edit foo.txt " open file
:$ " move to last line
:split " split
@ynkdir
ynkdir / gist:1242161
Created September 26, 2011 12:54
:help の検索でエラーがでる
:help の検索でエラーがでる
バックスペースでエスケープすればエラーはでなくなるが…
:help /\%(\)
:help s/\1
:help s/\2
:help s/\3
:help s/\9
:help s/\~
@ynkdir
ynkdir / fix-tag-search-with-encoding.diff
Created September 29, 2011 12:34
fix tag search with !_TAG_FILE_ENCODING
diff -r 15b934a16641 src/tag.c
--- a/src/tag.c Wed Sep 14 19:04:40 2011 +0200
+++ b/src/tag.c Wed Oct 05 08:49:02 2011 +0900
@@ -1360,13 +1360,9 @@
char_u *saved_pat = NULL; /* copy of pat[] */
#endif
- /* Use two sets of variables for the pattern: "orgpat" holds the values
- * for the original pattern and "convpat" converted from 'encoding' to
- * encoding of the tags file. "pats" point to either one of these. */