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
Optionals.ifPresentOrElse(opt, System.out::println, | |
() -> System.out.println("not present")); |
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
Optional.of(opt).map(value -> { System.out.println(value); | |
return value; }) | |
.orElseGet(() -> { System.out.println("not present"); | |
return -1;}); |
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
// Primitive hash function that for a string returns a positive 32 bit int | |
// Do not use in production, use murmur3 or fnv1 | |
// You can improve this by changing 5 to 31 | |
Object.defineProperty(String.prototype, 'hashCode', { | |
value: function() { | |
var hash = 0, i, chr; | |
for (i = 0; i < this.length; i++) { | |
chr = this.charCodeAt(i); | |
hash = ((hash << 5) - hash) + chr; | |
hash |= 0; // Convert to 32bit integer |
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
<cfscript> | |
startedAt = getTickCount(); | |
inputFilepath = expandPath( "../images/beach-small.jpg" ); | |
// In the first approach to drawing a partially-transparent image over another, we're | |
// going to create an intermediary image that represents the image overlay. This will | |
// the SCALED and PARTIALLY-TRANSPARENT image. | |
// -- |
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
#!/bin/bash | |
# Usage: clone_all_repos.sh [organization] <output directory> | |
ORG=$1 | |
PER_PAGE=100 | |
GIT_OUTPUT_DIRECTORY=${2:-"/tmp/${ORG}_repos"} | |
if [ -z "$GITHUB_TOKEN" ]; then | |
echo -e "Variable GITHUB_TOKEN isn't set! Please specify your GitHub token.\n\nMore info: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/" | |
exit 1 |
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 E(BaseException): | |
def __new__(cls, *args, **kwargs): | |
return cls | |
def a(): yield | |
a().throw(E) |
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
# ================================================================================== | |
# M1 Finance/Google Sheets Tracker | |
# -------------------------------- | |
# Author: Michael Johnson | |
# Last updated: May 25, 2020 | |
# | |
# This script works in tandem with a Python script to easily | |
# access and update information relating to my M1 Finance portfolio | |
# in a Google Sheet. | |
# |