Skip to content

Instantly share code, notes, and snippets.

@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:
# {
@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) {
@mikowl
mikowl / oneliners.js
Last active February 19, 2025 05:20
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@victorBaro
victorBaro / GlowingWaves.metal
Last active March 4, 2025 23:14
Glowing waves shader using new SwiftUI colorEffect modifier. Used code from here: https://github.com/GrishTad/GlowingWaves - Original shadertoy implementation here: https://www.shadertoy.com/view/tlySzm
#include <metal_stdlib>
using namespace metal;
// MARK: Helper methods
float N2(float2 p) {
p = fmod(p, float2(1456.2346));
float3 p3 = fract(float3(p.xyx) * float3(443.897, 441.423, 437.195));
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.x + p3.y) * p3.z);
}