Skip to content

Instantly share code, notes, and snippets.

View taipingeric's full-sized avatar

Chih-Yang Li taipingeric

View GitHub Profile
@taipingeric
taipingeric / matplotlib plot pixel value in grid view.py
Created June 17, 2023 08:56
plot image pixel grid with color heatmap
import matplotlib.pyplot as plt
import cv2
import numpy as np
img = cv2.imread('monna.jpg')[100:700, 350:800, ::-1]
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
img = cv2.resize(img, (12, 16))
plt.imshow(img, cmap='gray')
import seaborn as sns
struct SameHash: Hashable {
var hashValue: Int {
return 1
}
let value: Int
}
func ==(lhs: SameHash, rhs: SameHash) -> Bool {
return lhs.value == rhs.value
}
class A {
let a: String
}
class A {
let a: String
}
@taipingeric
taipingeric / slack_bot.py
Created June 20, 2016 08:18 — forked from julianeon/slack_bot.py
Slack bot example, adapted from my working version.
import time, json, yaml, re, os, myfunc
from slackclient import SlackClient
with open('slack.yaml', 'r') as f:
doc = yaml.load(f)
user_id=doc["user_id"]
user_name=doc["user_name"]
user_address=doc["user_address"]
print user_id
@taipingeric
taipingeric / SwitchSecureTextEntry.swift
Created May 16, 2016 03:48
Switch SecureTextEntry
extension UITextField {
func switchSecureTextEntry(isSecure: Bool? = nil, normalFont: UIFont? = nil, secureFont: UIFont? = nil) {
let defaultFont = UIFont.systemFontOfSize(14)
self.secureTextEntry = isSecure ?? !self.secureTextEntry
self.font = nil
if secureTextEntry {
self.font = secureFont ?? defaultFont
@taipingeric
taipingeric / secureEntry.swift
Last active May 16, 2016 02:39
switch textfield secureEntry
@IBOutlet weak var passwordTextField: UITextField!
@IBAction func switchSecureEntry(sender: UIButton) {
passwordTextField.secureTextEntry = !passwordTextField.secureTextEntry
}