Skip to content

Instantly share code, notes, and snippets.

@kevenli
kevenli / install_docker.sh
Last active March 29, 2022 07:27
install docker on centos7
sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io -y
sudo systemctl enable --now docker
@kevenli
kevenli / encoding.py
Created June 17, 2021 07:50 — forked from alexpizarroj/encoding.py
Standalone port of Django's `force_text` (1.11.x)
import datetime
from decimal import Decimal
import six
try:
from django.utils.encoding import DjangoUnicodeDecodeError
except ImportError:
class DjangoUnicodeDecodeError(UnicodeDecodeError):
@kevenli
kevenli / python3.sh
Last active January 26, 2021 02:39
add python3 execuable path
# /etc/profile.d/python3.sh
PATH=$PATH:/usr/local/bin
@kevenli
kevenli / log.py
Last active September 27, 2022 16:17 — forked from kingspp/logging.py
Python Comprehensive Logging using YAML Configuration
import os
import yaml
import logging.config
import logging
import coloredlogs
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""
| **@author:** Prathyush SP
| Logging Setup
@kevenli
kevenli / zip.bat
Created August 18, 2020 07:00
Archieve Folder with 7z
7z a -tzip ..\app.zip . -xr!log
@kevenli
kevenli / swap.sh
Created June 7, 2020 13:43 — forked from Repox/swap.sh
Shell script for adding swap to Linux
#!/bin/sh
# size of swapfile in megabytes
swapsize=1024
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
@kevenli
kevenli / extract_headers.md
Last active September 23, 2019 05:44
extract HEADERS and COOKIES from curl bash cmd (copied from chrome developer tools)

in notepad++

Headers

-H '([a-z\-]*): ([^']*)' 
->
'\1' : '\2', \r\n

Cookies

@kevenli
kevenli / add_user.sh
Last active January 22, 2020 01:30
Docker pruge
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
@kevenli
kevenli / import.py
Created July 8, 2019 11:38
scrapy project import
import os
from scrapyd.eggstorage import FilesystemEggStorage
from scrapyd.config import Config
import urllib2
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
register_openers()
source_dir = '/kf/scrapyd'
@kevenli
kevenli / index.php
Created March 5, 2019 08:42 — forked from vinzenz/index.php
Extremely Simple Sample TODO List App in PHP
<!--
Copyright 2017 Vinzenz Feenstra, Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software