Skip to content

Instantly share code, notes, and snippets.

View InBrewJ's full-sized avatar
🐼
eyes

Jason Brewer InBrewJ

🐼
eyes
View GitHub Profile
@InBrewJ
InBrewJ / big_boy_branch.py
Last active May 23, 2020 08:10
Largest Branch: BST, Iteration!
def goLeft(tree):
left_sum = 0
power_count = 1
descending = True
while descending:
for i in range( (2**power_count)-1, (2**(power_count+1))-1 ):
level_span = ((2**power_count)-1)
range_len = len(range( (2**power_count)-1, (2**(power_count+1))-1))
try:
@InBrewJ
InBrewJ / squash-the-squashed.sh
Created March 16, 2020 14:48
How to convert a PR with already squashed commits into a single commit
# WARNING: THIS WILL GET RID OF THE COMMITS ON YOUR FEATURE BRANCH TOO!
# Original steps
# 1. Start with a clean version branch.
# 2. git reset master
# 3. git add . (notice trailing dot in there)
# 4. git commit -m "A really meaningful commit message"
# 5. git push --force
git reset master && \
@InBrewJ
InBrewJ / Fibonacci.scala
Last active May 23, 2020 10:02
Iterative Fibonacci Sequence in Scala for no reason whatsoever
object fibonnaci {
var lastMinusOne = 0
var last = 0
for (count <- 1 to 10) {
if (count == 2) lastMinusOne = lastMinusOne + 1
println({val current = last + lastMinusOne; current })
val tempLast = last
last = last + lastMinusOne // aka current
lastMinusOne = tempLast
import random
from random import choices
name='Scrabble'
def split(word):
return [char for char in word]
score_map = {
"E": 1,
import unittest
import pairing_exercise
class TestPairingExercise(unittest.TestCase):
def test_calculate(self):
self.assertEqual(pairing_exercise.get_score('GUARDIAN1'), 10)
@InBrewJ
InBrewJ / highlight_depth.css
Last active July 30, 2020 14:32
All credit goes to this guy (Gajus Kuizinas): https://qr.ae/pNse0f
* { background-color: rgba(255,0,0,.2); }
* * { background-color: rgba(0,255,0,.2); }
* * * { background-color: rgba(0,0,255,.2); }
* * * * { background-color: rgba(255,0,255,.2); }
* * * * * { background-color: rgba(0,255,255,.2); }
* * * * * * { background-color: rgba(255,255,0,.2); }
@InBrewJ
InBrewJ / disable_network_interface.sh
Last active September 11, 2020 16:34
How to toggle a network interface in Pop OS 20.04 (on the wise ThinkPad)
# To show the current link state
ip link show
# To disable the wlp3s0 interface (the built in one)
if=wlp3s0
sudo ip link set $if down
# or
sudo ip link set wlp3s0 down
@InBrewJ
InBrewJ / rebase_from_master.sh
Created October 30, 2020 10:09
Rebasing from master - make your feature branch clean (All credit to @joeyciechanowicz)
git co -b feature-name
# ... do some stuff
git commit -am "message"
# .. go away for a while
git fetch origin/master
git rebase origin master
# ... do some more work
git add .
git commit --amend
@InBrewJ
InBrewJ / FilterDependabotFromPRs.txt
Last active January 14, 2024 00:30
Filter for PRs from real people (i.e. not dependabot)
is:open is:pr -author:app/dependabot
@InBrewJ
InBrewJ / rebase.sh
Created December 24, 2021 11:54
git rebase: always trust one source of commits for merge conflicts
## See https://stackoverflow.com/a/66766065/8249410
## IN A REBASE, THE MEANING OF OURS / THEIRS IS REVERSED
## Because we're replaying commits over the other branch, the commits you're adding over the
## base branch become 'theirs' wrt the base branch
## capeesh?
## To choose the influence of `origin/main` for rebase conflicts
git rebase -s recursive -X ours origin/main
## To choose the influence of your current branch for rebase conflicts