Skip to content

Instantly share code, notes, and snippets.

View jimmy947788's full-sized avatar
🙄
faping

吉掰米 jimmy947788 jimmy947788

🙄
faping
View GitHub Profile
@jimmy947788
jimmy947788 / nas.daedalus.cc.conf
Created April 18, 2022 14:26
Nginx 架設 Open Media Vault 使用的設定檔( 包和Certbot 憑證參數)
# This file is auto-generated by openmediavault (https://www.openmediavault.org)
# WARNING: Do not edit this file, your changes will get lost.
server {
server_name nas.daedalus.cc; # managed by Certbot
root /var/www/openmediavault; #綁對應路徑
index index.html;
autoindex off;
server_tokens off;
sendfile on;
large_client_header_buffers 4 32k;
@jimmy947788
jimmy947788 / dock.daedalus.cc.conf
Created April 18, 2022 14:30
用Nginx綁定domain 指向 container對應的 port
server {
server_name dock.daedalus.cc;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
listen 443 ssl; # managed by Certbot
@jimmy947788
jimmy947788 / usb_key_press.ino
Created May 19, 2022 07:36
this is arduino micro press button and exeute command
#include <Keyboard.h>
const int BTN2_PIN = 2; // input pin for pushbutto
const int BTN3_PIN = 3; // input pin for pushbutton
int btn2_prevState; //紀錄按紐2上次一次狀態
int btn3_prevState; //紀錄按紐3上次一次狀態
@jimmy947788
jimmy947788 / spdlog_snippets.c
Created August 16, 2022 15:40
方便使用 spdlog 設定
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE //一定要在 spdlog.h 之前定義
#include <spdlog/spdlog.h>
#include <spdlog/async.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/daily_file_sink.h>
int main(){
// 清掉已註冊logger
spdlog::drop_all();

Redis 支援JSON

預先準備

  1. 安裝redis

    sudo apt update -y
    sudo apt-get install libclang-dev -y
    # reload daemon first
    sudo systemctl daemon-reload
@jimmy947788
jimmy947788 / gist:11b23d863100ac600f0d9d0b1d1f0b8a
Last active October 2, 2022 09:36
python version change by update-alternatives
We couldn’t find that file to show.
@jimmy947788
jimmy947788 / sockets.h
Created November 26, 2022 08:17 — forked from willeccles/sockets.h
Cross-platform socket header for both POSIX sockets and Winsock
/*
* File: sockets.h
* Author: Will Eccles
* Date: 2020-03-12
*
* 1. Description
*
* This header attempts to make it easy to use sockets across platforms,
* for both Windows and POSIX systems. While Winsock is often somewhat
* compatible with Berkeley sockets, it is not strictly compatible,
@jimmy947788
jimmy947788 / LoggerConfig.py
Last active January 4, 2023 05:28
python 常用程式碼
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import logging
import logging.config
import os
import config
LOGGING_CONFIG = {
"version": 1,
@jimmy947788
jimmy947788 / .env
Last active December 2, 2022 18:39
docker-comose template
COMPOSE_PROJECT_NAME=myproject
# Redis
REDIS_HOSTNAME=redisdb.local
REDIS_PORT=6379
REDIS_PASSWORD=
# Rabbitmq
RABBITMQ_HOSTNAME=rabbitmq.local
RABBITMQ_USERNAME=root
@jimmy947788
jimmy947788 / client.py
Created December 3, 2022 14:52 — forked from dbehnke/client.py
Python AsyncIO Client and Server Example using StreamReader and StreamWriter
"""
client.py - AsyncIO Server using StreamReader and StreamWriter
This will create 200 client connections to a server running server.py
It will handshake and run similar to this:
Server: HELLO
Client: WORLD