This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ---#" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ---#" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/controllers/index.js | |
import { application } from "./application" | |
import VisibilityController from "./visibility_controller" | |
application.register("visibility", VisibilityController) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
NewerOlder