Skip to content

Instantly share code, notes, and snippets.

@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
@c02y
c02y / audio.py
Last active November 25, 2019 14:09
Download RoundTable mp3 files from http://english.cri.cn/4926/more/11680/more11680.htm
# -*- coding: utf-8 -*-
import os
import scrapy
import urllib.request
class AudioSpider(scrapy.Spider):
name = 'audio'
allowed_domains = ['english.cri.cn']
start_urls = ['http://english.cri.cn/4926/more/11680/more11680.htm']
@c02y
c02y / init.el
Last active April 29, 2019 09:25
change the last line of C-w and C-x w to fix the problem when using for multiple blank lines(it will tab in only one blank line)
replace last line of C-w and C-x w to
(when (not (current-line-empty-p)) (indent-for-tab-command)))))
;; use different bullet for a sub-list
(setq org-list-demote-modify-bullet
'(("-" . "+") ("+" . "*") ("*" . "-") ("1." . "+") ("1)" . "+")
("a." . "-") ("a)" . "-") ("A." . "-") ("A)" . "-")))
;; Comment this line out, since it will cause the sub-list indentation problem,
@c02y
c02y / emm
Created April 29, 2019 03:06
fix the typo in emm -a
cmd="-e '(execute-kbd-macro (kbd \"C-c a a c\"))'"
@c02y
c02y / config.fish
Created April 29, 2019 03:00
one zips file to handle zip file
function zips -d 'zip to list(l)/extract(x)/create(c)'
set -l options 'l' 'L' 'c' 'x' 'X'
argparse -n zips $options -- $argv
or return
for a in $argv
if set -q _flag_l # list
unzip -l $a
else if set -q _flag_L # list Chinese characters
zips.py -l $a
@c02y
c02y / gif
Last active April 26, 2019 11:37
gif recorder and converter
#!/bin/bash
print_usage()
{
cat <<EOF
$(basename $0) -- gif recorder and converter
Usage: $(basename $0) [-h] [-r] [-w] [-c] [time] [file]
-h to print this usage
-r to record a region
@c02y
c02y / emm
Last active April 26, 2019 11:32
emm function for bash
#!/bin/bash
# 0. put this script into ~/.local/bin/
# 1. Create a emacsclient.desktop in ~/.local/share/applications/emacsclient.desktop
# 1.1 if you installed Emacs using pkg manager instead of anaconda3, omit this step
# 1.2 if you are using non-GUI or launcher is unnecessary, omit this step including the next
# 1.3 if you are using an OS without systemctl installed, omit this step including the next
#
# emacsclient.desktop:
#
@c02y
c02y / init.el
Last active April 26, 2019 10:16
org-agenda
(setq org-todo-keywords
;; !/@ meaning: https://orgmode.org/manual/Tracking-TODO-state-changes.html
'((sequence "TODO(t!)" "STARTED(s!)" "NEXT(n!)" "WAITING(w!)" "|" "DONE(d!)" "CANCELED(c@)")
;; multiple sets for one file
;; (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)""|" "FIXED(f)")
;; (sequence "|" "CANCELED(c)")
))
# put this before txt README
@c02y
c02y / .condarc
Last active April 26, 2019 03:07
~/.condarc
channels:
- https://mirrors.cloud.tencent.com/anaconda/cloud/conda-forge/
- https://mirrors.cloud.tencent.com/anaconda/cloud/menpo/
- https://mirrors.cloud.tencent.com/anaconda/cloud/pytorch/
- https://mirrors.cloud.tencent.com/anaconda/cloud/bioconda/
- https://mirrors.cloud.tencent.com/anaconda/pkgs/main/
- https://mirrors.cloud.tencent.com/anaconda/pkgs/free/
- ripl-org
- lebedov
- conda-forge