Skip to content

Instantly share code, notes, and snippets.

@marnovo
marnovo / changeJDK.bash
Created October 20, 2020 09:17 — forked from trmaphi/changeJDK.bash
[Change system wide java version on Mac OS] Inspire by a stackoverflow answer https://stackoverflow.com/a/44169445/6730571 #bash #mac
#!/usr/bin/env bash
JDKS_DIR="/Library/Java/JavaVirtualMachines"
JDKS=( $(ls ${JDKS_DIR}) )
JDKS_STATES=()
# Map state of JDK
for (( i = 0; i < ${#JDKS[@]}; i++ )); do
if [[ -f "${JDKS_DIR}/${JDKS[$i]}/Contents/Info.plist" ]]; then
JDKS_STATES[${i}]=enable
@marnovo
marnovo / zapier-extract-urls.js
Last active May 7, 2023 04:07
Extract URLs from HTML source, as website or email.
// JS from https://johnathon.blog/how-to-use-zapier-extract-all-urls-from-text/
// regex from dperini's adapted to JS & any matches https://mathiasbynens.be/demo/url-regex
var re_weburl = new RegExp(/\b((?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?)/)
output = inputData.rawBody.match(re_weburl) || [];
return output.map(function(url) {
return {url: url};
});
SELECT
files.file_path, ref_commits.repository_id, files.blob_content
FROM
files
NATURAL JOIN
commit_files
NATURAL JOIN
ref_commits
WHERE
ref_commits.ref_name = 'HEAD'
@marnovo
marnovo / enable_aptx_aac_macos.sh
Created January 22, 2018 21:43
Enable AptX and AAC codecs on macOS
# (c) 2018 Marcelo Novaes
# License - MIT
# Enable AptX and AAC codecs on bluetooth connections on macOS
sudo defaults write bluetoothaudiod "Enable AptX codec" -bool true
sudo defaults write bluetoothaudiod "Enable AAC code" -bool true
# Reads set values, should return something like:
# {
@marnovo
marnovo / deviceQuery-output-GTX1080Ti.log
Created November 6, 2017 21:05
NVIDIA CUDA deviceQuery utility output from a GTX 1080 Ti GPU
~/NVIDIA_CUDA-9.0_Samples/1_Utilities/deviceQuery > ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GTX 1080 Ti"
CUDA Driver Version / Runtime Version 9.0 / 9.0
CUDA Capability Major/Minor version number: 6.1
@marnovo
marnovo / xcode-switcher-for-cuda.sh
Created November 3, 2017 17:22
Selects the right xcode for normal usage or CUDA usage
# Selects the right xcode for normal usage or CUDA usage
PS3='xcode version selector: '
options=("Xcode latest (9.0)" "Xcode 8.3.3 (CUDA)" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Xcode latest (9.0)")
echo "you chose: Xcode latest (9.0)"