Skip to content

Instantly share code, notes, and snippets.

View bebrws's full-sized avatar

Brad Barrows bebrws

View GitHub Profile
@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 <mathias.lafeldt@gmail.com> */
/* This file defines standard ELF types, structures, and macros.
@bebrws
bebrws / bpf.c
Created February 26, 2022 00:59 — forked from 2opremio/bpf.c
Example of using bpf to capture packets in OSX
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <err.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@bebrws
bebrws / UbuntuVNC.md
Last active April 21, 2021 18:14
VNC Server on Ubuntu 20.10 Using TightVNC