Skip to content

Instantly share code, notes, and snippets.

View fengjing's full-sized avatar

Feng Jing fengjing

  • China WuXi
View GitHub Profile
@fengjing
fengjing / seed_everything.py
Created December 3, 2024 09:22
seed everything
import random
import torch
import os
import numpy as np
def seed_everything(seed=42):
os.environ["PYTHONHASHSEED"] = str(seed)
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
@fengjing
fengjing / Web server.S
Created August 22, 2024 14:45 — forked from Elijah-Bodden/Web server.S
Web POST/GET http server written in intel x86 asm (pwn.college webserver course final solution)
.intel_syntax noprefix
.globl _start
.section .text
_start:
# Open socket
mov rdi, 2
mov rsi, 1
mov rdx, 0
@fengjing
fengjing / get_guid.py
Created August 2, 2024 07:56 — forked from wonderbeyond/get_guid.py
Get a secret random string in python(Refer to django.utils.crypto.get_random_string)
import os
import binascii
import uuid
from xid import Xid
def get_guid(style='uuid'):
"""Get a globally unique string for identify things"""
if style == 'uuid':
return uuid.uuid4().hex
@fengjing
fengjing / get_guid.py
Created August 2, 2024 07:56 — forked from wonderbeyond/get_guid.py
Get a secret random string in python(Refer to django.utils.crypto.get_random_string)
import os
import binascii
import uuid
from xid import Xid
def get_guid(style='uuid'):
"""Get a globally unique string for identify things"""
if style == 'uuid':
return uuid.uuid4().hex
@fengjing
fengjing / nginx_rotatelogs.bash
Created June 7, 2024 08:16 — forked from holysugar/nginx_rotatelogs.bash
nginx log rotation script
#!/bin/bash
LOGDIR=/usr/local/nginx/logs
PID=/usr/local/nginx/logs/nginx.pid
NOW=$(date +%Y%m%d-%H%M%S)
cd ${LOGDIR}
for i in *.log; do
mv ${i} ${i}.tmp.${NOW}
CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING
FOR hword, hword_part, word WITH unaccent, french_stem;
CREATE TEXT SEARCH CONFIGURATION en ( COPY = english );
ALTER TEXT SEARCH CONFIGURATION en ALTER MAPPING
FOR hword, hword_part, word WITH unaccent, english_stem;
CREATE TEXT SEARCH CONFIGURATION de ( COPY = german );
ALTER TEXT SEARCH CONFIGURATION de ALTER MAPPING
@fengjing
fengjing / m3u8-to-mp4.md
Created March 24, 2024 09:24 — forked from tzmartin/m3u8-to-mp4.md
m3u8 stream to mp4 using ffmpeg

1. Copy m3u8 link

Alt text

2. Run command

echo "Enter m3u8 link:";read link;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4
@fengjing
fengjing / 01.bash_shortcuts_v2.md
Created February 7, 2024 07:45 — forked from tuxfight3r/01.bash_shortcuts_v2.md
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@fengjing
fengjing / web-servers.md
Created October 13, 2023 09:05 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@fengjing
fengjing / trc20.py
Created October 12, 2023 13:30 — forked from andelf/trc20.py
Get TRC20 balance and Transfer TRC20 tokens
import requests
import base58
import base64
from pprint import pprint
ADDRESS = "T....your address"
PRIV_KEY = 'hex private key'
CONTRACT = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" # USDT