Skip to content

Instantly share code, notes, and snippets.

View jubishop's full-sized avatar
🎼
Making a podcast app.

Justin Bishop jubishop

🎼
Making a podcast app.
View GitHub Profile
require:
- rubocop-performance
AllCops:
EnabledByDefault: true
Exclude:
- '**/test.rb'
TargetRubyVersion: 3.0
Bundler/GemComment:
import SwiftUI
func EnumList<T: Identifiable, V: View>(_ ary: Array<T>,
block:@escaping (Int, T) -> V) ->
List<Never, ForEach<Array<(offset: Int, element: T)>, T.ID, HStack<V>>> {
return List(Array(ary.enumerated()), id: \.element.id) { idx, item in
block(idx, item)
}
}
@jubishop
jubishop / Erb.rb
Created September 2, 2020 02:06
Erb on Jekyll
require 'erb'
require 'recursive-open-struct'
module EmbeddedRuby
def render_liquid(content, payload, info, path = nil)
liquid = super(content, payload, info, path)
site = RecursiveOpenStruct.new(payload.site.to_h,
recurse_over_arrays: true)
page = RecursiveOpenStruct.new(payload.page,
require 'down'
src = File.open("about-me.html", "r") { |file| file.read }
count = 0
src.gsub!(/(src|data-flickity-lazyload)="(\S+)"/) { |match|
extension = if ($2.include? 'jpg' or $2.include? 'jpeg')
"jpg"
elsif ($2.include? 'png')
"png"
@jubishop
jubishop / css-grid-periodic-table.markdown
Created July 10, 2020 23:24
CSS Grid: Periodic Table

CSS Grid: Periodic Table

My very first CSS Grid Experiment!

So I can't actually group them together in a cluster like an actual periodic table or it wouldn't make sense or would look too forced 😔

One of my fondest memories of 2018 is when I found the resolve to deactivate Facebook, only to have my team lead tell me I'm in charge of Facebook ads a week later. No escape from Zuckerberg!

A Pen by Olivia Ng on CodePen.

### Added by Zplugin's installer
source ~/.zplugin/bin/zplugin.zsh
autoload -Uz _zplugin
(( ${+_comps} )) && _comps[zplugin]=_zplugin
### End of Zplugin installer's chunk
##### BEGIN Zplugin stuff #####
### needs: exa, fzy, lua, python3
# autosuggestions, trigger precmd hook upon load
const tracker = {};
const NEIGHBOR_ABOVE = "above";
const NEIGHBOR_BELOW = "below";
function updateConnected(current, value, direction) {
const neighbor = getNeighbor(current, direction);
if (neighbor !== false) {
tracker[neighbor] = value;
updateConnected(neighbor, value, direction);
}
function longestConsecutive(nums) {
let longestConsecutiveLength = 0,
longestKey; // FOR TESTING: This stores the key of a number in the longest sequence, used to build the list for display
const tracker = {};
const NEIGHBOR_ABOVE = "above";
const NEIGHBOR_BELOW = "below";
for (let i = 0; i < nums.length; i++) {
let currentValue = nums[i],
require_relative 'jubilib/binary_tree'
def is_valid_bst(node, min = -Float::INFINITY, max = Float::INFINITY)
return true if node.nil?
return false unless node.val > min and node.val < max
return (is_valid_bst(node.left, min, [max, node.val].min) and
is_valid_bst(node.right, [min, node.val].max, max))
end
require_relative 'jubilib/binary_tree'
def validate_and_return_minmax(node)
left_valid, left_min, left_max = node.left.nil? ?
[true, node.val, node.val] :
validate_and_return_minmax(node.left)
return [false, 0, 0] unless left_valid
right_valid, right_min, right_max = node.right.nil? ?
[true, node.val, node.val] :
validate_and_return_minmax(node.right)