Skip to content

Instantly share code, notes, and snippets.

View kaelzhang's full-sized avatar
👻
♡╰̩̩̩̩̩̍̍●̩̩̩̩̩̩̩̻̍̍̍̍̍̍̍̊ᴗ̩̩̩̩̩̩̩̩̩̩̪̺̍̍̍̍̍̍̍̍̍̍̆̑●̩̩̩̩̩̩̩̻̍̍̍̍̍̍̍̊╯̩̩̩̩̩̍̍̍̍̍♡

Kael kaelzhang

👻
♡╰̩̩̩̩̩̍̍●̩̩̩̩̩̩̩̻̍̍̍̍̍̍̍̊ᴗ̩̩̩̩̩̩̩̩̩̩̪̺̍̍̍̍̍̍̍̍̍̍̆̑●̩̩̩̩̩̩̩̻̍̍̍̍̍̍̍̊╯̩̩̩̩̩̍̍̍̍̍♡
View GitHub Profile
@kaelzhang
kaelzhang / get_event_loop vs get_running_loop.py
Last active October 27, 2023 03:58
Show a demo the differences between Python `asyncio.get_event_loop()` and (vs) `asyncio.get_running_loop()`. And also explain the differences between `asyncio.run()` and `loop.run_until_complete()`
import asyncio
# Ref: https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop
# > If there is no current event loop set in the current OS thread,
# > the OS thread is main, and set_event_loop() has not yet been called,
# > asyncio will create a new event loop and set it as the current one
loop = asyncio.get_event_loop()
# So, loop2 is loop
loop2 = asyncio.get_event_loop()
fs.stat(path, function(err, stats) {
console.log(path);
console.log();
console.log(stats);
console.log();
if (stats.isFile()) {
console.log(' file');
}
if (stats.isDirectory()) {
@kaelzhang
kaelzhang / vscode-python.md
Last active November 24, 2020 12:54
vscode (pythonVSCode): how to fix the issue that unable to import 'somemodule'

There is a common problem we often encounter when using vscode.

[pylint] E0401:Unable to import 'tensorflow'
  • First make sure that both the python.pythonPath and python.linting.pylintPath are configured correctly in the WORKSPACE SETTINGS, especilly for the cases when you use anaconda or virtualenv
{
@kaelzhang
kaelzhang / gpg.sh
Last active September 5, 2018 03:25
How to config gpg for publishing artifacts to maven cental
gpg --full-gen-key
gpg -K
# /Users/kael/.gnupg/pubring.kbx
# ------------------------------
# sec rsa2048 2018-09-04 [SC]
# XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# uid [ultimate] Kael Zhang <[email protected]>
# ssb rsa2048 2018-09-04 [E]
@kaelzhang
kaelzhang / # imagemagick - 2018-08-31_10-14-44.txt
Created August 31, 2018 02:25
imagemagick on macOS 10.13.6 - Homebrew build logs
Homebrew build logs for imagemagick on macOS 10.13.6
Build date: 2018-08-31 10:14:44
sudo chown -R `whoami` /usr/local
mkdir -p ~/installer
cd ~/installer
curl -O https://nginx.org/download/nginx-1.12.0.tar.gz
tar xJf nginx-1.12.0.tar.gz ./nginx-1.12.0
curl -O https://github.com/openresty/headers-more-nginx-module/archive/v0.32.tar.gz
tar xJf v0.32.tar.gz ./headers-more-nginx-module-0.32
# install [gpg](https://www.gnupg.org/download/)
chown -R `whoami` /usr/local
brew install gpg
# http://central.sonatype.org/pages/working-with-pgp-signatures.html
# http://developer.51cto.com/art/201405/440958.htm
@kaelzhang
kaelzhang / cors-nginx.conf
Last active July 6, 2017 06:32 — forked from alexjs/cors-nginx.conf
Slightly tighter CORS config for nginx
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
wget -O node-v5.3.0-linux-x64.tar.gz https://nodejs.org/dist/v5.3.0/node-v5.3.0-linux-x64.tar.gz --no-check-certificate
@kaelzhang
kaelzhang / disable-spotlight.sh
Last active December 22, 2015 07:35
Disable spotlight for Mac OS X
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist