Skip to content

Instantly share code, notes, and snippets.

View ycliuhw's full-sized avatar
🏠
Working from home

Kelvin ycliuhw

🏠
Working from home
  • Sydney
View GitHub Profile
#!/usr/bin/env python3
import sys
from random import randrange
from math import log, ceil, trunc
import copy
from multiprocessing import cpu_count, Process, SimpleQueue
def minCut(g):
'''Runs the random contraction algorithm and returns the min cut (# of
@ycliuhw
ycliuhw / gist:af3abe825495ea8aa6ea95bd43b2fea8
Created June 21, 2017 05:02 — forked from onlyyoujack/gist:c5796f3fa6591de52d0d
Jenkins REST API Automation via curl
#Get the current configuration and save it locally
curl -X GET http://user:password@hudson.server.org/job/myjobname/config.xml -o mylocalconfig.xml
#Update the configuration via posting a local configuration file
curl -X POST http://user:password@hudson.server.org/job/myjobname/config.xml --data-binary "@mymodifiedlocalconfig.xml"
#Creating a new job via posting a local configuration file
curl -X POST "http://user:password@hudson.server.org/createItem?name=newjobname" --data-binary "@newconfig.xml" -H "Content-Type: text/xml"
@ycliuhw
ycliuhw / caselessDictionary.py
Created July 5, 2016 01:29 — forked from bloomonkey/caselessDictionary.py
A Python dictionary sub-class that is case-insensitive when searching, but also preserves the keys as inserted.
class CaselessDictionary(dict):
"""A dictionary with case-insensitive keys.
A dictionary that is case-insensitive when searching, but also preserves
the keys as inserted.
"""
def __init__(self, initval={}):
if isinstance(initval, dict):
for key, value in initval.iteritems():