Skip to content

Instantly share code, notes, and snippets.

View hrdtbs's full-sized avatar
🎯
I may be slow to respond.

🐊💤 hrdtbs

🎯
I may be slow to respond.
View GitHub Profile
@hrdtbs
hrdtbs / swipe-vs-pan.md
Last active April 12, 2018 08:59
スワイプジェスチャーとパンジェスチャー

スワイプジャスチャーとパンジャスチャーは共にタッチポイントの並進移動を伴うものですが、両者の関係はスワイプジャスチャー ⊆ パンジャスチャーです。

つまりスワイプは常にパンですが、パンはスワイプでない可能性があります。この違いはレコグナイザーによるものです。

レコグナイザーについて

パンジャスチャーのレコグナイザーでは、並進移動の開始を探して、時間の経過とともにどの方向にも移動を報告し続けるのに対して、 スワイプジャスチャーのレコグナイザーはユーザーのタッチが必要な方向に直線的に移動したかどうかを瞬時に判断します。

@hrdtbs
hrdtbs / python-jupyter-on-mac.sh
Created April 7, 2018 03:58
MacでJupyterをとりあえず動かす
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install python3
pip3 install jupyter
jupyter notebook
@hrdtbs
hrdtbs / revert-a-commit.md
Created April 7, 2018 06:48 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@hrdtbs
hrdtbs / object-promise-all.js
Created April 10, 2018 06:19
object promise all
function asyncPrint(str, time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log(`${new Date()}: ${str}`);
resolve(`value ${str}`);
}, time);
});
}
const objectZip = (keys, values) =>
@hrdtbs
hrdtbs / nightmare-sample.js
Created April 10, 2018 06:37
Nightmare Sample
const Nightmare = require('nightmare')
async function getLatestDate(n, url) {
n.goto(url) // ページへ移動
// 任意のJavaScriptを実行
return n.evaluate(() => document.querySelector('.newsList').children[0].firstChild.textContent.trim())
}
!(async() => {
try {
const each = (object, callback) => {
for (key in object) {
const val = object[key];
if (callback.call(val, key, val) === false) {
break;
}
}
return object;
};
const pararels = async promises => {
const objectZip = (keys, values) =>
keys.reduce(
(others, key, index) => ({
...others,
[key]: values[index]
}),
{}
);
return objectZip(
export { default as login } from "./login";
export { default as auth } from "./auth";
@hrdtbs
hrdtbs / package.json
Created April 24, 2018 12:03
deploy gh-pages
{
"scripts": {
"setup:gh-pages":
"git checkout --orphan gh-pages && git reset --hard && git checkout master && git worktree add dist gh-pages",
"deploy:gh-pages":
"cd dist && git add --all && git commit -m \"Deploy to gh-pages\" && git push origin gh-pages && cd ../"
},
}