Skip to content

Instantly share code, notes, and snippets.

View naufalafif's full-sized avatar
👍

Naufal Afif naufalafif

👍
View GitHub Profile
@h1code2
h1code2 / main.py
Last active March 11, 2024 08:14
fastapi操作异步redis模块aioredis #fastapi #aioredis
import aioredis
from fastapi import FastAPI
from api.views import router as api_router
from ws.views import router as wss_router
from config import redis_config
async def redis_pool(db: int = 0):
"""
@dmmeteo
dmmeteo / 1.srp.py
Last active June 7, 2024 14:11
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):
@CarlosDomingues
CarlosDomingues / python-poetry-cheatsheet.md
Last active July 5, 2024 02:45
Python Poetry Cheatsheet

Create a new project

poetry new <project-name>

Add a new lib

poetry add <library>

Remove a lib

@miguelmota
miguelmota / notes.txt
Last active April 14, 2024 08:26
runc vs gvisor (runsc) vs rkt vs KataContainers vs NablaContainers
knowledge dump on container runtimes
KataContainers
- image coupled with kernel
- light vm layer
- can run in nested virturalization environments if hardware supports and you can enable it in bios (ex. only bare metal EC2 instances, limits many cloud providers)
- slower startup time
- OCI compliant
- previously known as ClearContainers by Intel
@heroheman
heroheman / ranger-cheatsheet.md
Last active July 2, 2024 16:15
Ranger Cheatsheet

Ranger Cheatsheet

General

Shortcut Description
ranger Start Ranger
Q Quit Ranger
R Reload current directory
? Ranger Manpages / Shortcuts
@alces
alces / ansible_local_playbooks.md
Last active July 6, 2024 09:49
How to run an Ansible playbook locally
  • using Ansible command line:
ansible-playbook --connection=local 127.0.0.1 playbook.yml
  • using inventory:
127.0.0.1 ansible_connection=local
@messa
messa / asyncio_ssl_example.py
Created June 26, 2015 12:43
Python asyncio + SSL TCP client/server example
#!/usr/bin/env python3
import asyncio
import multiprocessing
import os
import ssl
from time import sleep
port = 9000
@yamionp
yamionp / locustfile.py
Last active March 21, 2024 22:56
Websocket Locust Sample. locustfile and Echo/Chat Server
# -*- coding:utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
import json
import uuid
import time
import gevent
@adnan-i
adnan-i / mongoose-aggregate-by-month-year.js
Last active October 22, 2020 15:30
Mongoose aggregation for grouping users by month/year subscribed
User.aggregate([
{
/* Filter out users who have not yet subscribed */
$match: {
/* "joined" is an ISODate field */
'subscription.joined': {$ne: null}
}
},
{
/* group by year and month of the subscription event */
@wsargent
wsargent / deploy.sh
Created April 11, 2014 23:52 — forked from gre/deploy.sh
#!/bin/bash
REMOTE=play@SERVER_IP
REMOTE_APP=/home/play/PROJECT_NAME/
sbt stage || exit 1;
ssh $REMOTE "cd $REMOTE_APP; ./stop.sh";
rsync -va target/ $REMOTE:$REMOTE_APP/target
ssh $REMOTE "cd $REMOTE_APP; ./start.sh";