Skip to content

Instantly share code, notes, and snippets.

@ynkdir
ynkdir / shallowcopy.go
Last active August 29, 2015 14:23
shallowcopy: copy directory tree with hard link (cp -rpl)
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"time"
)
@ynkdir
ynkdir / search_multibyte_bce.diff
Created July 9, 2015 11:11
patch for search('multi-byte', 'bce')
diff -r bfc3682510d6 src/search.c
--- a/src/search.c Sat Jul 04 15:05:14 2015 +0200
+++ b/src/search.c Thu Jul 09 19:13:39 2015 +0900
@@ -548,6 +548,7 @@
pos_T start_pos;
int at_first_line;
int extra_col;
+ int start_char_len;
int match_ok;
long nmatched;
@ynkdir
ynkdir / ctrlshiftkey.c
Last active August 29, 2015 14:27
vim ctrl-shift-b
// cl /LD ctrlshiftkey.c user32.lib
#include <windows.h>
#ifdef _MSC_VER
# define EXPORT __declspec(dllexport)
# else
# define EXPORT
#endif
diff --git a/src/ops.c b/src/ops.c
index 62d88a7..7fda2c7 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -5407,6 +5407,8 @@ do_addsub(command, Prenum1, g_cmd)
int did_change = FALSE;
pos_T t = curwin->w_cursor;
int maxlen = 0;
+ pos_T startpos;
+ pos_T endpos;
@ynkdir
ynkdir / abcdiff.cpp
Last active August 29, 2015 14:27
abcdiff(仮)
// cl /Idtl abcdiff.cpp
// https://github.com/cubicdaiya/dtl
#include <dtl/dtl.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
@ynkdir
ynkdir / test_scrollwindowex.c
Last active September 5, 2015 14:07
ScrollWindowEx() does not scroll out text occationally.
#include <windows.h>
#include <stdio.h>
#include <string.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) {
HWND hwnd;
MSG msg;
WNDCLASSEX cls;
@ynkdir
ynkdir / patiencediff.go
Last active September 9, 2015 09:20
patiencedif.go
package main
// Patience Diff Advantages
// http://bramcohen.livejournal.com/73318.html
//
// Patience Diff, a brief summary
// http://alfedenzo.livejournal.com/170301.html
//
// 1. Match the first lines of both if they're identical, then match the
// second, third, etc. until a pair doesn't match.
@ynkdir
ynkdir / nicodownload.js
Created January 17, 2011 09:13
ニコニコ動画ダウンロードブックマークレット
(function(){
var http_get = function(url) {
var async = false;
var req = new XMLHttpRequest();
req.open("GET", url, async);
req.withCredentials = true;
req.send();
return req.responseText;
};
@ynkdir
ynkdir / rand_glibc.vim
Created January 17, 2011 12:42
glibc rand()
" glibc-2.12.1: random_r.c
let s:RAND_MAX = 2147483647
function! Srand(seed)
call s:srandom_r(a:seed, s:state)
endfunction
function! Rand()
return s:random_r(s:state)
@ynkdir
ynkdir / rand_msvc.vim
Created January 17, 2011 12:41
msvcrt rand()
" Visual C++ 2010: rand.c
let s:RAND_MAX = 32767
let s:seed = 0
function! Srand(seed)
let s:seed = a:seed
endfunction