Skip to content

Instantly share code, notes, and snippets.

View torufurukawa's full-sized avatar

Toru Furukawa torufurukawa

View GitHub Profile
@torufurukawa
torufurukawa / hello.js
Created May 12, 2020 14:17
Next.js cookie-session example
// pages/api/hello.js
import CookieSession from 'cookie-session'
const cookieSession = CookieSession({ name: 'session', keys: ['foo', 'bar'] })
function runMiddleware(req, res, fn) {
return new Promise((resolve, reject) => {
fn(req, res, result => {
if (result instanceof Error) {
return reject(result)
@torufurukawa
torufurukawa / google-script-run-promise.js
Last active October 20, 2023 10:13
Make google.script.run looks a promise
// Converted https://gist.github.com/shrugs/44cfb94faa7f09bcd9cb for ES6
function scriptRunPromise() {
const gs = {};
// google.script.run contains doSomething() methods at runtime.
// Object.keys(goog.sscript.run) returns array of method names.
const keys = Object.keys(google.script.run);
// for each key, i.e. method name...
@torufurukawa
torufurukawa / image-uploader.html
Last active June 5, 2019 04:10
Image Uploader
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Image Uploader</title>
</head>
@torufurukawa
torufurukawa / main1.py
Created December 12, 2018 05:35
Twitter Direct Message Chatbot example
# coding: utf8
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
@torufurukawa
torufurukawa / mkgoenv
Created March 21, 2017 13:51
mkgoenv
#!/bin/bash
# activate
cat << 'EOS' > activate
export GOPATH=$(pwd)
export PATH=${PATH}:$(pwd)/bin
EOS
# VS Code setting
mkdir -p .vscode
@torufurukawa
torufurukawa / keybindings.json
Created February 4, 2017 11:54
VS Code key bindings
// 既定値を上書きするには、このファイル内にキー バインドを挿入します
[
// Moving cursor
{ "key": "ctrl+p", "command": "cursorUp",
"when": "editorTextFocus" },
{ "key": "ctrl+n", "command": "cursorDown",
"when": "editorTextFocus" },
{ "key": "ctrl+f", "command": "cursorRight",
"when": "editorTextFocus"},
{ "key": "ctrl+b", "command": "cursorLeft",
package main
import (
"fmt"
"math/rand"
)
func main() {
var p Point = Point{2, 3}
var q Quality = Quality{99.9}
package main
import (
"fmt"
)
func main() {
in1 := make(chan int)
in2 := make(chan string)
done := make(chan bool)
@torufurukawa
torufurukawa / keymap.cson
Created November 18, 2016 00:12
Atom keymap settings
# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("hello")