Skip to content

Instantly share code, notes, and snippets.

View axiaoxin's full-sized avatar
🌙
不忙着圆缺 春天不走远

axiaoxin axiaoxin

🌙
不忙着圆缺 春天不走远
View GitHub Profile
@axiaoxin
axiaoxin / svgcheckbx_cleaned.js
Created July 22, 2022 02:21 — forked from GianlucaGuarini/svgcheckbx_cleaned.js
Cleaned version of the svgcheckbx.js file used in this demo http://tympanus.net/Development/AnimatedCheckboxes/
;(function(document, window, undefined) {
// wrap always your modules to avoid the namespace pollution
// use always the strict statement
'use strict';
// you do not need to wrap all your code in an if statement...
if (!document.createElement('svg').getAttributeNS) return;
// shortcut to select any DOM element
var $ = document.querySelectorAll.bind(document),
// create an array with all the inputs to uste
// BTW I am sure that this solution is neither correct but it comes from the original code logic
@axiaoxin
axiaoxin / Upgrade vim
Created July 23, 2020 08:02 — forked from yevrah/Upgrade vim
Update to Vim8 on Centos 7
################################################################################
# Method 1: Install using rpm packages (credit to DarkMukke)
#
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm
rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7
# WARNING: removing vim-minimal uninstalls `sudo` if you skip the second step
# make sure to at least run `yum install sudo`
yum -y remove vim-minimal vim-common vim-enhanced
@axiaoxin
axiaoxin / celery_tasks_error_handling.py
Created January 30, 2018 08:41 — forked from darklow/celery_tasks_error_handling.py
Celery tasks error handling example
from celery import Task
from celery.task import task
from my_app.models import FailedTask
from django.db import models
@task(base=LogErrorsTask)
def some task():
return result
class LogErrorsTask(Task):
@axiaoxin
axiaoxin / daemon.md
Created November 7, 2017 09:26 — forked from andreif/daemon.md
A simple unix/linux daemon in Python

A simple unix/linux daemon in Python

Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

Access: http://web.archive.org/web/20131025230048/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

by Sander Marechal

I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.

@axiaoxin
axiaoxin / daemon.py
Created November 7, 2017 09:23 — forked from marazmiki/daemon.py
Python daemon example
#!/usr/bin/env python
# coding: utf-8
import argparse
import os
import sys
import time
import atexit
import logging
import signal
@axiaoxin
axiaoxin / tree.md
Created May 16, 2017 06:42 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

#! /usr/bin/env python3
'''pyCookieCheat.py
2015022 Now its own GitHub repo, and in PyPi.
- For most recent version: https://github.com/n8henrie/pycookiecheat
- This gist unlikely to be maintained further for that reason.
20150221 v2.0.1: Now should find cookies for base domain and all subs.
20140518 v2.0: Now works with Chrome's new encrypted cookies.
See relevant post at http://n8h.me/HufI1w
@axiaoxin
axiaoxin / nginx.conf
Created November 22, 2016 03:16 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@axiaoxin
axiaoxin / 0. description.md
Created May 17, 2016 08:17 — forked from Integralist/0. description.md
Clojure deftype, defrecord, defprotocol
  • defprotocol: defines an interface
  • deftype: create a bare-bones object which implements a protocol
  • defrecord: creates an immutable persistent map which implements a protocol

Typically you'll use defrecord (or even a basic map);
unless you need some specific Java inter-op,
where by you'll want to use deftype instead.

Note: defprotocol allows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,

@axiaoxin
axiaoxin / enc_dec_test.py
Created March 31, 2016 10:22 — forked from justinfx/enc_dec_test.py
Speed test of common serializers on python 2.7.2 (pickle, cPickle, ujson, cjson, simplejson, json, yajl, msgpack)
"""
Dependencies:
pip install tabulate simplejson python-cjson ujson yajl msgpack-python
"""
from timeit import timeit
from tabulate import tabulate