Skip to content

Instantly share code, notes, and snippets.

Zac Bentley zbentley

  • Klaviyo
  • Boston, MA
Block or report user

Report or block zbentley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zbentley
zbentley / wrap_example.bash
Created Mar 30, 2018
Bash function wrapping with minimal eval
View wrap_example.bash
#!/usr/bin/env bash
wrap() {
local old_name="${1:?get fuct}"
local new_name="${2:?get fuct}"
_temp_function() {
echo "wrapping the old one!"
_old_function_call_placeholder param
@zbentley
zbentley / anagram.js
Created Mar 26, 2018
Anagram Identifier
View anagram.js
/*
Optimized potential-anagram identifier function.
Runs in O(N) time on the supplied string, with several o(N) optimizations as well.
Consumes at worst half of the supplied string's space in memory (additionally), plus overhead.
This algorithm uses two paths: a reusable array of integer values (it could just as well be a bitfield,
but that probably won't save any performance since memory has to be written in whole words anyway)
with a known, fixed size: it will store the first, most common, 512 characters of the alphabet and
View sadcomputer.gif.bash
function testshit {
local testname="${1:?Test name needs to be first parameter bro}"
local url="${2:?URL needs to be second parameter bro}"
local regex="${3:?Regex needs to be third parameter bro}"
# Can do this multiple times if you want with different CURL args to e.g. test the headers/response code/body:
local curlout=$(curl -whatever "$url")
if echo "$curlout" | grep -P "$regex" >/dev/null; then
echo "$testname ($url): all good"
else
echo -e "$testname ($url): failed\nexpected to match: $regex\nInstead, got output:$curlout"
You can’t perform that action at this time.