Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Vibing

Justin Bishop jubishop

💭
Vibing
View GitHub Profile
View run_long_process_in_background.rb
require 'sinatra'
get '/long_process' do
child_pid = Process.fork do
# hard work is done here...
sleep 10
Process.exit
end
View gist:7bdabe1f6bd74687a331ecb3d1472743
require:
- rubocop-performance
AllCops:
EnabledByDefault: true
Exclude:
- '**/test.rb'
TargetRubyVersion: 3.0
Bundler/GemComment:
View Enum.swift
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 Sep 2, 2020
Erb on Jekyll
View Erb.rb
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,
View convert_images.rb
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"
View css-grid-periodic-table.markdown

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.

View jubishop.zshrc
### 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
View erik.js
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);
}
View erik.js
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],
View two.rb
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