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 / smoothscroll.js
Created October 22, 2018 17:10
A vue-js supported smooth-scroll module based on a Stack Overflow answer by Manuel Otto.
const SmoothScroll = (target, speed, smooth) => {
if (target === document)
target = (document.documentElement || document.body.parentNode || document.body) // cross browser support for document scrolling
let moving = false;
let pos = target.scrollTop;
target.addEventListener('mousewheel', scrolled, false)
/* target.addEventListener('DOMMouseScroll', scrolled, false) */
function scrolled(e) {
@SamJakob
SamJakob / README.md
Last active June 7, 2023 16:40
Terrence (a bot to automatically change Discord guild icons)

Terrence 1.0.0

Changes the guild icons of any guilds the bot is a member of at a defined interval.

Usage

The bot has a customizable command prefix, however the default is t.
The default permission to execute commands is the 'Administrator' permission, however this can be changed.

  • t.update: Allows a user to indicate that an update to the Imgur album is available for the bot. Thus, allowing the cached image list from the album to be updated without restarting the bot.
  • t.change: Allows a user to pre-emptively change the Guild icon to another random image from the image list.

Setup

@SamJakob
SamJakob / README.md
Last active August 10, 2021 07:40
GDT Descriptor Macro
@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" {
<%@ language=JScript %>
<%
var SPDBInterface = {
read: function(file){
return new SPDB(file);
},
write: function(spdb, file){
FileSystem.writeFile(file, spdb.toXML());
@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
@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 / 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 / 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
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(