Skip to content

Instantly share code, notes, and snippets.

View briandemant's full-sized avatar
💭
is happy coding

Brian Demant briandemant

💭
is happy coding
View GitHub Profile
CMD = Super
# General
FDAS
## Text navigation
CTRL + LEFT/RIGHT : jump word forward/backward
CTRL + SHIFT + LEFT/RIGHT : select word forward/backward
Super + Q
import { EventEmitter } from 'events'
interface MyEvent {
payload: any
}
type MyOpenEvent = MyEvent & { type: 'open' }
type MyCloseEvent = MyEvent & { type: 'close' }
type MyOpenHandler = (event: MyOpenEvent) => void
@briandemant
briandemant / googleips.sh
Created March 12, 2019 10:33
get current public ip ranges's for google cloud
for x in $(nslookup -q=TXT _cloud-netblocks.googleusercontent.com 8.8.8.8| egrep -o "include:_cloud[-.a-z0-9]*" | cut -c9-);do
nslookup -q=TXT $x 8.8.8.8 | egrep -o 'ip4:[./0-9]*' | cut -c5-
done
const lockUpdaters = {}
function sleep(timeout) {
return new Promise((resolve) => {
setTimeout(resolve, timeout)
})
}
async function waitForLock(lockname, timeoutWindow) {
@briandemant
briandemant / slack-dark-mode.sh
Created February 8, 2019 06:45 — forked from mmrko/slack-dark-mode.sh
Dark Mode for Slack (macOS)
#!/usr/bin/env bash
# Homebaked Slack Dark Mode. After executing this script, hit refresh (⌘ + R) or restart Slack for changes to take effect.
# Adopted from https://gist.github.com/a7madgamal/c2ce04dde8520f426005e5ed28da8608
SLACK_RESOURCES_DIR="/Applications/Slack.app/Contents/Resources"
SLACK_SSB_INTEROP_FILEPATH="$SLACK_RESOURCES_DIR/app.asar.unpacked/src/static/ssb-interop.js"
THEME_FILEPATH="$SLACK_RESOURCES_DIR/dark-theme.css"
curl -o "$THEME_FILEPATH" "https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css"
Tue Apr 10 13:47:51 UTC 2018

Effective Engineer - Notes

What's an Effective Engineer?

  • They are the people who get things done. Effective Engineers produce results.

Adopt the Right Mindsets

#!/bin/bash
zero_pad(){
# zero_pad <string> <length>
[ ${#1} -lt $2 ] && printf "%0$(($2-${#1}))d" ''
printf "%s\n" "$1"
}
source=$1
name=${2:-$(basename $source)}
@briandemant
briandemant / fake_sendmail.sh
Last active September 5, 2016 07:59 — forked from xianhuazhou/gist:1415626
a fake sendmail script for testing mail related applications, can replace /usr/sbin/sendmail
#!/bin/sh
# Source : https://github.com/Sanchiz/fake_sendmail.sh
prefix="/home/USERNAME/sendmail/new"
numPath="/home/USERNAME/sendmail"
if [ ! -f $numPath/email_numbers ]; then
echo "0" > $numPath/email_numbers
fi
@briandemant
briandemant / cache_using_etag.php
Last active December 7, 2015 19:37
php caching headers
function ifNoneMatch($etag, $expire = 60, $cacheAt = "public",$mime_type = 'application/json') {
header("Content-Type: $mime_type");
header("Cache-Control: max-age=$expire, $cacheAt=true");
header('Expires:' . gmdate('D, d M Y H:i:s T', strtotime("+$expire seconds", $timestamp)));
header('Etag:' . $etag);
// exit if not modified
if ($_SERVER['HTTP_IF_NONE_MATCH'] == $etag) {
header("HTTP/1.1 304 Not Modified");
exit;