Skip to content

Instantly share code, notes, and snippets.

View wdpm's full-sized avatar
🎯

wdpm wdpm

🎯
View GitHub Profile
@anand2312
anand2312 / pymongo-to-motor.md
Last active April 11, 2025 18:01
pymongo vs Motor

pymongo vs Motor

Motor is an async Python driver for MongoDB.

When should I use Motor?

You should use Motor when you're trying to interact with a MongoDB database in an asynchronous context. When you're making something that needs to be asynchronous (like a web server, or most commonly from what I've seen here, Discord bots), you also want all the database calls to be done asynchronously. But pymongo is synchronous, i.e it is blocking, and will block the execution of your asynchronous program for the time that it is talking to the database.

Okay, How do I switch now?!

Thankfully for us, switching from pymongo to Motor isn't too hard, and won't need you to change much code. This process can be roughly summarized as:

Step 1: Install Motor, and import it

Installing can be done with pip - pip install motor

@QidiLiu
QidiLiu / ffmpeg_cheat_sheet.md
Created December 8, 2020 19:11
FFmpeg 指令集
@BarclayII
BarclayII / rbtree.py
Last active September 30, 2022 06:20
RBTree
class Node(object):
def __init__(self, key, red):
self.key = key
self.left = self.right = self.parent = None
self.red = red
@property
def grandparent(self):
if self.parent is None:
@zlovatt
zlovatt / CEP Debugging in vscode.md
Last active February 23, 2023 07:54
CEP Debugging in vscode

Setup

  • in .vscode folder in your project root, create a file launch.json
{
  "version": "0.1.0",
  "configurations": [
    {
      "name": "[Your Tool] Debugger",
 "type": "chrome",
@geminiwen
geminiwen / Main.java
Last active September 30, 2022 06:21
RBTree
package com.gemini.demo;
public class Main {
public static void main(String[] args) {
// write your code here
TreeNode root = new TreeNode();
root.setColor(TreeNode.COLOR_BLACK);
root.setData(50);
@Bleyddyn
Bleyddyn / github_stars.py
Last active August 14, 2023 10:56
Prototype of a simple way of keeping notes for starred Github repos
""" Prototype of a simple way of keeping notes for starred Github repos.
"""
import requests
import json
import argparse
import os
import time
from collections import defaultdict
def fetchJson( user ):
@whizkydee
whizkydee / ffmpeg.md
Created July 17, 2018 12:17 — forked from protrolium/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@cheerfulstoic
cheerfulstoic / Repository Maintenance Levels.md
Last active February 4, 2026 20:57
Repository Maintenance Levels

After reading Why I'm Frequently Absent from Open Source by James Long and listening the corresponding The Changelog episode, I dwelt on the idea and believe that open source maintainers...

  • ... should never be ashamed if they don't have time for a project.
  • ... should be honest with themselves and open with their users so that everybody can be on the same page
  • ... are people and they have at one time or another responsibilities or hardships that they need to attend to which reasonably take them away from a project
  • ... may also reasonbly decide that they don't like the direction of a project or that they would like to explore other things and may leave a project permanently.

Along this line of thinking I've created a set of descriptions for different levels at which a project might be maintained. A maintainer can use these to announce to their users the current ability that they have to dedicate to a pr

@AndorChen
AndorChen / fonts.md
Last active July 5, 2025 00:48
电子书制作

O'REILLY系列图书排版要求:

字体(均为汉仪字体)和字号(均为苹果字号)

  • 正文:书宋+times英文复合字体 (字号:9.5号)

  • 章节:中圆+helvetica英文复合字体 (字号:19号)

  • 章节标题:大黑+helvetica英文复合字体(字号:30号,字体宽度缩为80%)

@alirezas
alirezas / fade.js
Created February 13, 2017 10:54
fadeIn & fadeOut in vanilla js
function fadeOut(el){
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();