Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Writing in Haskell, TypeScript, or Power Automate

YAMAMOTO Yuji igrep

:shipit:
Writing in Haskell, TypeScript, or Power Automate
View GitHub Profile
@igrep
igrep / translate-mdn-ja-nvim.vim
Last active March 18, 2023 05:41
MDNの翻訳中、現在開いている英語版のパスを日本語版のパスに変換して開く(WindowsのNeovimで動かしていて、なおかつtranslated-contentとcontentが同じディレクトリーにある前提なので注意)
View translate-mdn-ja-nvim.vim
function! ToJaPath(enPath) abort
" e.g. content\files\en-us\glossary\boolean\html\index.md
return substitute(a:enPath, '^content\\files\\en-us', 'translated-content\\files\\ja', '')
endfunction
function! PrepareJaPath() abort
let path_to_index_md = ToJaPath(expand('%'))
call mkdir(v:lua.vim.fs.dirname(path_to_index_md), "p")
return path_to_index_md
endfunction
@igrep
igrep / no-empty.hs
Created November 16, 2022 09:33
Example type class for a type-level list with no instance for an empty list.
View no-empty.hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
import Data.Kind (Type)
data ExampleData (as :: [Type]) = ExampleData
@igrep
igrep / bookmarklet.js
Last active January 28, 2023 14:27
Replace a YouTube Short video's URL into traditional one. YouTubeのShortのURLを従来の形式のURLに書き換える
View bookmarklet.js
javascript:location.href="https://www.youtube.com/watch?v="+location.href.slice(`${location.origin}/shorts/`.length)
@igrep
igrep / rewrite-the-only-case-where-I-use-let-in.hs
Last active April 13, 2021 03:19
唯一let ... inを使いたくなる瞬間をdoのletでどうにかする
View rewrite-the-only-case-where-I-use-let-in.hs
import Test.Hspec
import Test.Hspec.QuickCheck
import Test.QuickCheck
-- 従来、Hspecで個別のテストケースに対して Gen を定義したい場合、
-- いちいち違う名前を付けるのが面倒なので let ... in で g (あるいはgen)という名前を使い回していたが、
-- 別にそれもdoの中のletで解決できることが発覚した。
main = hspec $ do
-- let ... inを使った場合
@igrep
igrep / lets-in-do.hs
Created April 13, 2021 02:49
do記法の中でletやlet ... inを使ったサンプル
View lets-in-do.hs
main = do
-- let ... in を使った場合
let f :: String -> IO ()
f = putStrLn
in f "f"
-- ただの let を使った場合(こっちの方が大抵おすすめ!)
let g :: String -> IO ()
g = putStrLn
g "g"
@igrep
igrep / download-from-m3u8.hs
Created February 20, 2021 08:27
Download and concatenate videos from a m3u8 file in Twitter etc.
View download-from-m3u8.hs
#!/usr/bin/env stack
{- stack --resolver lts-17.4 script
--package=typed-process
--package=filepath
--package=modern-uri
--package=text
-}
{-# LANGUAGE OverloadedStrings #-}
@igrep
igrep / list-google-shopping-list-items.js
Created September 1, 2020 14:23
For bookmarklet: List (and select to copy) the items in Google Shopping List
View list-google-shopping-list-items.js
prompt("Copy", [...document.getElementsByClassName('listItemTitle')].map(e => e.innerText).join("\n"))
@igrep
igrep / add-item-to-google-shopping-list.js
Created August 27, 2020 12:29
Function to a given item to Google Shopping List. Paste the code in the DevTools' console!
View add-item-to-google-shopping-list.js
const input = document.getElementsByClassName("listItemInput")[0];
const form = document.getElementsByClassName("addForm")[0];
function addItem(name){
input.dispatchEvent(new Event("focus"));
input.value = name;
input.dispatchEvent(new Event("input"));
form.dispatchEvent(new Event("submit"));
}
@igrep
igrep / simulate-left-below-above-right.vim
Created February 11, 2020 11:04
Simulate left, below, above, and right actions of unite.vim with denite.nvim
View simulate-left-below-above-right.vim
function! Denite_do_open(split_cmd, context) abort
execute(a:split_cmd)
call denite#do_action(a:context, 'open', a:context['targets'])
endfunction
call denite#custom#action('openable,file,buffer,directory', 'left', funcref('Denite_do_open', ['leftabove vsplit']))
call denite#custom#action('openable,file,buffer,directory', 'below', funcref('Denite_do_open', ['rightbelow split']))
call denite#custom#action('openable,file,buffer,directory', 'above', funcref('Denite_do_open', ['leftabove split']))
call denite#custom#action('openable,file,buffer,directory', 'right', funcref('Denite_do_open', ['rightbelow vsplit']))
View asmtut1-1.s
.text
.global _start
_start:
MOV X0, #65
MOV X8, #93
SVC 0