Skip to content

Instantly share code, notes, and snippets.

@c02y
c02y / Arch-Linux-Installation-Guide.md
Last active January 9, 2021 18:53
Arch Linux Installation Guide

Sources:

  1. Burn the ISO into USB drive if installing it into drive directly
  • dd if=archlinux.iso of=/dev/sda bs=4M status=progress && sync
  1. Install libvirt ovmf packages and reboot if installing it into KVM NOTE: ovmf package and reboot step ensure that boot from UEFI instead of BIOS, otherwise, it would fail during the process when you try to grub-install (install bootloader)
  • choose Fireware of "UEFI x86_84: ... OVMF_CODE.fd" from Overview in VM details of KVM
@c02y
c02y / tig-appimage-guide
Created August 1, 2020 08:24
tig appimage guide
* Create tig appimage
** get tig src file zip or using git into ~/public/tig
** compile
- make
- fix the dependencies
** generate the appimage file
- download linuxdeploy appimage and make it executable
- write the right tig.desktop and log tig.png, the logo can be empty tig.svg file
- ./linuxdeploy.appimage -e ./src/tig -i ./tig.png -d ./tig.desktop --appdir AppDir --output appimage
+ NOTE: in docker, you may unable to run appimage directly
@c02y
c02y / docker-guide.md
Last active May 4, 2021 15:39
Docker guide
  • Docker ** Prepare docker *** install docker package *** start and enable service
    • sudo systemctl start docker.service
    • sudo systemctl enable docker.service ** add permission and group
    • sudo usermod -aG docker $USER ** reboot your computer ** check if docker works
@c02y
c02y / LinkedListCycle.py
Created May 16, 2020 01:43
LinkedListCycle.py
# 141. Linked List Cycle (Easy)
# https://leetcode-cn.com/problems/linked-list-cycle/description/
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
@c02y
c02y / MergeSortedArray.py
Created May 14, 2020 22:26
MergeSortedArray.py
# 88. Merge Sorted Array (Easy)
# https://leetcode-cn.com/problems/merge-sorted-array/description/
from typing import List
class Solution:
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
"""
Do not return anything, modify nums1 in-place instead.
"""
@c02y
c02y / ValidPalindromeII.py
Created May 14, 2020 19:59
ValidPalindromeII.py
# 680. Valid Palindrome II (Easy)
# https://leetcode-cn.com/problems/valid-palindrome-ii/description/
class Solution:
def validPalindrome(self, s):
if s == s[::-1]:
return True
l, r = 0, len(s) - 1
while l < r:
if s[l] == s[r]:
l, r = l + 1, r - 1
@c02y
c02y / TopDownPrintBinaryTree.py
Created May 13, 2020 19:47
TopDownPrintBinaryTree.py
# https://cyc2018.github.io/CS-Notes/#/notes/32.1%20%E4%BB%8E%E4%B8%8A%E5%BE%80%E4%B8%8B%E6%89%93%E5%8D%B0%E4%BA%8C%E5%8F%89%E6%A0%91
class Node:
def __init__(self, val=0):
self.val = val
self.left = None
self.right = None
class TreeNodes:
def __init__(self):
@c02y
c02y / printMatrixCycle.py
Created January 15, 2020 08:38
29. 顺时针打印矩阵
#!/usr/bin/env python3
# https://cyc2018.github.io/CS-Notes/#/notes/29.%20%E9%A1%BA%E6%97%B6%E9%92%88%E6%89%93%E5%8D%B0%E7%9F%A9%E9%98%B5
class Solution:
def printMatrix(self, matrix):
res = []
while matrix:
res += matrix.pop(0)
if matrix and matrix[0]:
for row in matrix:
@c02y
c02y / backtrac.py
Created January 14, 2020 06:57
12. 矩阵中的路径 回溯法(backtracking)
#!/usr/bin/env python3
# https://cyc2018.github.io/CS-Notes/#/notes/12.%20%E7%9F%A9%E9%98%B5%E4%B8%AD%E7%9A%84%E8%B7%AF%E5%BE%84
# https://www.nowcoder.com/questionTerminal/c61c6999eecb4b8f88a98f66b273a3cc?f=discussion
class Solution:
def hasPath(self, matrix, rows, cols, path):
# write code here
if not matrix:
return False
if not path:
@c02y
c02y / reConstructBinaryTree.py
Created January 10, 2020 02:32
reConstructBinaryTree
# https://cyc2018.github.io/CS-Notes/#/notes/7.%20%E9%87%8D%E5%BB%BA%E4%BA%8C%E5%8F%89%E6%A0%91
# https://www.nowcoder.com/practice/8a19cbe657394eeaac2f6ea9b0f6fcf6?tpId=13&tqId=11157&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None