This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import objc | |
import AppKit | |
import sys | |
NSUserNotification = objc.lookUpClass('NSUserNotification') | |
NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter') | |
def notify(title, subtitle, info_text, delay=0, sound=False, userInfo={}): | |
notification = NSUserNotification.alloc().init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# wordcount | |
import string | |
from functools import reduce | |
str = """\ | |
How much ground would a groundhog hog, \ | |
if a groundhog could hog ground? \ | |
A gfoundhog would hog all the ground he could hog, \ | |
if a groundhog could hog ground. \ | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// general editor settings | |
"terminal.external.osxExec": "iTerm.app", | |
"workbench.colorTheme": "Material Theme", | |
"workbench.iconTheme": "material-theme-icons", | |
"vsicons.projectDetection.autoReload": true, | |
"editor.lineNumbers": "on", | |
"editor.fontSize": 12, | |
"editor.rulers": [90, 120], | |
"editor.minimap.enabled": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 使用 numpy 手动实现实现 | |
import numpy as np | |
# 生成随机数据集 | |
X = 2 * np.random.rand(100, 1) | |
y = 4 + 3 * X + np.random.randn(100, 1) | |
# 函数说明: | |
# 1. np.c_[np.array([1,2,3]), np.array([4,5,6])] --> array([[1, 4],[2, 5],[3, 6]]) | |
# 2. np.ones((2, 1)) --> array([[ 1.], [ 1.]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- coding: utf-8 -- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# 生成随机数据集 | |
np.random.seed(42) | |
X = 2 * np.random.rand(100, 1) | |
y = 4 + 3 * X + np.random.randn(100, 1) | |
X_b = np.c_[np.ones((100, 1)), X] | |
X_new = np.array([[0], [2]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import numpy as np | |
from numpy import linalg as LA | |
import matplotlib.pyplot as plt | |
# 1. calculate mu | |
# X = np.array([ | |
# [-1, 1], | |
# [ 0, 0], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.layers.core import Layer | |
from keras import initializers, regularizers, constraints | |
from keras import backend as K | |
class Attention(Layer): | |
def __init__(self, | |
kernel_regularizer=None, bias_regularizer=None, | |
kernel_constraint=None, bias_constraint=None, | |
use_bias=True, **kwargs): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.datasets import mnist | |
from keras.utils import to_categorical | |
from keras.layers import Input, Conv2D, MaxPooling2D, Flatten, Dense, Activation, BatchNormalization | |
from keras.models import Model | |
from keras import backend as K | |
# 1. load data | |
def load_data(): | |
(x_train, y_train), (x_test, y_test) = mnist.load_data() | |
x_train = x_train.reshape(x_train.shape[0], 28, 28, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while true; do curl -o /dev/null -sw "%{http_code}\n" https://labex.io; sleep .5; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"runtime" | |
"time" | |
) | |
type Monitor struct { |
OlderNewer