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
| #!/usr/bin/env ruby | |
| require 'sinatra' | |
| require 'oj' | |
| Oj.default_options = { | |
| mode: :compat | |
| } | |
| post '/client/v4/zones/:zone_id/purge_cache' do |
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 'nokogiri' | |
| require 'faraday' | |
| def urls_valid?(file_path) | |
| doc = Nokogiri::XML(File.read(file_path)) | |
| urls = doc.css('loc').map { |loc| loc.children.first.text } | |
| urls.all? do |url| | |
| Faraday.head(url).status == 200 | |
| end |
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
| chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a | |
| 40.times.map { chars.sample }.join |
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 Enumerable | |
| def my_each_slice(num, &block) | |
| offset = 0 | |
| while offset < count | |
| yield self.to_a[offset, num] | |
| offset += num | |
| end | |
| end | |
| end |
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
| (defn find-tag [tag nodes] | |
| (->> nodes | |
| (filter #(= (:tag %) tag)) | |
| first)) | |
| (defn tag-content [tag nodes] | |
| (-> (find-tag tag nodes) | |
| :content | |
| first)) |
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
| #!/usr/bin/env ruby | |
| db_name = ARGV.first | |
| raise ArgumentError, 'No database name given' if db_name.nil? | |
| require 'db_schema' | |
| require 'db_schema/reader/postgres' | |
| db = Sequel.connect(adapter: 'postgres', database: db_name) do |db| | |
| db.extension :pg_enum |
OlderNewer