Skip to content

Instantly share code, notes, and snippets.

View johnnybenson's full-sized avatar
👽
let's go

j-hnny johnnybenson

👽
let's go
View GitHub Profile
@johnnybenson
johnnybenson / clean_up_lambda.sh
Created March 29, 2023 21:17
Clean up old AWS Lambda Functions
function run() {
LAMBDA_FUNCTION=$1;
LAMBDA_VERSIONS_DATA=$(aws lambda list-versions-by-function --function-name $LAMBDA_FUNCTION);
LAMBDA_VERSIONS=$(echo $LAMBDA_VERSIONS_DATA | jq -r '.Versions | map(select(.Version != "$LATEST")) | map(.Version | tonumber)');
LAMBDA_VERSION_LATEST=$(echo $LAMBDA_VERSIONS | jq -r 'sort | .[-1:][0]');
echo "Latest Version: $LAMBDA_VERSION_LATEST";
LAMBDA_VERSIONS_ARR=($(echo $LAMBDA_VERSIONS | jq -r 'join(" ")'));
for version in "${LAMBDA_VERSIONS_ARR[@]}"; do
if (( version < LAMBDA_VERSION_LATEST )); then
echo "Removing old Version: $version";
@johnnybenson
johnnybenson / offset-targetted-inline-anchor.css
Created April 26, 2020 21:21
Offset targeted inline anchor
:target {
&::before {
display: block;
content: ' ';
margin-top: -5vh;
height: 5vh;
visibility: hidden;
pointer-events: none;
}
}
@johnnybenson
johnnybenson / gist:373bc8ae43aee9a5b187c55c68d35631
Created June 4, 2019 15:39 — forked from spudbean/gist:1558257
Look of disapproval and other emoticons
ಠ_ಠ
( ͡° ͜ʖ ͡°)
¯\_(ツ)_/¯
(╯°□°)╯︵ ┻━┻
http://www.fileformat.info/convert/text/upside-down.htm
WRTTN http://wrttn.me/30dbfd/
Unicode Emoticons
@johnnybenson
johnnybenson / routes.rb
Created May 3, 2019 16:40
Simple way to alias Devise gem /login /logout without changing underlying configuration
devise_scope :user do
get '/login' => 'users/sessions#new', :as => 'login'
get '/logout' => 'users/sessions#destroy', :as => 'logout'
end
// Create a function that checks if a given string is a palindrome.
// A palindrome is text that reads the same forwards and backwards, disregarding puncation, spaces, etc.
const testStrings = [
"b",
"aba",
"abc", // FALSE
"abba",
"Race Car",
"Mr. Owl ate my metal worm",
@johnnybenson
johnnybenson / what-forces-layout.md
Created September 12, 2017 15:19 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@johnnybenson
johnnybenson / ascii.php
Created September 5, 2016 18:38 — forked from donatj/ascii.php
Damn Simple PHP Ascii Art Generator
#!/usr/bin/php -q
<?php
if(isset($argv[1]) && strlen($argv[1])) {
$file = $argv[1];
}else{
echo 'Please Specify a File';
exit(1);
}
@johnnybenson
johnnybenson / uri.js
Created September 7, 2012 16:45 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"