Skip to content

Instantly share code, notes, and snippets.

View austintraver's full-sized avatar

Austin Traver austintraver

View GitHub Profile
@austintraver
austintraver / nap.sh
Created June 29, 2023 19:03
An illustrative example on how to use ZSH traps.
#!/bin/zsh
nap() {
print "Taking a nap..."
command sleep 3
}
TRAPINT() {
# Remove the printed '^C' from the console.
print -n "\x1b[2D"
@austintraver
austintraver / authy-qr-codes.js
Last active October 11, 2022 03:51
Export authentication codes from Authy
// QRious v4.0.2 | (C) 2017 Alasdair Mercer | GPL v3 License Based on jsqrencode | (C) 2010 [email protected] | GPL v3 License
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.QRious=e()}(this,function(){"use strict";function t(t,e){var n;return"function"==typeof Object.create?n=Object.create(t):(s.prototype=t,n=new s,s.prototype=null),e&&i(!0,n,e),n}function e(e,n,s,r){var o=this;return"string"!=typeof e&&(r=s,s=n,n=e,e=null),"function"!=typeof n&&(r=s,s=n,n=function(){return o.apply(this,arguments)}),i(!1,n,o,r),n.prototype=t(o.prototype,s),n.prototype.constructor=n,n.class_=e||o.class_,n.super_=o,n}function i(t,e,i){for(var n,s,a=0,h=(i=o.call(arguments,2)).length;a<h;a++){s=i[a];for(n in s)t&&!r.call(s,n)||(e[n]=s[n])}}function n(){}var s=function(){},r=Object.prototype.hasOwnProperty,o=Array.prototype.slice,a=e;n.class_="Nevis",n.super_=Object,n.extend=a;var h=n,f=h.extend(function(t,e,i){this.qrious=t,this.element=e,this
A = [1, 3, 6, 4, 1, 2]
s = set(A)
i = 1
while True:
if i not in s:
return i
else:
i += 1
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
# Initialize our variables using the first element.
current_subarray = max_subarray = nums[0]
# Start with the 2nd element since we already used the first one.
for num in nums[1:]:
# If current_subarray is negative, throw it away. Otherwise, keep adding to it.
current_subarray = max(num, current_subarray + num)
max_subarray = max(max_subarray, current_subarray)
@austintraver
austintraver / hist.sh
Created August 10, 2021 15:58
A fuzzy finder to search history in the Z Shell.
function fuzzy-search-history() {
# Assemble the list of commands found in history,
# such that it only contains the most recent occurrence
# of a particular command.
typeset -a entries=()
for line in ${(f)"$(fc -nl 1)"}; do
entries+=${${line//\\n/ }//\\t/ };
done
BUFFER=$(
print -l ${(Oau)entries} \
@austintraver
austintraver / ublock.txt
Last active February 23, 2023 06:22
uBlock Filters
||js.driftt.com/core$subdocument
||ogs.google.com/u/0/widget/callout/sid$subdocument
||player.vimeo.com/video/568544033$subdocument
||publisher.liveperson.net/iframe-le-tag/iframe.html?lpsite=60270350&lpsection=store-sales-en-us&buttons=lpChatService,lpChatSales$subdocument
askubuntu.com##.js-consent-banner
askubuntu.com##.ps-relative.js-freemium-cta
audio.microsoft.com##.context-uhf.uhfc-universal-context
bizbrains.com###coiOverlay
configure.zsa.io##.hurnZj.sc-hiSbYr
configure.zsa.io##.ioWVHA.sc-dkmKpi
@austintraver
austintraver / cookies.txt
Last active October 31, 2021 07:12
Cosmetic filtering for cookie permission requests on the web, for use with uBlock Origin
! GNU GENERAL PUBLIC LICENSE
! Version 3, 29 June 2007
!
! Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
! Everyone is permitted to copy and distribute verbatim copies
! of this license document, but changing it is not allowed.
!
! Preamble
!
! The GNU General Public License is a free, copyleft license for
@austintraver
austintraver / apt.conf
Last active June 3, 2021 19:53
Convenience configuration for Docker files, so that I don't have to keep typing `--no-install-recommends`
# From man://apt.conf(5)
#
# /etc/apt/apt.conf is the main configuration file shared by all the tools in the APT suite
# of tools, though it is by no means the only place options can be set. The suite also
# shares a common command line parser to provide a uniform environment.
#
# When an APT tool starts up, it will check the environment for the parameter
# APT_CONFIG, and read in values from that location if there are any. Else, `apt`
# will default to searching /etc/apt/apt.conf and /etc/apt/apt.conf.d/* for
# any additional configurations.
@austintraver
austintraver / zshcontrib.1
Last active April 7, 2021 08:05
Markdown of zshcontrib(1) converted back into `man` format
.TH "ZSHCONTRIB" "1" "February 14, 2020" "" ""
.hy
.SH NAME
.PP
zshcontrib - user contributions to zsh
.SH DESCRIPTION
.PP
The Zsh source distribution includes a number of items contributed by the user
community.
These are not inherently a part of the shell, and some may not be available in
@austintraver
austintraver / cling.sh
Created March 22, 2021 00:47
Configure LLVM & Clang as the default C/C++ developer toolchain
function cling {
if (( ${#} != 1 )); then
echo "usage: \`cling VERSION\` " >&2
return 1
fi
typeset version=${1}
typeset priority=$(( ${version} * 10 ))