- 新しくノートPCを購入したので、デスクトップPC内のデータをOSごと移行したい。(ノートPCとデスクトップPCが逆の立場でもOK)
- 二つのPCには異なるOSが入っているとする。(例えばノートPCにはWindows、デスクトップPCにはUbuntuがインストールされている。ここではこれを前提とする)
- また、ノートPC内のWindowsのライセンスがもったいないので、デスクトップPCにWindowsを移行する。
- (動機は上記だが、要は二つのOSを入れ替える作業)
- (同じOSであれば、バックアップとその復元という形でスムーズにデータを移行するためのソフトが大抵ある)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator as op | |
from itertools import chain | |
def car(l): | |
l = iter(l) | |
try: | |
return next(l) | |
except StopIteration: | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import operator as op | |
from itertools import chain | |
def car(l): | |
l = iter(l) | |
try: | |
return next(l) | |
except StopIteration: | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
class ApiLimit: | |
def __init__(self, request_limit, time_limit_second): | |
self.api_count = 0 | |
self.request_limit = request_limit | |
self.time_limit_second = time_limit_second | |
self.start = None | |
def __call__(self, func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyautogui as auto | |
import time | |
import random | |
def hold(key: str, duration: float, natural: bool=True, sd: float=0.05): | |
duration += random.gauss(0, sd) if natural else 0 | |
t = time.time() | |
while time.time() - t < duration: | |
auto.keyDown(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
class Cond: | |
def __init__(self): | |
self.conditions = [] | |
def add(self, predicate, func): | |
self.conditions.append((predicate, func)) | |
def call(self, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Val = | |
| Int of int | |
| Bool of bool | |
type Ope = Add | Mul | Lt | |
type Ast = | |
| Val of Val | |
| Form of Ope * Ast * Ast | |
let exec ope v1 v2 = | |
match ope, v1, v2 with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Val { | |
case int(Int) | |
case bool(Bool) | |
case symbol(String) | |
} | |
enum Ope { | |
case add | |
case mul | |
case lt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Potato { | |
func hash() -> Int | |
} | |
extension Potato where Self: Hashable { | |
func hash() -> Int { | |
return self.hashValue | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; input | |
(define (my-read) | |
(let ([a (read)]) | |
(if (symbol? a) | |
(symbol->string a) | |
a))) | |
(define (my-read-line) | |
(let ([line (read-line)]) | |
(if (string=? "" line) | |
(my-read-line) |
NewerOlder