Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / swap.sh
Created June 7, 2020 13:43
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 / 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
@kevenli
kevenli / HeadlessMain.java
Created December 4, 2017 08:23 — forked from mojavelinux/HeadlessMain.java
A main class wrapper for deck2pdf that runs the application headless using Monocle from jfxtras.org
package me.champeau.deck2pdf;
import java.lang.reflect.Field;
import java.util.Objects;
import javafx.application.Application;
/**
* Adapted from https://gist.github.com/hastebrot/cbca1128dd791966e3a6
*/
public class HeadlessMain {
@kevenli
kevenli / 1) Install
Created April 11, 2017 06:23 — forked from nghuuphuoc/1) Install
Install Redis on Centos 6
// --- Compiling ---
$ wget http://download.redis.io/releases/redis-2.8.3.tar.gz
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
@kevenli
kevenli / gist:29bae54dbe9e41312918785d82224f56
Last active February 25, 2017 09:20 — forked from crazycode/gist:53bd7a5b8ea8bad7ec56
ORACLE 11G R2静默安装配置 - UTF-8