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
const calculateCompoundInterest = (P, r, t, n, PMT, PMT_f, toFixed=2) => { | |
/* | |
* P = initial principle | |
* r = interest rate (annual) | |
* t = duration of invesment | |
* n = compound events per year (1 = annual, 6 = semi-annual, 3 = quarterly, 12 = monthly, ...) | |
* PMT = ongoing contibution amount | |
* PMT_f = contributions per year (1 = annual, 6 = semi-annual, 3 = quarterly, 12 = monthly, ...) | |
* ---> | |
* I = total investment |
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
name: Versioning | |
permissions: write-all | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the "main" branch | |
pull_request: | |
branches: | |
- main | |
types: |
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
<?php | |
/** | |
* Generate secure URL-friendly unique ID. | |
* By default, ID will have 21 symbols to have same collisions probability | |
* as UUID v4. | |
* | |
* @param integer $len The length of the ID to generate. | |
* @param mixed $entropy balanced, true (max), false (min) | |
* @param string $alphabet The characters to use in the ID. |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover"> | |
<script src="devtools.js"></script> | |
<script> | |
devTools.init((o) => { | |
if (o.open) { |
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
const Timer = require('./timer') | |
const timer = new Timer(); | |
// do stuff... | |
timer.stop(); | |
// '1s, 589.334334 ms' |
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
class Enum { | |
constructor(...args) { | |
if (args.length === 0) { | |
throw new Error('Enum must be initialized with at least one argument'); | |
} | |
let obj = (args.length === 1) ? args[0] : args; | |
if (args.length > 1 || Array.isArray(obj)) { | |
obj = Object.assign({}, ...obj.map((x) => ({ [x]: x }))); | |
} | |
[...Object.entries(obj)].forEach((items) => { |
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 re | |
from notion.client import NotionClient | |
def enumerate_notion_items( | |
view_url, id_col, created_at_col="created_time", token=None, client=None | |
): | |
""" | |
Given that a property with name e.g. "Item ID" exists for a notion dataset, | |
and that at least one item has a value for that property, this 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Redison - an extension for redis to get/set json objects | |
# https://gist.github.com/ranaroussi/90268aca3bf438d1aabfdb918288c6a9/edit | |
# | |
# Copyright 2020 Ran Aroussi | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. |
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
hanxue-mac:Github hanxue$ git clone https://github.com/AppScale/appscale.wiki.git | |
Cloning into 'appscale.wiki'... | |
remote: Counting objects: 1745, done. | |
remote: Compressing objects: 100% (1733/1733), done. | |
remote: Total 1745 (delta 1089), reused 10 (delta 4) | |
Receiving objects: 100% (1745/1745), 267.93 KiB | 35.00 KiB/s, done. | |
Resolving deltas: 100% (1089/1089), done. | |
Checking connectivity... done | |
hanxue-mac:Github hanxue$ ls appscale.wiki/ | |
.git/ |
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 yfinance as yf | |
import pandas as pd | |
# de-annualize yearly interest rates | |
def deannualize(annual_rate, periods=365): | |
return (1 + annual_rate) ** (1/periods) - 1 | |
def get_risk_free_rate(): | |
# download 3-month us treasury bills rates | |
annualized = yf.download("^IRX")["Adj Close"] |
NewerOlder