Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattcodez
mattcodez / test.md
Created May 4, 2022 04:29
markdown test

Hello world

hi, hiya

/* GAME OF LIFE
1. Any live cell with fewer than two live neighbours dies.
2. Any live cell with two or three live neighbours lives on to the next generation.
3. Any live cell with more than three live neighbours dies.
4. Any dead cell with exactly three live neighbours becomes a live cell.
*/
const blinkerSeed = {
height: 5,
coords: [[2,1], [2,2], [2,3]]
// Use only vanilla JS
function callWhenReadyToGo(cb) {
var allImagesLoaded = false;
// Look at all P and SPAN for very short text that says "loading"
// we don't want long text as it might be part of a longer paragraph then
var textEls = document.querySelectorAll('SPAN, P');
var loadingEls = [];
for (var i = 0; i < textEls.lenth; i++){
@mattcodez
mattcodez / fib_iterative.js
Created February 23, 2018 13:24
Fibonacci
function fib_i(num) {
console.log(`Series of ${num}`);
let num2 = 0, num1 = 1;
for (let i = 0; i < num; i++) {
console.log(num1);
const next = num2 + num1;
num2 = num1;
num1 = next;
}
}
@mattcodez
mattcodez / term.sh
Created September 12, 2017 17:43
Terminal stuff
watch --color git diff --color --stat
watch git status --porcelain
@mattcodez
mattcodez / .tmux.conf
Created August 29, 2017 22:31
Saving my current tmux conf
set -g mouse on
#set-option -g mouse on
set -g status-interval 2
set -g status-right "#S #[fg=green,bg=black]#(tmux-mem-cpu-load --colors --interval 2 --powerline-right)#[default]"
set -g status-right-length 60
set -g pane-border-status top
set -g pane-border-format "#{pane_index} #{pane_current_command} #{pane_pid}"
set -g default-terminal "screen-256color"
bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S - ; save-buffer %1 ; delete-buffer'
@mattcodez
mattcodez / mypi.cpp
Last active September 11, 2017 02:21
Very simple JS pi generator
// g++ -o mypi -std=c++14 mypi.cpp
#include <iostream>
#include <string>
#include <ctime>
#include <limits>
double myPi(long long loopCount);
typedef std::numeric_limits< double > dbl;
function myPromise(fn){
let done = false;
let next = [];
fn(() => {
done = true;
while (next.length > 0) next.pop()();
});
return {
then: fn => {
@mattcodez
mattcodez / thinArrow.js
Last active March 14, 2016 15:26
Proposal for temporary scope variables
//Proposal for temporary scope variables
let result = something.crazy.long.bar ? something.crazy.long.bar() : something.crazy.long.other();
//with() - Not 'strict' compliant
with (something.crazy.long){
result = bar ? bar() : other();
}
//fat arrow function