This file contains hidden or 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
| bundle add io-watch | |
| bundle exec io-watch app config -- bundle exec falcon serve --bind http://localhost:3000 --count 1 |
This file contains hidden or 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
| # frozen_string_literal: true | |
| require 'rack' | |
| require 'rack/session/cookie' | |
| module Sourced | |
| module UI | |
| # A minimal Rack-compatible router with a Sinatra-style DSL and | |
| # trie-based dispatch. | |
| # |
This file contains hidden or 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
| module Energy | |
| class Comparison | |
| module LoadProfileGapFiller | |
| module_function | |
| # Public API | |
| def fill_gaps(annual_coefficients:, customer_profile:) | |
| # 1. Compute observed totals | |
| observed_total = customer_profile.values.sum | |
| raise "Customer profile is empty" if observed_total.zero? |
This file contains hidden or 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
| /* | |
| The MIT License (MIT) | |
| Copyright (c) 2014 Ismael Celis | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or 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
| # The main worflow | |
| class MarksFlow < Sourced::Actor | |
| include Sourced::CommandMethods | |
| state do |id| | |
| { id:, status: :new, tasks: {} } | |
| end | |
| command :start_step1 do |state, cmd| | |
| raise "invalid transition" unless state[:status] == :new |
This file contains hidden or 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
| require 'exif' | |
| require 'geocoder' | |
| require 'time' | |
| def coord(deg, min, sec, _ref) | |
| (deg + (min / 60) + (sec / 3600)).to_f # * (ref == "S" || ref == "W") ? -1 : 1 | |
| # %(#{deg.to_i}°#{min.to_i}'#{sec.to_f}"#{ref}) | |
| end | |
| def coords(gos) |
This file contains hidden or 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
| # frozen_string_literal: true | |
| source "https://rubygems.org" | |
| gem 'puma' | |
| gem 'datastar' |
This file contains hidden or 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
| // Copyright (c) 2017 Ismael Celis | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is | |
| // furnished to do so, subject to the following conditions: | |
| // The above copyright notice and this permission notice shall be included in all |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>JSON form</title> | |
| <script> | |
| function jsonForm(form) { | |
| form.addEventListener('submit', function(event) { | |
| event.preventDefault(); | |
| var data = {}; |
This file contains hidden or 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
| require 'thread' | |
| def work(queue, &block) | |
| Thread.new do | |
| block.call(queue) | |
| queue << :done | |
| rescue StandardError => e | |
| queue << e | |
| end | |
| end |
NewerOlder