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
use crate::layer::Layer; | |
use crate::network::Network; | |
fn get_d_output( | |
output_layer: &Layer, | |
delta: Vec<f64>, | |
) -> Vec<f64> { | |
if output_layer.activation_functions.len() > 0 { | |
output_layer | |
.activation_functions |
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
const queue: Set<Promise<unknown>> = new Set() | |
const queueEmpty = async (): Promise<void> => { | |
await Promise.all(queue) | |
if (queue.size) { | |
await queueEmpty() | |
} | |
} |
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
#!/bin/bash | |
# usage: | |
# ./script.sh -a <value for a> -b <value for b> | |
while getopts a:b: opt | |
do | |
case $opt in | |
a) VAR_A=$opt;; | |
b) VAR_B=$opt;; | |
esac |
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 ts from 'typescript' | |
const unpackImportPath = (node: ts.ImportDeclaration): string => { | |
const moduleSpecifier = node.moduleSpecifier as ts.StringLiteral | |
return moduleSpecifier.text | |
} | |
const transformImport = ( | |
factory: ts.NodeFactory, | |
node: ts.ImportDeclaration, |
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
const reporter = (path: string[] = []) => ({ | |
get(target, property) { | |
if (typeof target[property] === 'object') { | |
return new Proxy(target[property], reporter(path.concat(property))) | |
} else { | |
return Reflect.get(target, property) | |
} | |
}, | |
set(target, property, value) { | |
console.log('setting ', path.concat(property).join('.')) |
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
/** | |
* - Create a coinmarketcap.com account and paste your API key below. | |
* - In Google Sheets go to Tools -> Script editor and paste this code in a new CMCIMPORT.gs script file | |
* - Use the function in your sheet, e.g. =CMCIMPORT("ADA") | |
*/ | |
function CMCIMPORT(symbol) { | |
const cache = CacheService.getDocumentCache() | |
if (cache.get('prices') == null) { | |
const response = UrlFetchApp.fetch('https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1&limit=500&convert=USD',{ | |
headers: { |
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
#!/bin/bash | |
# get the CloudFront Id | |
CF_DISTRIBUTION_ID=$(aws cloudfront list-distributions \ | |
--query "DistributionList.Items[?contains(Aliases.Items[0], "example.com")] | [0].Id" \ | |
--output text | |
) | |
# invalidate all paths | |
aws cloudfront create-invalidation --distribution-id ${CF_DISTRIBUTION_ID} --paths "/*" |
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
{ | |
"scripts": { | |
"postversion": "git reset --soft HEAD~1 && git commit --amend -C HEAD", | |
... | |
} | |
... | |
} | |
} |
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
const myScript = Object.assign(document.createElement('script'), { | |
src: '/some-script.js', | |
type: 'text/javascript', | |
async: true, | |
}); | |
document.head.appendChild(myScript); |
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
# node-switch alias | |
alias ns=$HOME/scripts/node-switch.sh | |
# switch node version based on .nvmrc | |
default_node_version=12.13.1 | |
chpwd() { | |
if [[ -f .nvmrc && -r .nvmrc ]]; then | |
ns switch "$(< .nvmrc)" | |
elif [[ $(node --version) != v$default_node_version ]]; then | |
ns switch $default_node_version |
NewerOlder