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
# Load balancer configuration | |
upstream exampleApp { | |
# Directs to the process with least number of connections. | |
least_conn; | |
# One failed response will take a server out of circulation for 20 seconds. | |
server 127.0.0.1:10080 fail_timeout=20s; | |
#server 127.0.0.1:10081 fail_timeout=20s; | |
#server 127.0.0.1:10082 fail_timeout=20s; | |
#server 127.0.0.1:10083 fail_timeout=20s; |
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
/** | |
* Simple linear regression | |
* | |
* @param {Array.<number>} data | |
* @return {Function} | |
*/ | |
function regression(data) { | |
var sum_x = 0, sum_y = 0 | |
, sum_xy = 0, sum_xx = 0 | |
, count = 0 |
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
// array of values | |
var values = [10,8,12,10,11,9,10,12,8,50,10,12,8]; | |
// smoothing whole array | |
function lpf(values, smoothing){ | |
var value = values[0]; | |
for (var i = 1; i < values.length; i++){ | |
var currentValue = values[i]; | |
value += (currentValue - value) / smoothing; | |
values[i] = Math.round(value); |
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
/** | |
* Two-dimensional Gaussian function | |
* | |
* @param {number} amplitude | |
* @param {number} x0 | |
* @param {number} y0 | |
* @param {number} sigmaX | |
* @param {number} sigmaY | |
* @returns {Function} | |
*/ |
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
// create private key (any password is ok) | |
openssl pkcs12 -in xxx.pfx -nocerts -out example.key | |
// remove password | |
openssl rsa -in example.key -out example.key | |
// generate private/public pair | |
openssl pkcs12 -in xxx.pfx -out privpub.pem | |
// get public certificate from privpub |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def s3_to_pandas(client, bucket, key, header=None): | |
# get key using boto3 client | |
obj = client.get_object(Bucket=bucket, Key=key) | |
gz = gzip.GzipFile(fileobj=obj['Body']) | |
# load stream directly to DF | |
return pd.read_csv(gz, header=header, dtype=str) | |
def s3_to_pandas_with_processing(client, bucket, key, header=None): |
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 pyqrcode | |
from PIL import Image | |
# create background - QR code | |
qr = pyqrcode.create('Some text',error = 'H') | |
qr.png('output.png', scale=10) | |
im = Image.open('output.png') | |
im = im.convert("RGBA") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def g_at_distance(g_base, radius, distance): | |
""" | |
Calculate gravitational accelleration at a distance | |
- above the surface G * (radius / distance)^2 | |
- below the surface G * (distance / radius) | |
Parameters | |
---------- | |
g_base : float | |
gravitational accelleration at the surface |
OlderNewer