This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template <typename T> | |
| std::basic_string<T> replace_all(const std::basic_string<T>& str, const T* from, const T* to) | |
| { | |
| std::basic_string<T> ret; | |
| ret.reserve(str.length()); | |
| size_t from_len = 0; | |
| while (from[from_len]) { | |
| from_len++; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| //----------------------------------------------------------------------------- | |
| // utf8_char_len | |
| //----------------------------------------------------------------------------- | |
| template <typename T> | |
| size_t utf8_char_len(const char* str, size_t off, T eos) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func columnWidth(s string) int { | |
| runes := []rune(s) | |
| w := 0 | |
| for _, r := range runes { | |
| k := width.LookupRune(r).Kind() | |
| if k == width.EastAsianWide || k == width.EastAsianFullwidth { | |
| w = w + 2 | |
| } else { | |
| w = w + 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| i := 0 | |
| for { | |
| pc, fn, line, ok := runtime.Caller(i) | |
| if ok == false { | |
| break | |
| } | |
| fmt.Printf("[stack-%d] %s[%s:%d]\n", i, runtime.FuncForPC(pc).Name(), fn, line) | |
| i++ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "archive/zip" | |
| "io" | |
| "os" | |
| "path/filepath" | |
| "strings" | |
| ) | |
| func zipit(source, target string, needBaseDir bool) error { | |
| zipfile, err := os.Create(target) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define debug(...) { fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); } | |
| // bash> tail -f debug.log | |
| // bash> [command] 2> debug.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Expr ← Sum | |
| Sum ← Product (('+' / '-') Product)* | |
| Product ← Value (('*' / '/') Value)* | |
| Value ← [0-9]+ / '(' Expr ')' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "title": "For yhirose's HHKB", | |
| "rules": [ | |
| { | |
| "description": "Change Shift+Esc to ~", | |
| "manipulators": [ | |
| { | |
| "type": "basic", | |
| "from": { | |
| "key_code": "escape", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [alias] | |
| co = checkout | |
| st = status | |
| br = branch | |
| ci = commit | |
| l = log --date=short --pretty='format:%C(yellow)%h %C(cyan)%ad %C(green)%<(16,trunc)%an%Creset%C(yellow)%d%Creset %s' | |
| lg = log --date=short --pretty='format:%C(yellow)%h %C(cyan)%ad %C(green)%<(16,trunc)%an%Creset%C(yellow)%d%Creset %s' --graph |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <cstdlib> | |
| #include <iomanip> | |
| #include <iostream> | |
| #include <sstream> | |
| #include "peglib.h" | |
| using namespace peg; | |
| using namespace std; | |
| bool translate(const string& text, string& result) { |