Skip to content

Instantly share code, notes, and snippets.

@thorpj
thorpj / popup_controller.js
Last active August 13, 2023 22:00
StimulusJS Controller for popups using tippy.js.
import ApplicationController from './application_controller';
import tippy from 'tippy.js';
import 'tippy.js/dist/tippy.css';
// Inspired by https://chrislabarge.com/posts/stimulus-popup/
// NOTE: ApplicationController must have `this.element[this.identifier] = this;` in the connect() method.
/*
// Manually set content and trigger
// 'data-popup-trigger': :manual is optional. When no content is given, the controller isn't going to show a popup on mouseenter or click
Failed to load secrets.rb
yarn install v1.12.3
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.04s.
I, [2020-06-05T17:52:37.376781 #20893] INFO -- : Writing /home/rails/workshop_tracker/public/assets/manifest-312e30e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js
I, [2020-06-05T17:52:37.377462 #20893] INFO -- : Writing /home/rails/workshop_tracker/public/assets/manifest-312e30e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.js.gz
rails aborted!
NoMethodError: undefined method `+' for nil:NilClass
/home/rails/workshop_tracker/vendor/bundle/ruby/2.5.0/gems/sprockets-4.0.1/lib/sprockets/asset.rb:138:in `etag'
class BookInPartJob < ActiveJob::Base
queue_as :default
def perform(ticket_number, message, all_parts_received, warranty_reference, vendor, title)
ticket = Api::Autotask::Ticket.find_by_ticket(ticket_number)
api_warranty_reference = ticket.warranty_reference.value
if api_warranty_reference.exclude? warranty_reference
ticket.warranty_reference = "#{ticket.warranty_reference.value} #{warranty_reference}".strip
end
if all_parts_received
#!/usr/local/bin/ruby -w
# There doesn't seem to be an easy way to download a gif from giphy.com from the url type
# that people tend to use when posting in forums
# Usage:
# ruby giphy_dl.py <giphy url>
require 'giphy'
require 'open-uri'
// Allows us to use Scanner (which is for user input)
import java.util.*;
// Don't worry about why we need this. HorseTracker is the name of this program,
// which is why we used it here
class HorseTracker
{
public static String[] getHorseData(int horseCount)
horse_names = []
horse_finish_times = []
def register_horse(horse_name, horse_number):
horse = [horse_number, horse_name]
horse_names.append(horse)
print("Registered horse")
def record_race_data(horse_number, finish_time):
horse = [horse_number, finish_time]
@thorpj
thorpj / 0_reuse_code.js
Created February 20, 2017 14:36
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console