Skip to content

Instantly share code, notes, and snippets.

@ydf
ydf / Dockerfile
Last active November 1, 2022 05:01
django development env, use docker container with ssh
FROM python:3.11-slim as base
FROM base as builder
COPY requirements.txt .
RUN apt-get update && apt-get install -y --no-install-recommends default-libmysqlclient-dev gcc && apt-get clean --yes && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN mkdir /install && pip install --no-cache-dir --prefix=/install -r requirements.txt && rm -rf /tmp/* /var/tmp/*
FROM base
COPY --from=builder /install /usr/local
COPY --from=builder /usr/lib/x86_64-linux-gnu/libmariadb.s* /usr/lib/x86_64-linux-gnu/
RUN apt-get update && apt-get install -y openssh-server
@ydf
ydf / nginx_config.conf
Last active February 26, 2023 11:54
nginx block country ip
# wget https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-Country.mmdb
# http conf
geoip2 /etc/nginx/GeoLite2-Country.mmdb {
auto_reload 30m;
$geoip2_metadata_country_build metadata build_epoch;
$geoip2_data_country_code default=US country iso_code;
}
geoip2_proxy 1.1.1.0/24; # cdn ip
@ydf
ydf / xtrabackup_full_increment_restore.sh
Last active February 6, 2022 05:52 — forked from SQLadmin/xtrabackup_full_increment_restore.sh
Automate xtrabackup for FULL/Incremental and restore
#!/bin/bash
# This is my production backup script.
# https://sqlgossip.com
set -e
set -u
usage() {
echo "usage: $(basename $0) [option]"
echo "option=full: Perform Full Backup"
@ydf
ydf / Jetbrains-IDE-Evaluator.md
Last active August 28, 2024 05:34
Jetbrains-IDE-Evaluator.md

how to evaluate JetBrains IDE ? for Mac OS X

# step 1 remove eval key
rm -rf ~/Library/Application\ Support/JetBrains/*/eval/*.key

# Step 2 Remove all `evl*` properties
rm  -rf ~/Library/Application\ Support/JetBrains/*/options/other.xml

# step 3
# wget https://gist.github.com/ydf/8c5a7f80ee84dd24c5c676f84929b1f8/raw/dda2ab31a16fc5ab436666d2162bd2db85350632/deploy_unattended-upgrades.sh -O /tmp/a && sh /tmp/a
apt-get -y install unattended-upgrades && \
cat > /etc/apt/apt.conf.d/10periodic <<EOF
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "3";
APT::Periodic::Unattended-Upgrade "1";
EOF
sed -i 's#//\t"${distro_id}:${distro_codename}-updates"#\t"${distro_id}:${distro_codename}-updates"#' /etc/apt/apt.conf.d/50unattended-upgrades && \
@ydf
ydf / file_comm.py
Last active September 22, 2023 11:04
tcp over file python
# from https://labs.f-secure.com/tools/tcp-over-file-tunnel/
import sys
import socket
import threading
import base64
import time
import binascii
import mutex
import signal
pass { from: 0.0.0.0/0 to: 109.239.140.0/24 }
pass { from: 0.0.0.0/0 to: 149.154.164.0/23 }
pass { from: 0.0.0.0/0 to: 149.154.164.0/22 }
pass { from: 0.0.0.0/0 to: 149.154.166.0/23 }
pass { from: 0.0.0.0/0 to: 149.154.168.0/22 }
pass { from: 0.0.0.0/0 to: 149.154.172.0/22 }
pass { from: 0.0.0.0/0 to: 149.154.172.0/23 }
pass { from: 0.0.0.0/0 to: 205.172.60.0/22 }
pass { from: 0.0.0.0/0 to: 67.198.55.0/24 }
pass { from: 0.0.0.0/0 to: 91.108.12.0/22 }
@ydf
ydf / adblock rule
Created January 12, 2018 07:10
adblock rule
@@||twimg.com$script,domain=twitter.com
@@||gtimg.com$script,domain=qq.com
$xmlhttprequest,third-party
$script,third-party
$subdocument,other
@ydf
ydf / iptables-rule
Last active January 11, 2018 10:32
iptables.rule
# Generated by iptables-save v1.4.21 on Thu Jan 11 10:10:03 2018
*filter
:INPUT DROP [8:834]
:FORWARD ACCEPT [0:0]
:OUTPUT DROP [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT
-A INPUT -m conntrack --ctstate INVALID -j DROP
-A INPUT -p tcp -m multiport --dports 80,443,22 -j ACCEPT
-A INPUT -p udp -m udp --sport 67:68 --dport 67:68 -j ACCEPT
@ydf
ydf / init.sh
Last active December 1, 2022 09:11
ubuntu server init
#!/bin/bash
cat >> /etc/security/limits.conf <<EOF
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535
EOF