-
코랩에서 Indent 칸 2칸 -> 4칸으로 수정하기
-
출처: StackOverflow
-
Tools 도구 > Preferences 설정 > 편집기 Editor > 들여쓰기 너비(공백 개수) Indentation width in spaces
-
-
구글 코랩 런타임 연결 끊김 방지
-
코랩은 일정시간 동안 아무 interaction이 없으면 강제적으로 session timeout을 걸어버림. 이를 방지하기 위해 브라우저 자체에 코드를 실행시켜서 일정 시간마다 특정 버튼을 누르는 등의 interaction을 주어야 주어진 12시간(pro 24시간)의 session 시간을 모두 활용할 수 있음.
-
코드 출처: 테디노트
function ClickConnect(){ console.log("9분!"); document.querySelector("colab-toolbar-button").click() } setInterval(ClickConnect, 9 * 60 * 1000) // ms 단위
-
이 코드를 실행 시키면 빈 셀들이 엄청 많이 생성 되는데 shift+클릭으로 선택 후 지워주는 수 밖에 없다...
-
-
Open in Colab 버튼
-
코드 출처: 구글 코랩 공식 가이드
-
ⓐ GitHub
[](https://colab.research.google.com/github/{repo_owner}/{repo_name}/blob/master/{path_to_notebook/notebook_name}.ipynb)
-
ⓑ Gist
[](https://colab.research.google.com/gist/{gist_owner}/{gist_id})
-
-
코랩에서 구글 드라이브에 있는 파일 다운받기
-
코드 출처: (기억 안남...)
!gdown --id {shared_google_file_id}
-
-
코랩에서 깃 전체 다운받기
-
코드 출처: (기억 안남...)
!git clone https://github.com/{repo_owner}/{repo_name}.git
-
-
Matplotlib에서 나눔폰트 설정
-
코드 출처: (기억 안남...)
import os if not os.path.exists("/usr/share/fonts/truetype/nanum/NanumSquareR.ttf"): from warnings import warn warn("나눔글꼴 미설치. 설치 진행.") print() !apt-get install fonts-nanum print() print("설치 완료. 세션 재시작.") from time import sleep sleep(1) os.kill(os.getpid(), 9) else: print("나눔글꼴 설치 완료")
import matplotlib.font_manager as fm fm._rebuild() import matplotlib.pyplot as plt plt.rcParams["font.family"] = "NanumSquare" plt.rcParams['axes.unicode_minus'] = False
-
-
Colab에서 TensorBoard 실행
-
코드 출처: 테디노트
# 텐서보드 extension 로드를 위한 magic command %load_ext tensorboard
# 텐서보드를 로드 %tensorboard --logdir {log_dir}
-
-
Colab에서 private repo를 clone하기
-
코드 출처: Arun Prasad's Blog
# 1. Create a new key pair. Keep it simple: default directory, no passphrase. ssh-keygen -t ed25519# 2. Set the public key as the deploy key on your private repo. cp /root/.ssh/id_ed25519.pub /content/ # 해당 파일을 다운로드 후, repo 설정(Settings) > Security > Deploy keys 로 이동. 복사 붙여넣기.
# 3. Dump the private key into a string that you save in your Colab. # ※ 안전하지 않은 방법이지만, 어차피 노트북 내용을 볼 수 있다는 것은 repo 내용도 볼 수 있다는 소리다. cp /root/.ssh/id_ed25519 /content/ # 해당 파일을 다운로드 후, 아래 `GITHUB_PRIVATE_KEY`에 붙여넣기.
# 4. Add some logic to write your private key string to ~/.ssh/id_ed25519. GITHUB_PRIVATE_KEY = """——-BEIN OPENSSH PRIVATE KEY——- my super cool key ——-END OPENSSH PRIVATE KEY——- """ # Create the directory if it doesn't exist. !mkdir -p /root/.ssh # Write the key with open("/root/.ssh/id_ed25519", 'w') as f: f.write(GITHUB_PRIVATE_KEY) # Add github.com to our known hosts !ssh-keyscan -t ed25519 github.com >> ~/.ssh/known_hosts # Restrict the key permissions, or else SSH will complain. !chmod go-rwx /root/.ssh/id_ed25519 # Note the `git@github.com` syntax, which will fetch over SSH instead of HTTP. !git clone git@github.com:shhommychonx/my_repository.git
-
-
ipsum lorem
Last active
July 23, 2023 15:45
-
-
Save shhommychon/051d923fdbd617714ffc464a9f676f8f to your computer and use it in GitHub Desktop.
내가 안까먹을라고 적어놓는 코랩 사용 팁들
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment