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
sv_lang = Language.find_by(lang_code: :sv) | |
en_lang = Language.find_by(lang_code: :en) | |
ar_lang = Language.find_by(lang_code: :ar) | |
root_industry = nil | |
result = csv.map do |row| | |
sv, en, ar = row | |
is_root_industry = false | |
if sv.start_with?('__') |
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
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
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
const CrossOriginLocalStorage = function(currentWindow, iframe, allowedOrigins, onMessage) { | |
this.allowedOrigins = allowedOrigins; | |
let childWindow; | |
// some browser (don't remember which one) throw exception when you try to access | |
// contentWindow for the first time, it works when you do that second time | |
try { | |
childWindow = iframe.contentWindow; | |
} catch(e) { | |
childWindow = iframe.contentWindow; |
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 |