Skip to content

Instantly share code, notes, and snippets.

@dreamerlzl
dreamerlzl / gdrive.py
Last active December 22, 2024 09:22
Access Google API with Python SDK and refresh token
# make sure your app is in published but not testing mode on Google Cloud Console
# refresh token will expire in 6 months then; see https://developers.google.com/identity/protocols/oauth2
# you can get a refresh token following this answer generated by Phind.com: https://www.phind.com/search?cache=esclzqazl0knyo8xouu0mf8c&source=sidebar
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import Resource, build
from google.auth.transport.requests import Request
class GoogleDriveAgent:
def __init__(
@dreamerlzl
dreamerlzl / rust-analyzer
Created February 24, 2023 02:21
Automatically switch rust-analyzer channel during rustup default
# assumption: you use `rustup component add rust-analyzer` to manage RA
# you could check that by seeing whether is a rust-analyzer under `~/.rustup/toolchains/${your_toolchain}/bin`
# place this exectuable under dir like ~/.cargo/bin
#!/usr/bin/fish
eval (rustup which --toolchain (string split - (rustup default) | head -n 1) rust-analyzer) $argv