Skip to content

Instantly share code, notes, and snippets.

@mootoh
mootoh / load.kt
Created November 21, 2019 10:15
Load remote image with Coil into Jetpack Compose Image
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
Column {
ItemCell(item = Item("cat 1", "https://thumbs-prod.si-cdn.com/s-rtW1rEAQTIGcmUVNFSSPC4s3I=/800x600/filters:no_upscale()/https://public-media.si-cdn.com/filer/56/4a/564a542d-5c37-4be7-8892-98201ab13180/cat-2083492_1280.jpg"))
ItemCell(item = Item("cat 2", "https://images.pexels.com/photos/104827/cat-pet-animal-domestic-104827.jpeg?auto=compress&cs=tinysrgb&h=750&w=1260"))
}
import requests
import urllib.parse
import json
from datetime import datetime
# Load configuration
with open('config.json', 'r') as f:
config = json.load(f)
# Confluence API endpoint URLs

djb

みんなそろそろ D.J. Bernstein が世界史上最高のプログラマだというのを思い出すべきだと思うんだ。

まず、客観的な事実だけを見てみよう。 djb は2つの重要なシステムソフトウェアを書いた。 メールサーバと DNS サーバだ。 どちらも何百万というドメインで使われている。 ありとあらゆる複雑な仕事をこなし、とてつもない高負荷でも問題ないし、どんな異常事態にも対応する。 これらは、Bernstein が最初にリリースしたときとまったく同じものが動いてるのだ。

@mootoh
mootoh / dayone_to_evernote.applescript
Created August 29, 2012 07:34
Create an Evernote note from DayOne journal entry.
--
-- See also: https://gist.github.com/3507997
--
on run {input, parameters}
set theDate to date (item 1 of input)
set theYear to item 2 of input
set theTitle to item 3 of input
set body to ""
repeat with cur from 4 to count input
@mootoh
mootoh / latest_dayone_entry.rb
Created August 29, 2012 07:32
prescript to Automator that extracts the latest Day One journal entry.
#
# See also: https://gist.github.com/3508021
#
require 'rubygems'
require 'sqlite3'
DAYONE_JOURNAL_PATH = "~/Library/Containers/com.dayoneapp.dayone/Data/Library/Application\ Support/Journal.sqlite"
db = SQLite3::Database.new(DAYONE_JOURNAL_PATH)
row = db.execute('select Z_PK, Z_ENT, Z_OPT, ZCREATIONYEAR, ZISENTRYDELETED,ZSTARRED,ZCREATIONDATE, ZMODIFIED,ZPHOTOMODIFIED,ZENTRYTEXT, ZUUID, ZLOCATION, ZWEATHER from ZJOURNALENTRY order by Z_PK DESC limit 1')[0]
@mootoh
mootoh / xml_encode.js
Last active January 13, 2020 14:26
XML escape function in Javascript.
// original:
// - http://stackoverflow.com/questions/7918868/how-to-escape-xml-entities-in-javascript
// - http://stackoverflow.com/questions/1091945/where-can-i-get-a-list-of-the-xml-document-escape-characters
// - http://www.w3.org/TR/xml/#syntax
if (!String.prototype.encodeXML) {
String.prototype.encodeXML = function () {
return this.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
@mootoh
mootoh / nvc.java
Created February 15, 2017 15:50
UINavigationController-like stacked fragment
package net.mootoh.tabexperiment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@mootoh
mootoh / docker-compose.yml
Created July 14, 2016 09:31
OS X Docker で Redmine を最速で起動する
redmine-mysql:
restart: always
image: sameersbn/mysql:latest
environment:
- DB_USER=redmine
- DB_PASS=password
- DB_NAME=redmine_production
volumes:
- /tmp/docker/redmine/mysql:/var/lib/mysql
@mootoh
mootoh / Zundoko.java
Created March 11, 2016 08:34
Zundoko.rxjava
// https://twitter.com/kumiromilk/status/707437861881180160
public class Zundoko {
private static final String TAG = "KIYOSHI";
private static final String ZUN = "ズン";
private static final String DOKO = "ドコ";
public static void zundoko() {
Observable o = Observable.create(new Observable.OnSubscribe<String>() {
Random rand = new Random();
@mootoh
mootoh / 0001-Shift-E-to-edit-in-Page.patch
Created March 15, 2016 22:25
crowi shortcut key to edit page
From cafa54547e4043b6bab3e9becba0fb1215cdd9db Mon Sep 17 00:00:00 2001
From: Motohiro Takayama <mootoh@gmail.com>
Date: Tue, 15 Mar 2016 15:24:11 -0700
Subject: [PATCH] Shift+E to edit in Page
---
lib/views/page.html | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/views/page.html b/lib/views/page.html