Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
Hello!

Keitaroh Kobayashi keichan34

👋
Hello!
View GitHub Profile
@keichan34
keichan34 / NewWindowPortal.tsx
Created Sep 11, 2020
Open a new window with a React portal
View NewWindowPortal.tsx
import React, { useEffect, useMemo, useRef } from "react"
import { createPortal } from "react-dom"
const NewWindowPortal: React.FC = ({children}) => {
const containerEl = useMemo(() => document.createElement("div"), [])
useEffect(() => {
if (!containerEl) {
return
}
@keichan34
keichan34 / config.fish
Created Apr 17, 2020
My Fish-shell config
View config.fish
function fish_greeting
echo "! COMPUTER_NAME"
end
set -x EDITOR vim
set -x LESS -asrRix8
set -x LANG en_US.UTF-8
set -x LC_ALL en_US.UTF-8
set -x LANGUAGE en_US.UTF-8
@keichan34
keichan34 / package.json
Created Jul 23, 2018
hacking CRA to work with babel-plugin-relay
View package.json
{
"scripts": {
"build": "node ./setup && react-scripts build"
}
}
@keichan34
keichan34 / blurb.fish
Last active Mar 12, 2017 — forked from jeremy-w/blurb.fish
Fish function to create or reply to a social post on 10 Centuries. MPLv2
View blurb.fish
function blurb --description Post\ to\ 10C.\\nblurb\ post\ MESSAGE\\nblurb\ POST_ID\ REPLY --argument reply_id message
set -l token $TEN_CENTURIES_API_TOKEN
set -l endpoint https://api.10centuries.org/content/write
set -l usage 'blurb: post or reply to a message on 10C
Usage:
blurb post MESSAGE
Post a new blurb
View keybase.md

Keybase proof

I hereby claim:

  • I am keichan34 on github.
  • I am sleepy_keita (https://keybase.io/sleepy_keita) on keybase.
  • I have a public key ASASuKTnKfWXIiwyRu4jyTDn-i8LUj1qZLrKHeNPRBtlsAo

To claim this, I am signing this object:

@keichan34
keichan34 / hi.exs
Last active Sep 17, 2016
compile-time list
View hi.exs
defmodule Hi do
keys = ~w(hello there)a
for {key, idx} <- Enum.with_index(keys) do
def index_of_key(unquote(key)) do
{:ok, unquote(idx)}
end
def key_at_index(unquote(idx)) do
{:ok, unquote(key)}
@keichan34
keichan34 / config.fish
Last active May 26, 2016
I got tired of loading nvm every time in my fish shell, so this.
View config.fish
# Requires bass and nvm
# bass: https://github.com/edc/bass
# nvm: https://github.com/creationix/nvm
function nvm
set -g NVM_LOADED "1"
bass source ~/.nvm/nvm.sh ';' nvm $argv
end
function ensure_nvm_loaded
@keichan34
keichan34 / ses_credential_generator.exs
Created Mar 26, 2016
Amazon SES SMTP Credential Generator
View ses_credential_generator.exs
#!/usr/bin/env elixir
Application.start(:crypto)
key = case System.argv do
[key | _] -> key
_ ->
IO.puts "Usage: ses_credential_generator.exs [AWS Secret Access Key]"
exit(:shutdown)
end
@keichan34
keichan34 / .babelrc
Last active Sep 11, 2016
Sample Phoenix + Brunch (Babel) + Mocha test setup for unit tests
View .babelrc
{
"presets": ["es2015"]
}
View msd.php
<?php
header("Content-Type: application/rss+xml");
date_default_timezone_set("Asia/Tokyo");
function formatTime($duration) //as hh:mm:ss
{
$hours = floor($duration / 3600);
$minutes = floor( ($duration - ($hours * 3600)) / 60);
$seconds = $duration - ($hours * 3600) - ($minutes * 60);
You can’t perform that action at this time.