Skip to content

Instantly share code, notes, and snippets.

View igrep's full-sized 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 / download-from-m3u8.hs
Created February 20, 2021 08:27
Download and concatenate videos from a m3u8 file in Twitter etc.
#!/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
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!
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
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']))
.text
.global _start
_start:
MOV X0, #65
MOV X8, #93
SVC 0
@igrep
igrep / with-intmap-dynamic.hs
Last active September 15, 2019 10:13
Simulate ST Monad without "impure" things
#!/bin/env stack
{-
stack script --resolver=lts-14.6
--package=mtl
--package=containers
-}
{-# OPTIONS -fdefer-type-errors #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RankNTypes #-}
@igrep
igrep / fact.js
Last active July 30, 2019 04:04
Roughly simulate the difference between pointfree style and pointful style. Inspired by https://kakkun61.hatenablog.com/entry/2019/07/29/%E9%96%A2%E6%95%B0%E3%81%AE%E3%83%A1%E3%83%A2%E5%8C%96
/*
fact :: Int -> Integer
fact 0 = 1
fact n = fromIntegral n * fact (n-1)
*/
const fact = function(n){
if (n == 0){
return 1;
} else {
return n * fact(n - 1);
import Data.Bits
import Data.Word
import Data.STRef
import Control.Monad.ST
import Data.Function
import Test.Hspec
import Test.Hspec.QuickCheck
#include "stdio.h"
int main()
{
int array[5];
int *p;
int i;
p = array; /* p = &array[0] と同じ */
for (i = 0; i < 5; i++) {
@igrep
igrep / switch-twitter.js
Created July 4, 2019 06:26
Switch between twitter.com and mobile.twitter.com
switch(location.hostname){
case 'twitter.com':
location.href = location.href.replace(/^https:\/\/twitter/, 'https://mobile.twitter');
break;
case 'mobile.twitter.com':
location.href = location.href.replace(/^https:\/\/mobile\.twitter/, 'https://twitter');
break;
}