This file contains 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
.cm-s-sublime-text-like.CodeMirror { | |
background-color: #242424; | |
color: #fff; | |
} | |
.CodeMirror div.CodeMirror-cursor { | |
border-left: 1px solid #f8f8f0; | |
z-index: 3; | |
} |
This file contains 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
const Sanitizer = { | |
encode: function(str) { | |
if (!str) return; | |
str = "" + str; | |
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, '''); | |
}, | |
decode: function(str) { | |
if (!str) return; | |
str = "" + str; | |
return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, '\'').replace(/&/g, '&'); |
This file contains 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
// camelCase -> hyphenCase | |
function camelToHyphenCase: function(str) { | |
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); | |
} | |
// hyphenCase -> camelCase | |
function hyphenToCamelCase(str) { | |
return str.replace(/-([a-z])/g, function(g) { | |
return g[1].toUpperCase(); | |
}); | |
} |
This file contains 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
// server/hoge.js | |
const re = /\[\[(.+?)\]\]/g; // matches '*[[hoge]]' or '* [[hoge]]' | |
const reRedirect = /^\#REDIRECT\s?\[\[(.+)\]\]/; // matches '#REDIRECT [[hoge]]' | |
const reRelatedHeader = /\=\=\s?関連項目\s?\=\=/; | |
function getEndpoint(title) { | |
title = encodeURIComponent(title); | |
return `https://ja.wikipedia.org/w/api.php?action=query&titles=${title}&prop=revisions&rvprop=content&format=json`; | |
} |
This file contains 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
// 配列の重複を削除 | |
var arr = ["", "", "hoge", "baa", "hogege", "", "foo", "", ""]; | |
var newArr = arr.filter((x, i, self) => self.indexOf(x) === i); | |
// newArr -> ["", "hoge", "baa", "hogege", "foo"] |
This file contains 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
/** | |
* dl an external image resource and append it as an img element into the rootEl | |
* | |
* @param {String} | |
* image resource's url | |
* @param {Element} Optional | |
* root element to be appended an img element. | |
* @param {Function} Optional | |
* callback function. 'function(imgEl){...}' |
This file contains 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
// manifest.json | |
/* | |
... | |
"permissions": [ | |
"*://*.amazon.co.jp/*", | |
"*://*.amazon.com/*" | |
or | |
"<all_urls>" | |
], | |
... |
This file contains 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
// buf is ArrayBuffer | |
function ab2str(buf) { | |
return td.decode(new Uint8Array(buf)); | |
} | |
function ab2dom(buf) { | |
let html = ab2str(buf); | |
let rootEl = document.createElement('html'); | |
rootEl.innerHTML = html; |
This file contains 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
// First, | |
// $ git clone https://github.com/kzahel/web-server-chrome.git | |
// $ ./minimize.sh | |
// and ... | |
// load wsc-chrome.min.js in your html | |
function request(url, headers, cb) { | |
let xhr = new WSC.ChromeSocketXMLHttpRequest; | |
let headersLen = headers.length; | |
let k, v; |
OlderNewer