Skip to content

Instantly share code, notes, and snippets.

View mtgto's full-sized avatar

Satoshi Goto mtgto

  • Japan
  • 14:49 (UTC +09:00)
  • X @mtgto
View GitHub Profile
@mtgto
mtgto / ContentView.swift
Created August 7, 2021 07:28
isActive of NavigationLink is not work when using List with empty container. (iOS 14.5, Xcode 12.5.1, Swift 5.4)
import SwiftUI
// isActive of NavigationLink is not work when using List with empty container.
struct ContentView: View {
@State var isSubviewDisplayed: Bool = false
@State var array: [String] = []
var body: some View {
NavigationView {
List(array, id: \.self) { _ in
NavigationLink(
@mtgto
mtgto / serve.mjs
Last active August 25, 2023 03:10
Hot reload and do incremental builds with `esbuild`
/*
* Change from https://gist.github.com/unki2aut/4ac81c33be2e8f121e80a26eba1735d7
* - Use top level await (Node.js v14.8.0+)
* - To use top level await, you need to write a script as ES Modules
* - Set chokidar options to avoid duplicate building
* - Define NODE_ENV (For React)
* - Add API proxy setting by using proxy-middleware
*/
import chokidar from "chokidar";
import esbuild from "esbuild";
@mtgto
mtgto / timestamptz.sql
Created July 23, 2020 00:24
timestamptz
select time || ':00' as time, name, value
from (
values
(timestamptz '2020-07-22 09:00:00 UTC', 'b', 3)
, (timestamptz '2020-07-22 10:00:00 UTC', 'a', 1)
, (timestamptz '2020-07-22 10:00:00 UTC', 'b', 2)
) as t (time, name, value)
;
@mtgto
mtgto / New_Query.sql
Created July 22, 2020 16:33
New Query
select *
from (
values
(timestamptz '2020-07-22 09:00:00 UTC', 3)
, (timestamptz '2020-07-22 10:00:00 UTC', 1)
, (timestamptz '2020-07-22 08:00:00 UTC', 2)
) as t (time, value)
;
@mtgto
mtgto / kubecontext.py
Created April 5, 2019 23:04
Show Kubernetes context in Powerline segment (need kubernetes-py)
# -*- coding: utf-8 -*-
# I made it because below related libraries doesn't work with python 3.7.
#
# - https://github.com/zcmarine/powerkube
# - https://github.com/so0k/powerline-kubernetes
#
# NOTE: I don't understand completely how to use powerline watcher.
from kubernetes_py import K8sConfig
@mtgto
mtgto / helloworld.py
Created April 5, 2019 22:55
First step to write a new Powerline segment.
# -*- coding: utf-8 -*-
def helloworld(pl):
return [{
'contents': 'こんにちは、世界',
'highlight_groups': ['information:regular']
}]
@mtgto
mtgto / repositories
Created January 30, 2018 00:10
[~/.sbt/repositories] Use google's maven central mirror, prevent to redirect for lightbend repository.
# http://www.scala-sbt.org/1.x/docs/Launcher-Configuration.html
# https://storage-download.googleapis.com/maven-central/index.html
[repositories]
local
maven-central: https://maven-central-asia.storage-download.googleapis.com/repos/central/data/
lightbend-ivy-releases: https://dl.bintray.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
#typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-snapshots: https://oss.sonatype.org/content/repositories/snapshots
@mtgto
mtgto / ~|.sbt|repositories
Created December 26, 2017 08:47
Use Google Cloud Platform's Maven Central repository mirror for sbt
# http://www.scala-sbt.org/release/docs/Proxy-Repositories.html
# http://www.scala-sbt.org/release/docs/Launcher-Configuration.html
# https://storage-download.googleapis.com/maven-central/index.html
[repositories]
local
typesafe-ivy-releases: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
google-maven-central: https://maven-central-asia.storage-download.googleapis.com/repos/central/data/
maven-central
sonatype-snapshots: https://oss.sonatype.org/content/repositories/snapshots
@mtgto
mtgto / uploader.rb
Created January 6, 2017 07:26
Idiot simple http file uploader written by ruby. It requires sinatra.
# WARNING: This script has an enormous vulnerability!!!!!!
require 'sinatra'
get '/' do
erb <<"HTML"
<form action="upload" method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Upload" />
</form>
curl -I http://search.yahoo.co.jp/
HTTP/1.1 500 Internal Server Error
Server: nginx
Date: Mon, 13 Oct 2014 11:50:27 GMT
Content-Type: text/html
Content-Length: 186
Connection: close