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
@mitsuse
mitsuse / a.py
Created March 10, 2021 07:46
Argument 1 to "f" has incompatible type "object"; expected "Type[Any]"
from typing import List
from typing import Tuple
from typing import Type
def f(x: Type) -> None:
...
# error: Argument 1 to "f" has incompatible type "object"; expected "Type[Any]"
@mitsuse
mitsuse / pixafish.py
Last active February 21, 2021 09:52
Collect image URLs from Pixabay, Unsplash and Pexels.
from __future__ import annotations
from typing import Any
from typing import Dict
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import IO
from typing_extensions import Literal
from typing_extensions import Protocol
@mitsuse
mitsuse / final.py
Created August 24, 2020 03:11
`typing_extensions.Final` cannot be used for dataclasses.
from __future__ import annotations
from typing_extensions import Final
from dataclasses import dataclass
@dataclass
class A:
x: Final[int] = 100
@mitsuse
mitsuse / private_init.py
Last active September 8, 2018 08:31
A workaround for private __init__ by using name mangling.
#!/usr/bin/env python3
from __future__ import annotations
class Foo:
class __Internal:
pass
def __init__(self, _: Type[__Internal]) -> None:
pass
#!/usr/bin/env python3
from typing import NamedTuple
import typedjson
class NameJson(NamedTuple):
first: str
last: str
@mitsuse
mitsuse / Keyboard.swift
Created March 5, 2018 06:27
Reactive extension for events emitted from keyboard.
import UIKit
import RxSwift
import RxCocoa
public enum Keyboard: ReactiveCompatible {
public struct Update {
public let size: CGSize
public let duration: Double
}
@mitsuse
mitsuse / MakeTitleViewFirstResponderByTouchingTabTwice.swift
Created March 2, 2018 03:30
同じタブを二度タップして titleView を first responder にする
import UIKit
import RxCocoa
import RxSwift
final class TabBarController: UITabBarController {
private let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
@mitsuse
mitsuse / bitrise.yml
Created December 28, 2017 17:01
Automate linting and pushing a podspec on Bitrise.io.
format_version: 1.4.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
workflows:
deploy:
after_run:
- ensure_clean
- test
- lint_spec
- push_spec
build:
@mitsuse
mitsuse / birise_temp
Created December 25, 2017 07:39
Run `bitrise run` on the specific commit in a temporary directory.
#!/bin/bash
validate_variable() {
name=$1
value=${!name}
if [ -z "$value" ]; then
echo "error: \$${name} is required." >&2
exit 128
fi