This file contains hidden or 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 tensorflow as tf | |
import tensorflow.keras as keras | |
import numpy as np | |
model = keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])]) | |
model.compile(optimizer='sgd', loss='mean_squared_error') | |
xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=float) | |
ys = np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype=float) |
This file contains hidden or 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 base64 | |
import ecdsa | |
def generate_vapid_keypair(): | |
""" | |
Generate a new set of encoded key-pair for VAPID | |
""" | |
pk = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p) | |
vk = pk.get_verifying_key() |
This file contains hidden or 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
# Fish shell | |
# REUSE ENVIRONMENT VARIABLES FROM ~/.bash_profile | |
bash -c '. ~/.bash_profile; env' | while read e | |
set var (echo $e | sed -E "s/([a-zA-Z0-9_]+)=(.*)\$/\1/") | |
set value (echo $e | sed -E "s/([a-zA-Z0-9_]+)=(.*)\$/\2/") | |
# remove surrounding quotes if existing | |
set value (echo $value | sed -E "s/^\"(.*)\"\$/\1/") |
This file contains hidden or 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 bash | |
# hangj.cnblogs.com | |
# https://www.cnblogs.com/hangj/p/16921863.html | |
s3_key="Q3AM3UQ867SPQQA43P2F" | |
s3_secret="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG" | |
session_token="Security-Token" | |
bucket="bucket-log" |
This file contains hidden or 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
Readme: In the following pseudo code, [] indicates a subroutine. | |
Sometimes I choose to write the subroutine inline under the [] in order to maintain context. | |
One important fact about the way rollbacks are handled here is that we are storing state for every frame. | |
In any real implementation you only need to store one game state at a time. Storing a game | |
state for every frame allows us to only rollback to the first frame where the predicted inputs don't match the true ones. | |
==Constants== | |
MAX_ROLLBACK_FRAMES := Any Positive Integer # Specifies the maximum number of frames that can be resimulated | |
FRAME_ADVANTAGE_LIMIT := Any Positive Integer # Specifies the number of frames the local client can progress ahead of the remote client before time synchronizing. |
This file contains hidden or 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 bash | |
# change the working directory to where this file is located | |
full_file_path=`realpath $0` | |
absolute_dir=`dirname $full_file_path` | |
cd $absolute_dir | |
# crate new user if not exists | |
username="bot" | |
userpassword="password123456" |
This file contains hidden or 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
local function run(src, level) | |
local level = level or 1 | |
level = level + 3 | |
assert(level >= 3) | |
local function get(t, k) | |
-- print('get:', k) | |
-- print('bt:', debug.traceback()) | |
local level = level + 1 |
This file contains hidden or 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 | |
# -*- coding: utf-8 -*- | |
# pip3 install pycaw -i https://pypi.douban.com/simple | |
# https://docs.microsoft.com/en-us/windows/win32/api/endpointvolume/nf-endpointvolume-iaudioendpointvolume-getvolumerange | |
from ctypes import cast, POINTER | |
from comtypes import CLSCTX_ALL | |
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume |
This file contains hidden or 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 bash | |
# https://www.cnblogs.com/hangj/p/11838259.html | |
IP=localhost | |
FILE=proxy.pac | |
# 找到一个可用的 port | |
SOCKSPORT=`python -c 'import socket; s=socket.socket(); s.bind(("localhost", 0)); print(s.getsockname()[1]); s.close()'` | |
HTTPPORT=`python -c 'import socket; s=socket.socket(); s.bind(("localhost", 0)); print(s.getsockname()[1]); s.close()'` |
This file contains hidden or 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
(function() { | |
// https://github.com/exif-js/exif-js | |
var debug = false; | |
var root = this; | |
var self = window || this; | |
var Blob = Blob || function () {} | |
var DOMParser = DOMParser || function () {} | |
var EXIF = function(obj) { |
NewerOlder