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
| import express from 'express' | |
| import fs from 'fs' | |
| import http from 'http' | |
| import u from 'url' | |
| import path from 'path' | |
| const downloadRouter = express.Router() | |
| let downloadedFiles = {} |
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
| import { load } from 'cheerio' | |
| import got from 'got' | |
| import url from 'url' | |
| import express from 'express' | |
| import http from 'http' | |
| import 'express-async-errors' | |
| const app = express() | |
| const validationError = (message) => { |
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
| # game has two players who take turns placing either an X or an O on the board. | |
| # game's solved if either the grid fills up or a player wins. | |
| # a player wins if they're able to align their character (X or O) along a vertical, | |
| # horizontal, or diagonal set of cells. | |
| class Player | |
| attr_accessor :character | |
| attr_reader :name | |
| def initialize(name) |
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
| def bubble_sort(array) | |
| loop do | |
| swapped = false | |
| for i in (1...array.length) | |
| if array[i-1] > array[i] | |
| array[i-1], array[i] = array[i], array[i-1] | |
| swapped = true | |
| end | |
| end | |
| break unless swapped |
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
| def substrings(word, dictionary) | |
| dictionary.reduce(Hash.new(0)) do |substr_count, substr| | |
| idx = 0 | |
| while idx < word.length | |
| if word[idx, substr.length] == substr | |
| substr_count[substr] += 1 | |
| idx += substr.length | |
| else | |
| idx += 1 | |
| 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
| def is_upcase?(string) | |
| string.upcase == string | |
| end | |
| def caesar_cipher(string, key) | |
| upper = "A".ord | |
| lower = "a".ord | |
| cipher_arr = string.chars.map do |c| | |
| if "a".upto("z").include?(c.downcase) |