Skip to content

Instantly share code, notes, and snippets.

View mitsuse's full-sized avatar
💭
🐈🐈

mitsuse mitsuse

💭
🐈🐈
View GitHub Profile
#!/bin/bash
cd /sys/kernel/config/usb_gadget/
mkdir -p procon
cd procon
echo 0x057e > idVendor
echo 0x2009 > idProduct
echo 0x0200 > bcdDevice
echo 0x0200 > bcdUSB
echo 0x00 > bDeviceClass
// Authoer: The SwiftUI Lab
// Full article: https://swiftui-lab.com/scrollview-pull-to-refresh/
import SwiftUI
struct RefreshableScrollView<Content: View>: View {
@State private var previousScrollOffset: CGFloat = 0
@State private var scrollOffset: CGFloat = 0
@State private var frozen: Bool = false
@State private var rotation: Angle = .degrees(0)
@tbutts
tbutts / tmux-migrate-options.py
Last active February 29, 2024 08:11
For tmux configs: Merge deprecated/removed -fg, -bg, and -attr options into the -style option
#!/usr/bin/env python
# vim: set fileencoding=utf-8
#
# USAGE:
# Back up your tmux old config, run the script and redirect stdout to your conf
# file. Example:
#
# $ cp ~/.tmux.conf ~/.tmux.conf.orig
# $ python ./tmux-migrate-options.py ~/.tmux.conf.orig > ~/.tmux.conf
#
@dgrtwo
dgrtwo / mnist_pairs.R
Created May 31, 2017 18:56
Comparing pairs of MNIST digits based on one pixel
library(tidyverse)
# Data is downloaded from here:
# https://www.kaggle.com/c/digit-recognizer
kaggle_data <- read_csv("~/Downloads/train.csv")
pixels_gathered <- kaggle_data %>%
mutate(instance = row_number()) %>%
gather(pixel, value, -label, -instance) %>%
extract(pixel, "pixel", "(\\d+)", convert = TRUE)

Reactの難しさを分解しよう を読んで。

n番煎じの話題。今更な話題、それはわかってる。自分の周りの環境が変わったので、書き下すことで、再度整理したい。

抽象

サーバーが生成するHTMLが一つの粘土の像だとしたら、jQueryがナイフで、Reactは設計図を持った3Dプリンタ。

鼻が大きすぎるから削るとか、ちょっとしたことをやるのが jQuery の主な用途。しかしあるいは、職人的に、大きな塑像から、一つの像を切り出すこともできる。

@tarunon
tarunon / Undefined.swift
Created March 24, 2017 05:27
lazy var fatalError is a solution that instead of ImplicitlyUnwrappedOptional
func undefined<T>(_ funcName: String=#function) -> T {
fatalError("\(funcName) is undefined.")
}
class A {
lazy var parameter: Int = undefined()
}
let a = A()
a.parameter = 100
@voluntas
voluntas / webrtc.rst
Last active May 21, 2024 05:35
WebRTC コトハジメ
@voluntas
voluntas / webrtc.rst
Last active May 21, 2024 13:55
WebRTC の未来
@kei-sato
kei-sato / usdex
Last active August 29, 2015 14:24
Exchange usd to any currency, or any currency to usd
#!/usr/bin/env python
#coding:utf-8
# Exchange usd to any currency, or any currency to usd
# help: python convert_usd.py -h
import os.path
from datetime import date, datetime
import argparse
import urllib
@azu
azu / Incremental DOM.md
Last active July 13, 2022 16:07
Incremental DOM ざっと見たやつ。追記: 初期バージョンのコードなので最新では異なる場合があります。

Incremental DOM

Introducing Incremental DOM — Google Developers — Medium

Reactやvirtual-dom、Glimmer(Ember)などVirtual DOMの実装は色々あるが、これらのVirtual DOM実装には2つの問題がある

  • 既存のテンプレート言語を利用していない(しにくい)
  • モバイルでのパフォーマンス、特にメモリに関しては大きすぎる

これらを解決するためにIncremental DOMと言うものを作っている(WIP)