Skip to content

Instantly share code, notes, and snippets.

@mikowl
mikowl / oneliners.js
Last active March 28, 2024 20:52
👑 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);
@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) {
@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:
# {
@marcusramberg
marcusramberg / -
Last active April 9, 2024 09:45
kitty.conf including nord color theme
# vim:fileencoding=utf-8:ft=conf
# Fully featured
font_family FuraCode Nerd Font Mono
italic_font auto
bold_font auto
bold_italic_font auto
# Font size (in pts)
font_size 11.0
@yang-wei
yang-wei / note.md
Last active April 2, 2024 22:27
Clojure Thread-first vs Thread-last Macros

Repost from:

http://yangweilim.com/blog/2015/11/18/clojure-thread-first-vs-thread-last-macros/

In this post, I am going to show you {when|how} to use Clojure marcos, ->> aka thread-last and -> aka thread-first. In some case, -> and ->> may perform the same operation if you do not pay enough attention. So I will also show you what's the difference between them. Note that doc -> and docs ->> din't make sense for me at first, so if same thing happened to you I hope that this post will make it clear.

If I am coding a function in Clojure, I would not think to write in macro firstly(maybe I am still new to it?). Macros like -> and ->> only come in my mind when it comes to refactoring. They are not neccessary in our program but they will make it elegant.

To explain how both of these macros work, let's us solve a quiz together.

[Write a function which calculates factorials.](http://www.4clojure.com/prob

@paulirish
paulirish / what-forces-layout.md
Last active April 14, 2024 08:07
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@staltz
staltz / introrx.md
Last active April 15, 2024 10:24
The introduction to Reactive Programming you've been missing
@mislav
mislav / _readme.md
Last active March 28, 2024 00:47
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 15, 2024 11:43
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a