Skip to content

Instantly share code, notes, and snippets.

View kawarimidoll's full-sized avatar
🦕
#Deno

カワリミ人形 kawarimidoll

🦕
#Deno
View GitHub Profile
@kawarimidoll
kawarimidoll / asset_tag_helper.rb
Last active December 27, 2020 08:22
Easy way to use lazy image_tag in Ruby on Rails
module ActionView::Helpers::AssetTagHelper
alias rails_image_tag image_tag
def image_tag (source, options = {})
options[:loading] ||= 'lazy'
rails_image_tag(source, options)
end
end
@kawarimidoll
kawarimidoll / URL-to-QR.md
Last active January 12, 2021 06:02
A bookmarklet that shows the URL of the current page as a QR code on a modal window

A bookmarklet that shows the URL of the current page as a QR code on a modal window. Click the background to close the modal.

javascript:((modal,fixed,mid)=>{modal.style=fixed;modal.innerHTML=`<div style="${fixed};left:0;top:0;width:100%;height:100%;background-color:#000C;cursor:pointer" onclick="this.parentNode.parentNode.removeChild(this.parentNode)"></div><p style="${fixed}${mid};color:white;font-size:3em">wait...</p><img style="${fixed}${mid}" src="https://chart.googleapis.com/chart?cht=qr&chs=256x256&chco=000022&chl=${location.href}">`;document.body.appendChild(modal)})(document.createElement("div"),"position:fixed",";left:50%;top:50%;transform:translate(-50%,-50%)")
@kawarimidoll
kawarimidoll / README.md
Last active July 8, 2021 07:09
denotree

denotree

tree powered by Deno 🦕

This automatically respects .gitignore.

install

$ deno install --allow-read --allow-run --force --name denotree https://gist.githubusercontent.com/kawarimidoll/c6f1c1007370b00bd4d345525490cdb8/raw/af0ed893aec412bbf1dcb0e4a87f56507ef831b8/tree.ts
@kawarimidoll
kawarimidoll / dynamo_sample.js
Created August 9, 2021 02:41
Deno Deploy x DynamoDB
// https://deno.com/deploy/docs/tutorial-dynamodb
import {
json,
serve,
validateRequest,
} from "https://deno.land/x/sift@0.1.4/mod.ts";
// AWS has an official SDK that works with browsers. As most Deno Deploy's
// APIs are similar to browser's, the same SDK works with Deno Deploy.
// So we import the SDK along with some classes required to insert and
@kawarimidoll
kawarimidoll / README.md
Last active December 1, 2021 15:12
Auto-Update Deno Dependencies

Auto-Update Deno Dependencies

Create .github/workflows/udd.yml. This workflow checks updates of the modules imported in all .ts files and creates PR like this.

If you want just to check update dependencies, use cdd.yml instead of udd.yml. Running cdd.yml fails when there is updates, then you can get a notification.

@kawarimidoll
kawarimidoll / arg_opt_sample.sh
Last active March 10, 2024 15:00
Process arguments and options in shell script
#!/bin/bash
usage() {
cat << EOS >&2
sample.sh
USAGE:
bash arg_opt_sample.sh [options] <arg1> [arg2]
ARGS:
@kawarimidoll
kawarimidoll / README.md
Last active November 27, 2021 01:55
Auto Run Deno in Neovim

Auto Run Deno in Neovim

Copy DenoRun in your init.vim.

When you run :DenoRun in Deno script file, deno run will be started the terminal window. If the name of the file is match with Deno test files, deno test will be started instead of deno run. It automatically add -A --no-check --unstable --watch for productivity. Use this only in your own files for your security.

This works only in Neovim, not Vim, because Vim has different terminal API.

@kawarimidoll
kawarimidoll / README.md
Last active November 26, 2021 16:28
get DENO_DIR
@kawarimidoll
kawarimidoll / MergeHighlight.vim
Last active December 9, 2021 00:59
Merge highlight in Vim or Neovim
command! -nargs=+ -complete=highlight MergeHighlight call s:MergeHighlight(<q-args>)
function! s:MergeHighlight(args) abort "{{{
let l:args = split(a:args)
if len(l:args) < 2
echoerr '[MergeHighlight] At least 2 arguments are required.'
echoerr 'New highlight name and source highlight names.'
return
endif
" skip 'links' and 'cleared'
@kawarimidoll
kawarimidoll / README.md
Last active December 3, 2022 11:13
Define keymappings for multiple modes at once in Vim or Neovim

multiple_keymap.vim

Define keymappings for multiple modes at once in Vim or Neovim.

Installation

Put codes in your configuration file, such as .vimrc or init.vim.

Usage