Skip to content

Instantly share code, notes, and snippets.

@ginpei
ginpei / README.md
Last active April 8, 2018 19:29
TS Compiler doesn't work with @types/sinon-chai

Environment

Using WSL (Ubuntu) on Windows 10.

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
<!DOCTYPE html>
<title>Hello World!</title>
<button id="hello">Hello</button>
<script>
hello.onclick = () => alert('Hello World!');
</script>
@ginpei
ginpei / replaceWords.js
Created December 20, 2017 03:26
ページ中の単語を置き換える
{
replaceWords(/猫/g, '犬');
function replaceWords(target, result) {
const texts = [];
const els = document.querySelectorAll('title, body *:not(script):not(style)')
els.forEach(el => {
texts.push(...findTextNodes(el))
})
@ginpei
ginpei / vim.md
Last active November 12, 2017 07:11
Vim始めるぞ

Initialize

const firebase = require('firebase')
const admin = require('firebase-admin')

const serviceAccount = require('./serviceAccountKey.json')
const secret = {
	"PROJECT_ID": "xxx",
	"API_KEY": "xxx"
{
"private": "true",
"scripts": {
"js": "browserify -t [ babelify --presets [ es2015 ] ] src/main.js -o out/main.js",
"start": "watchify -v -t [ babelify --presets [ es2015 ] ] src/main.js -o 'exorcist out/main.js.map > out/main.js' -d"
},
"dependencies": {
"babel-preset-es2015": "^6.22.0",
"babelify": "^7.3.0",
"browserify": "^14.1.0",
// fetch
URL url = new URL("https://www.wikipedia.org/");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream in;
try {
in = new BufferedInputStream(connection.getInputStream());
} finally {
connection.disconnect();
}

Hubotのインストールと最初のbot生成

$ mkdir my-hubot
$ cd my-hubot
$ yo hubot
  • 色々聞かれる
  • 基本的には初期値のままenter
var opener = require('opener');
var result = opener('http://www.example.com/');
console.log(result.spawnfile, result.exitCode);
setTimeout(()=>console.log(result.spawnfile, result.exitCode),1000);