Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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(