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
print(’\033[31m\u2764‘ × 29) |
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
find . -name '*.crx' | sed "s;\(\.\/.*\)\.crx$;mv \1.crx \1.zip;" | bash | |
# A simpler solution | |
find . -type f | xargs -I{} sh -c "mv {} {}.zip" |
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
alias ga="git status -s | grep '^ M' | awk '{print \$2}' | xargs git add" # dont add the new files |
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
sum(x for x in list(map(lambda n: 2**n * 2**n, range(13)))) |
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
#!/usr/bin/env python | |
import argparse | |
class LargeFileSplitter: | |
def __init__(self, file, n): | |
self.file = file | |
self.num = n | |
if file.endswith('.txt'): | |
file = file[:-4] |
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
#!/usr/bin/env bash | |
PREFERRED_FONT="AR PL KaitiM GB" | |
CJK_MAIN_FONT= | |
zh_fonts_file=$(mktemp -t fonts.XXX) | |
# save fonts family into a temp file to avoid the trouble with spaces among font family string | |
fc-list :lang=zh --format "%{family[0]}\n" > $zh_fonts_file | |
if [[ ! -s $zh_fonts_file ]]; then |
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
find -name 'ARB-*.md' -printf '%P\n' | awk '{orig=$0; gsub(/-/, "_"); print "mv", orig, $0}' | bash | |
# notes | |
# | |
# -printf '%P\n' to strip preceding './' from find's output | |
# orig=$0 to save original file name | |
# gsub(/-/, "_") to subsititue '-' in the original file name to '_' in the target file name, it happens to '$0' in place | |
# print "mv", orig, $0 to generate shell command |
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
echo "#include <stdio.h>\nint main() { int a = sizeof(struct {}); printf(\"a = %d\\\n\", a); }" | gcc -x c - | |
# a = 0 | |
echo "#include <stdio.h>\nint main() { int a = sizeof(struct {}); printf(\"a = %d\\\n\", a); }" | gcc -x c++ - | |
# <stdin>:2:36: error: types may not be defined in ‘sizeof’ expressions |
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
git log -L"/^VERSION = /,/^NAME = /:Makefile" --pretty="%h" --no-patch | | |
while read revision; do git show "$revision":Makefile | | |
sed -n -e '/^VERSION = [0-9]/ { N; N; N; N; s/\n/ /g; p }' | | |
sed -e 's/VERSION = //' -e 's/ PATCHLEVEL = /./' -e 's/ SUBLEVEL = /./' -e 's/ EXTRAVERSION = *//' -e 's/NAME/ NAME/'; done |
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
set from="[email protected]" | |
set realname="Luc Ma" | |
# ==================== IMAP ============================= | |
set imap_user = "[email protected]" | |
# git-send-email | |
# set imap_pass = "xxxx xxxx xxxx xxxx" |
OlderNewer