Skip to content

Instantly share code, notes, and snippets.

View brettinternet's full-sized avatar
👋

Brett brettinternet

👋
View GitHub Profile
@brettinternet
brettinternet / Redux nested Object.assign()
Last active January 24, 2017 02:12
For returning new state in redux with nested objects from a reducer's initialState
let state = {
nestedObj: {
x: 1,
y: 2,
},
h: 10
}
let addObj = {
@brettinternet
brettinternet / Average array elements for dataset
Last active January 30, 2017 21:19
Average every third element in an array for a more concise dataset
let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
avgs = [],
sum = 0;
arr.forEach((el, i) => {
sum += el;
if ((i + 1) % 3 == 0) {
avgs.push(sum / 3);
sum = 0;
}

Change the base url of a gist to cdn.rawgit.com

@brettinternet
brettinternet / configs
Created February 24, 2017 14:54
user configs
# .tmux.conf.local
====
set -g default-terminal "screen-256color"
set-option -g status-position bottom
set-window-option -g xterm-keys on
bind-key -n S-Up set-option -g status
bind-key -n S-Down set-option -g status
bind-key -n S-Left previous-window
bind-key -n S-Right next-window
set-option -g status-fg white
@namespace html url(http://www.w3.org/1999/xhtml);
@namespace xul url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
/*
Author: Twily
Description: Minimal flat styled tabs for Australis
Compitability: Firefox Nightly v31.0a1 - v32.0a1 (Australis)
CSS Variables were introduced to Firefox in v29.0a1
Website: http://twily.info/
*/
@brettinternet
brettinternet / now_playing.osascript
Created February 25, 2017 08:23 — forked from JorenSix/now_playing.osascript
This osascript gets and returns the meta data of the track that is currently playing in Spotify on Mac OS X.
#!/usr/bin/osascript
#
# now_playing.osascript
#
# Osascript to fetch the meta data of the currently playing
# track in Spotify. This works only on Mac OS X.
tell application "System Events"
set myList to (name of every process)
end tell
@brettinternet
brettinternet / tmux-cheatsheet.markdown
Created March 3, 2017 02:05 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@brettinternet
brettinternet / js-huh.js
Last active March 5, 2017 23:28
Go home Javascript, you're drunk
console.log(9999999999999999); // 10000000000000000
[] + {} // '[object Object]'
{} + [] // 0
console.log(!+[]+[]+![] === 'truefalse'); // true
Math.max( ...[] ) // -Infinity
Math.max( undefined ) // NaN
console.log( …[] ) // undefined
@brettinternet
brettinternet / node-logger.js
Created March 7, 2017 23:51
Debugging in node with a lightweight logger
const fs = require('fs'),
util = require('util'),
file = fs.createWriteStream(__dirname + '/error.log', {flags : 'w'}),
sout = process.stdout,
err = d => {
file.write(util.format(d) + '\n')
sout.write(util.format(d) + '\n')
}
@echo off
:: Created by: Shawn Brink
:: http://www.eightforums.com
:: Tutorial: http://www.eightforums.com/tutorials/6320-fast-startup-turn-off-windows-8-a.html
:: To turn off Fast Startup
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /V HiberbootEnabled /T REG_dWORD /D 0 /F