Skip to content

Instantly share code, notes, and snippets.

View SamJakob's full-sized avatar
:octocat:
Programming

SamJakob SamJakob

:octocat:
Programming
View GitHub Profile
@SamJakob
SamJakob / Tensorboard.md
Created April 25, 2022 18:11
Helper class for Tensorboard (can be used directly in Jupyter notebooks)

Tensorboard Helper

Usage

  1. Add tensorboard.py to your project.
    • Add the file to your project and import it.
    • Or, if using Jupyter Notebook, paste it into a code cell.
  2. Initialize the class as follows:
# Clear any logs from previous runs
!rm -rf ./logs/
@SamJakob
SamJakob / .zshrc
Created April 5, 2022 05:54
zsh script to check if in an npm directory when trying to run yarn
# ...
# Ensure yarn is not run in an npm directory.
yarn() {
if [ -f "./package-lock.json" ]; then
echo "no... this is an npm directory"
else
command yarn $@
fi
}
@SamJakob
SamJakob / kramdown_rfc_test.mkd
Created March 29, 2022 00:57
Bare-bones example for kramdown-rfc

title: Test Protocol abbrev: TP docname: draft-test-00 date: 2022-03-29 category: std submissionType: IETF

ipr: trust200902 area: Applications

from tensorflow.keras import backend as K
@tensorflow.function
def angeleaky_elu(x, alpha=1.0):
"""
Custom activation function that introduces a bias between 0 < x < 0.5 to
'throttle' the positive values that the network is not confident in.
"""
return K.switch(
@SamJakob
SamJakob / kde-screenshot.sh
Created November 24, 2021 15:50
KDE screenshot script
# This might not be super useful for most cases because you could just install a screenshot tool
# designed for KDE and you likely wouldn't have gnome installed - but it was useful for a specific
# lab environment.
gnome-screenshot -a -f /tmp/screenshot.png; xclip -selection clipboard -i /tmp/screenshot.png -t image/png; rm /tmp/screenshot.png
@SamJakob
SamJakob / snake_camel_case_converter.dart
Created November 22, 2021 23:10
Snakes and Camels!
/// Converts an upper camel case string to lower snake case.
String toLowerSnake(String value) {
return value.replaceAllMapped(RegExp(r"([A-Z])"), (match) => "_${match.group(1)!.toLowerCase()}");
}
/// Converts a lower snake case string to upper camel case.
String toUpperCamel(String value) {
return value.replaceAllMapped(RegExp(r"_([a-z])"), (match) => match.group(1)!.toUpperCase());
}
@SamJakob
SamJakob / PorterStemmer.js
Created October 28, 2021 13:52
Porter stemmer in JavaScript
// Original source: https://tartarus.org/martin/PorterStemmer/js.txt
// This algorithm/implementation is public domain, free for any purpose. If in doubt, please
// ...refer to FAQ#1 ("What is the licensing arrangement for this software?") at:
// ... https://tartarus.org/martin/PorterStemmer/
// (Reproduced here for convenience).
// Porter stemmer in Javascript. Few comments, but it's easy to follow against the rules in the original
// paper, in
//
@SamJakob
SamJakob / script.sh
Last active September 16, 2021 03:01
Hotfix for typedoc package.json
# This should be added to package.json as a 'postinstall' script.
curl https://gist.githubusercontent.com/SamJakob/6fd2f06cc38242557e5d2d50fbe7a157/raw/62bae510910db76c9ef503b92288b429c62a4206/typedoc_package.json > ./node_modules/typedoc/package.json
<%@ language=JScript %>
<%
var SPDBInterface = {
read: function(file){
return new SPDB(file);
},
write: function(spdb, file){
FileSystem.writeFile(file, spdb.toXML());
@SamJakob
SamJakob / elf.h
Last active August 23, 2021 21:17
elf.h for macOS 11
/*
Original file: https://gist.github.com/mlafeldt/3885346
Modified by SamJakob on August 23rd 2021 to include changes suggested
by @jastka4.
*/
#undef END_C_DECLS
#ifdef __cplusplus
# define BEGIN_C_DECLS extern "C" {