Skip to content

Instantly share code, notes, and snippets.

@tkrkt
tkrkt / bear_add-tweet.js
Last active May 17, 2019 06:53
[Alfred] [Bear] append tweet to bear
// with input as query
function run() {
const id = "<note-id>";
const app = Application.currentApplication();
app.includeStandardAdditions = true;
const d = new Date();
const time = `${d.getFullYear()}/${d.getMonth() + 1}/${d.getDate()} ${d.getHours()}:${d.getMinutes()}`;
const text = `{query}\n${time}\n----`;
import { useReducer, useCallback, useRef, useLayoutEffect } from "react";
type Thunk<S, A = any> = (
dispatch: ThunkDispatch<S, A>,
getState: () => S
) => void;
type ThunkDispatch<S, A> = (action: A | Thunk<S, A>) => void;
const isThunk = <S, A>(e: any): e is Thunk<S, A> => {
@tkrkt
tkrkt / google-translate-fix-balloon-styles.user.js
Created December 27, 2018 14:53
[userscript] [GoogleTranslate] Fix balloon styles
// ==UserScript==
// @name [GoogleTranslate] Fix balloon styles
// @namespace https://gist.github.com/tkrkt
// @include http://translate.googleusercontent.com/*
// @version 1
// @grant none
// ==/UserScript==
const style = document.createElement("style");
style.textContent = `
@tkrkt
tkrkt / qiitadeck-gray-visited-links.user.js
Created October 31, 2018 05:24
[userscript] [QiitaDeck] Gray visited links
@tkrkt
tkrkt / tabelog-add-to-google-calendar.user.js
Last active November 2, 2018 07:54
[userscript] [tabelog] Add current shop to Google Calendar from send link (need to fix start/end date)
// ==UserScript==
// @name [tabelog] Add to Google Calendar
// @namespace https://gist.github.com/tkrkt
// @description Add current shop to Google Calendar from send link (need to fix start/end date)
// @version 1
// @match https://tabelog.com/*
// @grant none
// ==/UserScript==
const descArea = document.querySelector('.js-rst-info.infosend__textarea');
@tkrkt
tkrkt / karabiner.json
Last active October 25, 2018 08:01
keymap
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@tkrkt
tkrkt / amazon-calc.js
Last active October 13, 2018 09:33 — forked from polamjag/amazon-calc.js
Amazonで買ったもの集計
// 使い方:
// 1. 全部コピーする (右上の Raw をクリックした先でやるのが楽)
// 2. Amazon の注文履歴ページ ( https://www.amazon.co.jp/gp/css/order-history/ ) を開く
// 3. F12 または 右クリ→要素の検証 とかで出てくる開発者ツールのコンソール (JavaScript REPL) にペースト
// 4. エンターで実行
//
// format:
// type outputJSON = Array<{
// product: string; // ファイル名
// href: string; // 商品ページURL
// ==UserScript==
// @name [Qiita] word-break normal
// @namespace https://gist.github.com/tkrkt
// @version 1
// @author tkrkt
// @match https://qiita.com/*
// @grant none
// ==/UserScript==
const style = document.createElement('style');
@tkrkt
tkrkt / download.js
Created April 5, 2018 03:46
How to download files on WebExtension
// Use an A tag
// Firefox: OK, Chrome: NG
// Waiting with setTimeout is dirty
const downloadWithATag = (filename, text) => {
const blob = new Blob([text], {type: 'text/plain;charset=utf-8'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
@tkrkt
tkrkt / NumberMap.java
Last active March 23, 2018 04:10
[Java] I want to write more elegantly
import java.util.HashMap;
public class NumberMap {
HashMap<String, Number> map = new HashMap<>();
public void put(String key, Number value) {
if (value instanceof Double
|| value instanceof Float
|| value instanceof Integer
|| value instanceof Long