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
{ | |
"variables": [], | |
"info": { | |
"name": "WaybackArchiver", | |
"_postman_id": "e073f167-ab7a-2b60-024b-0e6d405cb45e", | |
"description": "API for api.waybackarchiver.com.", | |
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" | |
}, | |
"item": [ | |
{ |
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
const articles = { | |
data: [{ | |
id: 3, | |
type: 'articles' | |
attributes: { | |
title: 'LMA-kort', | |
slug: 'lma-kort', | |
body_html: '<p>LMA-kort är ett bevis på...</p>', | |
language_id: 192, | |
traits: ['bank_account', 'skill_ids', 'resume', 'personal_letter'], // zero to many |
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
class KeyStruct < Struct | |
def initialize(**keyword_args) | |
keyword_args.each do |key, value| | |
if members.include?(key) | |
self[key] = value | |
else | |
raise ArgumentError, "Unknown key struct member: #{key}" | |
end | |
end | |
end |
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
# Returns an event emitter class with given event names | |
# @return [Object] the event emitter class | |
# @param [String, Symbol] event_names | |
# @example Simple event emitter | |
# class CrawlEvent < EventEmitter(:found_url, :page_title) | |
# end | |
# | |
# event = CrawlEvent.new do |on| | |
# on.every_found_url { {|url| puts "Found URL: #{url}" } | |
# on.every_page_title { {|title| puts "Page title: #{title}" } |
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
require 'open-uri' | |
require 'wayback_archiver' # requires `gem install wayback_archiver` | |
sitemap_urls = ARGV | |
sitemap_urls.map do |url| | |
sitemap_xml = open(url).read | |
sitemap = WaybackArchiver::Sitemap.new(sitemap_xml) | |
sitemap.urls | |
end.flat_map { |url| puts url } |
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
SUBDOMAIN_MATCHER = /\A([a-z][a-z\d]*(-[a-z\d]+)*|xn--[\-a-z\d]+)\z/i | |
[ | |
['as a', nil], | |
['a-a', 0], | |
['todd2', 0], | |
['todd-2', 0], | |
['todd-admin', 0], | |
['_todd-admin', nil], | |
['-todd-admin', nil], |
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
'.source.ruby': | |
'Insert Ruby optparser': | |
'prefix': 'optparse' | |
'body': | |
''' | |
require 'optparse' | |
options = {} |
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
'.source.ruby': | |
'Insert gem configuration block': | |
'prefix': 'gconfig' | |
'body': | |
''' | |
def self.configuration | |
@configuration ||= Configuration.new | |
end | |
def self.config |
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
'.source.ruby': | |
'def method_missing .. end': | |
'prefix': 'defmm' | |
'body': | |
''' | |
def method_missing(method_name, *arguments, &block) | |
if ${1}.respond_to?(method_name) | |
${1}.public_send(method_name, *arguments, &block) | |
else | |
super |
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
# USAGE | |
# In any local GitHub repository run | |
# $ github_open | |
github_open() { | |
local remotename="${@:-origin}" | |
local remote="$(git remote -v | awk '/^'"$remotename"'.*\(push\)$/ {print $2}')" | |
[[ "$remote" ]] || return | |
local user_repo="$(echo "$remote" | perl -pe 's/.*://;s/\.git$//')" | |
open "https://github.com/$user_repo" |