Skip to content

Instantly share code, notes, and snippets.

View JokerQyou's full-sized avatar

Joker_ JokerQyou

View GitHub Profile
JokerQyou / cloud-init-docker.yaml&env=plain&abbr=cloud-init
Last active April 22, 2020 02:10
Cloud-init user data to install some fundamental components
- curl -fsSL | sh
- curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- ln -s /usr/local/bin/docker-compose /usr/local/bin/dc
- apt-get install -y zsh git
JokerQyou /
Last active April 19, 2018 02:18 — forked from vaab/
Fixing python 2.7 windows unicode issue with ``subprocess.Popen``.
# coding: utf-8
# This patched `Popen` class
# adds support for Unicode commandline on Windows platform.
# issue:
import os
import ctypes
import subprocess
import _subprocess
from ctypes import (
JokerQyou /
Last active September 29, 2017 07:28
Wtf is with these docker registry clients, I just want to delete an image.


python --delete-layers
JokerQyou /
Created June 14, 2017 09:49 — forked from serge-kilimoff/
Persistent watchdog observer. When watchdog re-start, check if new/modify/delete/etc.. files or directories since the last launch, and send events for suscribers handlers.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
Subclassing Observer for saving states of folders, and load this states at the next observation.
TODO : mapping events and handlers dispatching, for a shorter code.
from __future__ import unicode_literals, print_function, division
import cPickle as pickle
import os
JokerQyou /
Created May 23, 2016 07:26
Regular expression to split by punctuation
# coding: utf-8
from __future__ import print_function
import re
pattern = u''.join([
u'\u0020-\u002f', # < General Latin characters, exclude @, letters and numbers
JokerQyou /
Created May 11, 2016 02:54 — forked from schlamar/
mplog: Python advanced multiprocessing logging.
import logging
import multiprocessing
import time
import mplog
FORMAT = '%(asctime)s - %(processName)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
existing_logger = logging.getLogger('x')
JokerQyou / agtrunc
Last active April 19, 2016 06:03 — forked from tweekmonster/agtrunc
A script to truncate the_silver_searcher's output in Vim
#!/usr/bin/env python
'''Truncates matches from ag
Place this script somewhere in your $PATH, like ~/bin and pipe ag into it.
Vim could be setup like this:
if executable('ag')
set grepprg=ag\ --vimgrep\ -w\ $*
if executable('agtrunc')
JokerQyou /
Last active January 2, 2018 12:30 — forked from instagrim-dev/
A python lib for sending notification on OS X
# coding: utf-8
from Foundation import NSUserNotification
from Foundation import NSUserNotificationCenter
from Foundation import NSUserNotificationDefaultSoundName
def notify(message, title='Notification', sound=False):
notification = NSUserNotification.alloc().init()
if sound:
JokerQyou /
Last active August 29, 2015 14:12
Type check
import functools, inspect
def _strict_type(type_map):
Check func parameter type
:param f: func
:param type_map: mapping of parameter types
def _wrapped(f):
// --- Compiling ---
$ wget
$ tar xzvf redis-2.8.3.tar.gz
$ cd redis-2.8.3
$ make
$ make install
// --- or using yum ---
$ rpm -Uvh
$ rpm -Uvh