Skip to content

Instantly share code, notes, and snippets.

View hehesky's full-sized avatar

Kaihua Zhou hehesky

  • IBM
  • Toronto
View GitHub Profile
@hehesky
hehesky / copy.go
Created January 29, 2020 16:54 — forked from r0l1/copy.go
Copy a directory tree (preserving permissions) in Go.
/* MIT License
*
* Copyright (c) 2017 Roland Singer [roland.singer@desertbit.com]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
@hehesky
hehesky / vercomp.sh
Created November 13, 2018 14:41
Bash: Compare 2 dot separated version code
#!/bin/bash
#compare 2 dot separated version codes. Return 0 if both identical. Return 1 if first is newer. Return 2 if second is newer
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
@hehesky
hehesky / sigmat.py
Created February 14, 2018 01:10 — forked from cfelton/sigmat.py
Signal Matrix implemented in myhdl
from myhdl import *
class SignalMatrix(object):
def __init__(self, size=(4,4,), stype=intbv(0)[9:]):
# the size of the matrix
self.size = size
nrows, ncols = size
import bottle
from beaker.middleware import SessionMiddleware
session_opts = {
'session.type': 'memory',
'session.cookie_expires': 300,
'session.auto': True
}
app = SessionMiddleware(bottle.app(), session_opts)