Skip to content

Instantly share code, notes, and snippets.

View callumacrae's full-sized avatar

Callum Macrae callumacrae

View GitHub Profile
@fnky
fnky / ANSI.md
Last active April 24, 2024 21:19
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@william8th
william8th / .tmux.conf
Last active April 21, 2024 02:07
Tmux open new pane in same directory
# Set the control character to Ctrl+Spacebar (instead of Ctrl+B)
set -g prefix C-space
unbind-key C-b
bind-key C-space send-prefix
# Set new panes to open in current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
@ffoodd
ffoodd / improved-sr-only.markdown
Last active April 11, 2024 22:55
Improved .sr-only

Improved .sr-only

Theorically bulletproof CSS class for visually hide anything and keep it accessible to ATs.

A Pen by ffoodd on CodePen.

License.

@paulirish
paulirish / what-forces-layout.md
Last active April 24, 2024 12:47
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
@paulirish
paulirish / bling.js
Last active April 20, 2024 17:39
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active April 24, 2024 12:29
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@toddmotto
toddmotto / qsa.js
Last active August 29, 2015 14:02
104 bytes jQuery-like wrapper, $('.class') returns NodeList, $('.class:first') returns first Node only, optional scoping $('.class', '.parent')
function $(a,b){return(b||document)['querySelector'+(b=/\:first$/,b.test(a)?'':'All')](a.replace(b,''))}
@yocontra
yocontra / fucking-run-chrome.js
Created April 14, 2014 00:46
Testing WebRTC in Chrome
var os = require('os');
var path = require('path');
var randomDir = function() {
return path.join(os.tmpdir(), String(Math.floor(Math.random()*1000)));
};
var openit = function(url) {
var chromeLocation = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
var args = [
@cfj
cfj / console.clog.js
Last active April 2, 2021 18:17
console.clog
window.console.clog = function(log){
var message = typeof log === 'object' ? '%cLooks like you\'re trying to log an ' : '%cLooks like you\'re trying to log a ',
style = 'background:url(http://i.imgur.com/SErVs5H.png);padding:5px 15px 142px 19px;line-height:280px;';
console.log.call(console, message + typeof log + '.', style);
};
@callumacrae
callumacrae / build-tools.md
Last active October 25, 2023 15:14
Build tools written in JavaScript