Skip to content

Instantly share code, notes, and snippets.

@5t111111
5t111111 / rds-setsuzoku-chan
Last active September 5, 2023 00:01
rds-setsuzoku-chan (RDS接続ちゃん) is a utility script to establish a AWS Systems Manager - Session Manager port-forwarding connection for Amazon RDS via a bastion host.
#!/usr/bin/env bash
set -euo pipefail
#===============================================================================
# rds-setsuzoku-chan (RDS SETSUZOKU CHAN)
#
# <README>
# https://gist.github.com/5t111111/5e864858250c555da9e4232242af1591#file-rds-setsuzoku-chan-md
#===============================================================================
@5t111111
5t111111 / qr.ts
Created June 22, 2021 03:22
Simple QRCode generator for Deno Deploy
/**
* Simple QRCode generator for Deno Deploy
*/
import { qrcode } from "https://deno.land/x/qrcode/mod.ts";
addEventListener("fetch", async (event) => {
const url = new URL(event.request.url);
const params = new URLSearchParams(url.search);
const text = params.get("text");
@5t111111
5t111111 / README.md
Last active May 31, 2021 12:56
Get music key (scale) from notes used in it

Usage

  1. Install Deno
  2. Run
deno run https://gist.githubusercontent.com/5t111111/698c87f8ee518f4db737bd00502695f1/raw/get-music-key-from-notes.ts C E F

The above will output:

interface UploadPayload {
public_id: string;
version: number;
width: number;
height: number;
format: string;
resource_type: string;
created_at: string;
tags: string[];
pages: number;
@5t111111
5t111111 / vscode-rust-setup.md
Created June 16, 2018 04:26
VSCode Rust Setup

Install RLS (Rust Language Server)

You have to setup nightly release channel toolchain.

rustup install nightly
rustup update nightly
@5t111111
5t111111 / MyMiddleware.swift
Created May 14, 2018 03:09
Vapor 3.0 middleware
import Vapor
public final class MyMiddleware: Middleware {
public init() {
}
public func respond(to req: Request, chainingTo next: Responder) throws -> Future<Response> {
return try next.respond(to: req).map { res in
if req.http.headers.contains(name: "X-NYA-N") {
res.http.headers.add(name: "X-NYA-N", value: "RESPONSE")
@5t111111
5t111111 / gatsby-node.js
Created March 14, 2018 02:42
gatsbyでURLを `/YYYY/MM/DD/slug` という形式にする
...
exports.onCreateNode = ({ node, getNode, boundActionCreators }) => {
const { createNodeField } = boundActionCreators;
if (node.internal.type === 'MarkdownRemark') {
// Create slug with post date directory structure
const createSlug = (postDate, filePath) => {
const year = postDate.getFullYear();
const month = `0${postDate.getMonth() + 1}`.slice(-2); // month with zero padding
@5t111111
5t111111 / gatsby-node.js
Created March 14, 2018 02:42
gatsbyでURLを `/YYYY/MM/DD/slug` という形式にする
...
exports.onCreateNode = ({ node, getNode, boundActionCreators }) => {
const { createNodeField } = boundActionCreators;
if (node.internal.type === 'MarkdownRemark') {
// Create slug with post date directory structure
const createSlug = (postDate, filePath) => {
const year = postDate.getFullYear();
const month = `0${postDate.getMonth() + 1}`.slice(-2); // month with zero padding
@5t111111
5t111111 / IdeaVim OS X Key Repeat.markdown
Created April 12, 2017 14:43 — forked from lsd/IdeaVim OS X Key Repeat.markdown
Enable key-repeat for ALL applications or just for IdeaVim/specific JetBrains apps

Upgrading to Lion or Yosemite and WebStorm 9, I noticed key repeat was
turned off for the IdeaVim plugin h j k l keys.

System-wide key repeat

defaults write -g ApplePressAndHoldEnabled -bool false in a terminal will enable
key repeat for every app. This can alternatively be found in the accessibility settings in OS X' preferences.

App specific key repeat

@5t111111
5t111111 / conv_hist_from_zsh_to_fish.sh
Created April 4, 2017 17:01
Convert zsh history to fish history fomat
fc -lni 1 | ruby -rtime -r yaml -e 'puts STDIN.inject([]) { |a, l| a << { "cmd" => l[16..-1].strip, "when" => Time.parse(l[0..15]).to_i } }.to_yaml(options = {:line_width => -1})' > ~/.local/share/fish/histfile-from-zsh