Skip to content

Instantly share code, notes, and snippets.

View skiptomyliu's full-sized avatar
🫐

Dean Liu skiptomyliu

🫐
View GitHub Profile
@skiptomyliu
skiptomyliu / build.sh
Created February 25, 2017 04:48
codesign script
# Name of your app.
APP="mosaicshapes"
# The path of your app to sign.
APP_PATH="/Users/dean/Desktop/m/mosaicshapes.app"
# The path to the location you want to put the signed package.
RESULT_PATH="/Users/dean/Desktop/$APP.pkg"
# The name of certificates you requested.
APP_KEY="3rd Party Mac Developer Application: [Redacted]"
INSTALLER_KEY="3rd Party Mac Developer Installer: [Redacted]"
#APP_KEY=”Developer ID Application: [redacted]”
@skiptomyliu
skiptomyliu / slope.py
Last active March 9, 2017 03:34
1st degree polynomial
def get_slope(img_seg):
x,y = np.where(img_seg==True)
slope,_ = np.polyfit(x,y,1)
return -1*slope
def average_color(image):
w,h = image.size
x0,y0 = (0,0)
x1,y1 = (w,h)
r,g,b = 0,0,0
area = w*h
for x in range(x0, x1):
for y in range(y0, y1):
DEG30 = 30/360.
def adjacent_colors((r, g, b), d=DEG30): # Assumption: r, g, b in [0, 255]
r, g, b = map(lambda x: x/255., [r, g, b]) # Convert to [0, 1]
h, l, s = colorsys.rgb_to_hls(r, g, b) # RGB -> HLS
h = [(h+d) % 1 for d in (-d, d)] # Rotation by d
adjacent = [map(lambda x: int(round(x*255)), colorsys.hls_to_rgb(hi, l, s))
for hi in h] # H'LS -> new RGB
adjacent[0] = tuple(adjacent[0])
def luminance(r,g,b):
return math.sqrt(0.299 * math.pow(r,2) + 0.587 * math.pow(g,2) + 0.114 * math.pow(b,2))
def tint_to_lum(color, lum):
r,g,b = color
nR,nG,nB = r,g,b
while True:
tint_factor = .005
nR = nR + (255 - nR) * tint_factor
@skiptomyliu
skiptomyliu / LDAP JXplorer trust self signed certificate
Last active October 13, 2017 17:14 — forked from laszlomiklosik/LDAP JXplorer trust self signed certificate
LDAP JXplorer trust self signed certificate workaround
2 easy steps:
1) echo -n | openssl s_client -connect AD_SERVER:AD_SERVER_PORT | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ldapserver.pem
2) keytool -import -trustcacerts -file ldapserver.pem -alias ALIAS_GOES_HERE -keystore /Users/.../Apps/jxplorer-3.3.1-osx/jxplorer-3.3.1.app/Contents/Resources/security/cacerts
OR
Via JXPlorer UI, go to menu Security -> Trusted Servers and CAs. Import the new ldapserver.pem file. Default password "changeit"
@skiptomyliu
skiptomyliu / service.yaml
Last active July 4, 2018 14:20
kube tutorial ingress
apiVersion: v1
kind: Service
metadata:
name: webserver
namespace: webserver
spec:
ports:
- port: 80
targetPort: 3000
protocol: TCP
apiVersion: certmanager.k8s.io/v1alpha1
kind: Certificate
metadata:
name: webserver-tls-prod
spec:
secretName: webserver-tls-prod
dnsNames:
- mosaic.skiptomyliu.com
acme:
config:
apiVersion: certmanager.k8s.io/v1alpha1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
# The ACME server URL
server: https://acme-v02.api.letsencrypt.org/directory
# Email address used for ACME registration
email: [your_email address]
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: echoserver
namespace: echoserver
spec:
replicas: 1
template:
metadata:
labels: