Skip to content

Instantly share code, notes, and snippets.

View derekjhyang's full-sized avatar

Derek Yang derekjhyang

View GitHub Profile
/* [Usage Example]
// Prepare your Redis environment
Map<String,Object> configMap = new HashMap<>();
configMap.put("redisIp", "http://10.0.192.103");
configMap.put("redisPort", "6379");
configMap.put("semaphoreExpiredMilliSecTime",120000L);
configMap.put("waitPermitMillisecTime",10L);
configMap.put("permitExpiredMillisecTime",10000L);
@derekjhyang
derekjhyang / py_multi_inheritance_mso
Created May 13, 2018 07:27
測試py的多重繼承下MSO的順序
#!/usr/bin/env python3
#
# 作者:Coldwings
# 链接:https://www.zhihu.com/question/54855335/answer/141414989
# 来源:知乎
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
#
#
class A:
def __new__(cls, *argv, **kwargs):
@derekjhyang
derekjhyang / safety_cleanup_boot_partition.sh
Last active March 20, 2018 05:52
此腳本可以快速修復/boot空間滿的狀況 (適用於Debian系列Linux)
#!/bin/bash
#
# How to run:
# 1. chmod +x safety_cleanup_boot_partition.sh
# 2. sudo ./satefy_cleanup_boot_partition.sh
#
#
# Find older kenerl images and purge them
dpkg --list 'linux-image*' | awk '{ if ($1=="ii") print $2}' | grep -v `uname -r` | xargs sudo apt-get purge -y
#!/usr/bin/env python2.7
import paramiko
import os
class MySFTPClient(paramiko.SFTPClient):
def exists(self, path):
"""os.path.exists for paramiko's SCP object
"""
try:
self.stat(path)
for i in $(sudo dpkg --get-selections | awk '/nova-/{print $1}'); do sudo service $i restart; done
@derekjhyang
derekjhyang / keystonev2-endpoints-create.sh
Last active August 29, 2015 14:22
for Keystone V2 endpoint creation
#!/bin/bash
ENDPOINT=http://localhost # URL end without slash
REGION=regionOne
# keystone
echo "=== Install keystone endpoint ==="
keystone endpoint-create \
--service-id $(keystone service-list | awk '{for(i=1;i<=NF;i++){if($i=="identity"){print $2}}}') \
--publicurl ${ENDPOINT}:5000/v2.0 \
heat_template_version: 2014-10-16
description: A docker load-balancer server
parameters:
image:
type: string
description: Image used for servers
default: tomcat
flavor:
type: string
description: flavor used by the servers
@derekjhyang
derekjhyang / dhcp_server_troubleshooting.sh
Created January 7, 2015 08:02
dhcp_server_troubleshooting.sh
#!/usr/bin/bash env
tcpdump -i eth0 -v port bootps
@derekjhyang
derekjhyang / arping_test.sh
Created December 2, 2014 08:25
execute the command `arping` with the given ip ranges.
#!/bin/bash
#ip_start=$(echo ${1} | sed 's/^.*\(.\{3\}\)$/\1/')
#ip_end=$(echo ${2} | sed 's/^.*\(.\{3\}\)$/\1/')
#set -x #debug mode
log_file=~/arping.log
function usage() {
del /S "C:\Program Files\Apache Software Foundation\Tomcat 6.0\logs\*"
del /S "C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\*"