Skip to content

Instantly share code, notes, and snippets.

View bebrws's full-sized avatar

Brad Barrows bebrws

View GitHub Profile
@bebrws
bebrws / soundOnSlack.sh
Last active September 26, 2024 00:19
Play Audio Notification on MacOS for Slack Notifications
#!/bin/bash
##### INSTRUCTIONS
# 1. Just place this script in your home directory, make it executable, and run it:
# curl -O https://lnkd.in/gHkrCECr https://gist.githubusercontent.com/bebrws/a0ac04b59da575f36eb104b228182c1f/raw/089c60103df44ab33df4a006aeb8e4b49a3822e0/soundOnSlack.sh
# chmod +x soundOnSlack.sh
# ./soundOnSlack.sh
#
# This will create a launch agent that will run the script every time you login.
# and it will utilize the system logging to listen for Slack notifications to play a sound passively.
@bebrws
bebrws / macOS-Preferences-Defaults.sh
Created September 23, 2024 18:50 — forked from ChristopherA/macOS-Preferences-Defaults.sh
macOS Preferences Defaults
#!/usr/bin/env zsh
#===========================================================================
# * INFO
#
# macOS Preferences Defaults
# By Christopher Allen @ChristopherA https://github.com/christophera/
# My most basic macOS preferences, in this gist to make it easy to load on
# multiple machines and VMs. Ideally runs on all macOS versions since Yosemite,
@bebrws
bebrws / site-config.json
Created April 17, 2023 22:01
Configure a local Sourcegraph instance to not require login - UNSAFE if server is public
{
"auth.degraded.public": true,
"auth.public": true,
"auth.providers": [
{
"allowSignup": true,
"type": "builtin"
}
],
"externalURL": "http://localhost:3080",
@bebrws
bebrws / sourcegraph.plist
Last active April 27, 2023 17:29
An OSX LaunchAgent plist file for starting sourcegraph on startup. Useful if your running a local sourcegraph instance on an extra Mac
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>dev.bbarrows.sourcegraph-local-server</string>
<key>ServiceDescription</key>
<string>Start the sorucegraph service on boot</string>

Add this to /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist Thanks to: https://gist.github.com/emotality/b1bcb2bb8a07921f9c8cad1c969daedf

<key>Duplication</key>
<dict>
    <key>Duplicate Current Line</key>
    <string>moveToBeginningOfLine:, deleteToEndOfLine:, yank:, insertNewline:, moveToBeginningOfLine:, yank:</string>
    <key>Duplicate Lines</key>
    <string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
@bebrws
bebrws / nonRepeatingCharInterviewQuestion.js
Created March 24, 2023 14:55
An interview question in Javascript - Find the first non repeating character in a string. Return that or null if no non repeating chars are found.
// firstNonRepeatingChar is a function that should find the first character in a string of characters that is non repeating
// non repeating meaning that it is only found in the input string (str) once
// if there are multiple non repeating characters the first non repeating character should be returned
// if all characters in the string repeat null should be returned
function firstNonRepeatingChar(str) {
throw new Error("Please implement this function");
}
function testCase(description, inputString, expectedResult) {
@bebrws
bebrws / nonRepeatingCharInterviewQuestion.ts
Created March 24, 2023 14:54
An interview question for JS/Typescript - Find the first non repeating character in a string. Return that or null if no non repeating chars are found.
// firstNonRepeatingChar is a function that should find the first character in a string of characters that is non repeating
// non repeating meaning that it is only found in the input string (str) once
// if there are multiple non repeating characters the first non repeating character should be returned
// if all characters in the string repeat null should be returned
function firstNonRepeatingChar(str: string): string | null {
throw new Error("Please implement this function");
}
function testCase(description: string, inputString: string, expectedResult: string | null) {
@bebrws
bebrws / monad.ts
Created March 24, 2023 14:52
Typescript Monad Interview Question - Filled in with answer - Idea is to ask to implement one of the functions that uses the Maybe monad
// Start with an explanation of what this code is (a Maybe monad implementation) and what a Maybe monad is and why it is useful
/*
The Maybe monad is a type of monad used in functional programming to handle values that may or may not exist or maybe invalid,
and it is particularly useful when dealing with some kind of untyped/unvalidated input. For example, a string that a user inputs.
Let's say we want the user to write a number. The string we get as input could be empty or contain letters, etc...
It is common to encounter situations where we read values that do not have a, such as when retrieving data from a database or
parsing input from a user. When a value is missing, attempting to perform operations on it can lead to errors, crashes, or unexpected behavior in the program.
The Maybe monad provides a way to handle these situations in a safe and predictable manner. It works by wrapping a
@bebrws
bebrws / MuteChrome.workflow
Created March 23, 2023 16:50
Mute Google Chrome from Automator Workflow
on run {input, parameters}
tell application "Google Chrome"
activate
tell application "System Events"
-- key code 123 using {shift down, command down} -- shift-command-left
tell application "System Events" to keystroke "d..." using command down
end tell
end tell
@bebrws
bebrws / elf.h
Created June 11, 2022 17:33 — forked from mlafeldt/elf.h
elf.h for OSX
/* This is the original elf.h file from the GNU C Library; I only removed
the inclusion of feature.h and added definitions of __BEGIN_DECLS and
__END_DECLS as documented in
https://cmd.inp.nsk.su/old/cmd2/manuals/gnudocs/gnudocs/libtool/libtool_36.html
On macOS, simply copy the file to /usr/local/include/.
Mathias Lafeldt <[email protected]> */
/* This file defines standard ELF types, structures, and macros.