Skip to content

Instantly share code, notes, and snippets.

View jeffrey4l's full-sized avatar
🎯
Focusing

Jeffrey Zhang jeffrey4l

🎯
Focusing
View GitHub Profile
#!/bin/bash
TEMP=`cat /sys/class/thermal/thermal_zone0/temp`
TEMP="${TEMP:0:2}.${TEMP:2}"
UPLOAD1=`awk '{print $1}' /proc/loadavg`
UPLOAD5=`awk '{print $2}' /proc/loadavg`
UPLOAD15=`awk '{print $3}' /proc/loadavg`
UPTIME=`awk '{print $1/3600}' /proc/uptime | awk -F "." '{print $1"."substr($2,1,2)}'`
TMP_FILE="/tmp/cosm.json"
#!/usr/bin/env python
#-*- coding:utf-8 -*-
#Author: Lei Zhang <zhang.lei.fly@gmail.com>
import sys
import os
import signal
import argparse
from math import floor
from shutil import copyfile, rmtree
// ==UserScript==
// @name Yooli Enhance
// @namespace http://xcodest.me/
// @version 0.2
// @description Yooli Enhance
// @match http://www.yooli.com/*
// @match https://www.yooli.com/*
// @require http://www.yooli.com/v2/local/js/common/jquery-1.8.3.min.js
// @updateURL https://gist.github.com/jeffrey4l/6162185/raw/de803a96bca9988cb10e2e9bef3b395c5cf55bdb/Yooli_Enhance.js
// @copyright 2012+, You
@jeffrey4l
jeffrey4l / local_settings.py
Last active August 29, 2015 14:05
nova flavor init
# Add following line to the local_settings.py file to order the flavor
def flavor_sort_key(flavor):
order_prefix = {
'micro': '1',
'standard': '2',
'compute': '3',
'memory': '4',
}
name = flavor.name
@jeffrey4l
jeffrey4l / nova-flavor-init.sh
Last active August 29, 2015 14:06
nova flavor init
#!/bin/bash
#
# This configuration is copy from ustack.com
DEFAULT_ROOT_GB=40
nova-manage flavor create --name micro-1 --cpu 1 --memory 512 --root_gb $DEFAULT_ROOT_GB --is_public True
nova-manage flavor create --name micro-2 --cpu 1 --memory 1024 --root_gb $DEFAULT_ROOT_GB --is_public True
nova-manage flavor create --name standard-1 --cpu 1 --memory 2048 --root_gb $DEFAULT_ROOT_GB --is_public True
@jeffrey4l
jeffrey4l / bdfilm.js
Created October 20, 2014 13:25
Better BDFilm
// ==UserScript==
// @name BD File Remover
// @namespace http://your.homepage/
// @version 0.1
// @description enter something useful
// @author You
// @match http://bdfilm.lofter.com/
// @grant none
// ==/UserScript==
@jeffrey4l
jeffrey4l / python_in_perf.py
Created December 25, 2014 02:49
python_in_perf.py
import random
import timeit
S1 = set(range(100))
S2 = range(100)
S3 = tuple(range(100))
print type(S1), type(S2), type(S3)
def test1():
diff --git a/horizon/tables/base.py b/horizon/tables/base.py
index adc284c..1337989 100644
--- a/horizon/tables/base.py
+++ b/horizon/tables/base.py
@@ -1031,6 +1031,16 @@ class DataTable(object):
"""
return self.request.get_full_path().partition('?')[0]
+ def get_full_url(self):
+ """Returns the full URL path for this table.
@jeffrey4l
jeffrey4l / version_method.py
Last active August 29, 2015 14:21
Python Magic MetaClass
VERION_METHODS='version_methods'
class VersionMethod(object):
def __init__(self, version, func):
self.version = version
self.func = func
class MetaClass(type):
def __new__(cls, name, bases, cls_dict):
@jeffrey4l
jeffrey4l / interrupt_pool.py
Created November 17, 2015 07:11
Interrupt the Python multiprocessing.Pool in graceful way
import multiprocessing
from multiprocessing import Pool
import time
import signal
def worker():
while True:
print time.time()
time.sleep(.5)