Skip to content

Instantly share code, notes, and snippets.

function fzf-translate() {
local out snippet key file candidate fzf_command command
fzf_command="fzf --multi --phony --print-query --expect=ctrl-m,ctrl-q --bind=\"change:reload:echo '{q}' | nextword | tr ' ' '\n' | xargs -I WORD echo 'WORD' \" --preview='google-trans {q}'"
IFS=$'\n' out=$(eval "echo '' | ${fzf_command}")
while true; do
query=$(echo "$out" | head -1)
key=$(echo "$out" | head -2 | tail -1)
FZF_GH_PR_EXTRA_ARG=${FZF_GH_PR_EXTRA_ARG:-''}
FZF_GH_PR_BINDKEY=${FZF_GH_PR_BINDKEY:-'^x^p^r'}
function fzf-gh-pr-selection() {
local out pr key fzf_command command
pr_list_command='gh pr list'
fzf_command='fzf --query "$LBUFFER" --prompt="Pull Request> " --preview="gh pr view {1}" --expect=ctrl-o,ctrl-c'
command="$pr_list_command | $fzf_command"
# frozen_string_literal: true
require 'gruff'
def calc_score(start_day, stop = 1000)
score = []
card = 0
0.step(1000, 20) do |day|
card += 6 if start_day < day && day < stop
@yuki-yano
yuki-yano / ducks.tsx
Last active January 20, 2021 08:36
typescript-redux-thunk-sample
import axios from "axios"
import { Reducer, Dispatch } from "redux"
import Cookies from "js-cookie"
export type UserState = {
accessToken: string
loggingIn: boolean
error: string
}
@yuki-yano
yuki-yano / ducks.tsx
Last active January 2, 2019 07:41
typescript-fsa-redux-thunk-sample
import axios from "axios"
import { Dispatch } from "redux"
import actionCreatorFactory from "typescript-fsa"
import { reducerWithInitialState } from "typescript-fsa-reducers"
import { asyncFactory } from "typescript-fsa-redux-thunk"
import Cookies from "js-cookie"
export type UserState = {
accessToken: string
loggingIn: boolean
@yuki-yano
yuki-yano / javascript_typescript_generate_dictionary.js
Last active November 18, 2018 05:21
Generate JS and TS dictionary from Microsoft/TypeScript
const fs = require("fs");
const { TypescriptParser } = require("typescript-parser");
function printWord(parsed) {
for (let usage of parsed.usages) {
console.log(usage);
}
for (let declaration of parsed.declarations) {
if (declaration.name) {
console.log(declaration.name);
@yuki-yano
yuki-yano / Switch_Command_and_Option_in_Terminal.json.erb
Last active July 4, 2018 08:25
Switch Option to Meta in Terminal and alacritty
{
"title": "Switch Option to Meta in Terminal and alacritty",
"rules": [
{
"description": "Switch Option to Meta in Terminal and alacritty",
"manipulators":
<%=
TerminalKeys = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
each_key(
source_keys_list: TerminalKeys,
#include <TimerOne.h>
/**
* デバッグ出力の切り替え
*/
#define DEBUG_MODE 0
/**
* 最大入力受付数
*/
@yuki-yano
yuki-yano / imperial.py
Last active March 22, 2018 11:32
imperial
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Imperial
# ======
# Copyright (C) 2015 FTG-Reversal
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@yuki-yano
yuki-yano / GoogleTranslation.vim
Last active June 8, 2017 09:23
Google Translation from vim. require translategoogle.vim
function! TransRange() range
let texts = []
for n in range(a:firstline, a:lastline)
let line = getline(n)
call substitute(line, '\n\+$', ' ', '')
call add(texts, line)
endfor
10new | put!=translategoogle#command(join(texts))
endfunction