Skip to content

Instantly share code, notes, and snippets.

View ManickYoj's full-sized avatar

Nick Francisci ManickYoj

View GitHub Profile
def uninterruptable_operation(iteration)
puts "[INFO #{Time.now}] Start operation, iteration #{iteration}. Part " \
"one: Eg. we might long poll for messages here"
sleep(5)
puts "[INFO #{Time.now}] Operation part two. Eg. we might process " \
"messages here."
sleep(1)
def operation(iteration)
# ... As implementd above
end
# Only runs if the file is the entry point for execution,
# but not if loaded as a library
if $0 == __FILE__
puts "[INFO #{Time.now}] #--- Starting Worker Program ---#"
def operation(iteration)
# ... Implemented As above
end
# Only runs if the file is the entry point for execution,
# but not if loaded as a library
if $0 == __FILE__
puts "[INFO #{Time.now}] #--- Starting Worker Program ---#"
at_exit do
def operation(iteration)
# ... Implemented As above
end
# Only runs if the file is the entry point for execution,
# but not if loaded as a library
if $0 == __FILE__
puts "[INFO #{Time.now}] #--- Starting Worker Program ---#"
iteration = 0
def operation(iteration)
puts "[INFO #{Time.now}] Start operation, iteration #{iteration}. Part " \
"one: Eg. we might long poll for messages here"
sleep(5)
puts "[INFO #{Time.now}] Operation part two. Eg. we might process " \
"messages here."
sleep(1)
@ManickYoj
ManickYoj / at_exit_uninterruptable.rb
Last active April 5, 2022 01:22
A ruby script that, upon interrupt, delays exit until after a method has completed execution
def operation(iteration)
# ... As implemented above
end
# Only runs if the file is the entry point for execution,
# but not if loaded as a library
if $0 == __FILE__
puts "[INFO #{Time.now}] #--- Starting Worker Program ---#"
// app/javascripts/application.js
// This is the entry point for the build script in package.json.
// That is to say if your JS files aren't imported here,
// they won't be bundled.
import "@hotwired/turbo-rails"
import "./controllers"
// app/javascript/controllers/index.js
import { application } from "./application"
import VisibilityController from "./visibility_controller"
application.register("visibility", VisibilityController)
// app/javascript/controllers/visibility_controller.js
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = [ "hideable" ]
showTargets() {
this.hideableTargets.forEach(el => {
el.hidden = false
<div id="options" data-controller="visibility">
<h1>Toggle Visibility</h1>
<button data-action="visibility#showTargets">Show All Elements</button>
<button data-action="visibility#hideTargets">Hide All Elements</button>
<button data-action="visibility#toggleTargets">Toggle Element Visibility</button>
<p data-visibility-target="hideable">The Flamboyent Thing #1<p/>
<p data-visibility-target="hideable" hidden>The Slightly Stealthy Thing #2<p/>
</div>