Skip to content

Instantly share code, notes, and snippets.

Guoxing Dong dalang

Block or report user

Report or block dalang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dalang / ko_math_whiz
Created May 30, 2018
If the big number 5555…5555 ( a total of 2000 digits)is divided by 84, what's the remainder?
View ko_math_whiz
int('5' * 2000) % 84
dalang / docker-compose.yml  
Created May 27, 2018
docker-compose for clair and clairctl
View docker-compose.yml  
version: '2.1'
container_name: clair_postgres
image: postgres:latest
restart: unless-stopped
dalang / 
Created May 25, 2018
find the n-th Monisen number. A number M is a Monisen number if M=2**P-1 and both M and P are prime numbers. For example, if P=5, M=2**P-1=31, 5 and 31 are both prime numbers, so 31 is a Monisen number.
import math
def is_monisen_number(value):
log2 = int(math.log2(value + 1))
return 2**log2 == value + 1 and log2 in PRIME_NUMBERS
dalang /
Created May 11, 2015
print yanghui triangle
def yanghui_triangle():
def safe_get_value(l, index):
length = len(l)
return 0<= index < length and l[index] or 0
tmp = [1]
while True:
yield tmp
length = len(tmp)
new = []
dalang /
Created Apr 21, 2015
decorator for retrying function in specific times
def retry(attempt, raise_on_fail=False):
def decorator(func):
def wrapper(*args, **kw):
att = 0
last_except = None
while att < attempt:
return func(*args, **kw)
except Exception as e:
att += 1
View double_super.rb
grandparent = self.class.superclass.superclass
meth = grandparent.instance_method(:the_method)
View vagrant-wrapper.rb
# Author:: BinaryBabel OSS (<>)
# Homepage::
# License:: MIT
# For bugs, docs, updates:
# Copyright 2013 sha1(OWNER) = df334a7237f10846a0ca302bd323e35ee1463931
dalang /
Last active Dec 22, 2015
oh-my-zsh razor plugin

#oh-my-zsh razor plugin Enable Razor from puppetlabs capability of command autocomplete

Ensure you have installed oh-my-zsh ###How to use this razor plugin:

  1. mkdir a new folder named razor in your oh-my-zsh plugin folder: ~/.oh-my-zsh/plugins/razor
  2. put this file in ~/.oh-my-zsh/plugins/razor
  3. config your ~/.zshrc to enable razor plugin: add razor in the bracket of the line starts with plugins=(
  4. Try type razor in terminal and test command autocomplete with tab
dalang / raw.rb
Created Jul 24, 2013
test dynamically add instance_variables or class_variables to class.
View raw.rb
class Mine
@xxx = 1
attr_accessor :some_var
def intialize
@some_var = true
class << self
def my_number num
dalang /
Created Jul 18, 2013
bash script to get data from csv file and run command with the parsed info
#== USAGE: [csvFilename] <SerialNumber>
#== Return:
#== 0 -- normal
#== 1 -- Args error
#== 2 -- imana configuration file is not exist
#== 3 -- The Server with given serialnumber is NOT in csv File
You can’t perform that action at this time.