Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View akirchner333's full-sized avatar
🦀
I'm a crabputer

Alexa akirchner333

🦀
I'm a crabputer
View GitHub Profile
@akirchner333
akirchner333 / met.rb
Last active September 26, 2019 21:27
Script for downloading all the Met's swords
require 'net/http'
require 'open-uri'
require 'json'
def get_page(url)
uri = URI(url)
search = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
request = Net::HTTP::Get.new uri
response = http.request request
response.body
@akirchner333
akirchner333 / lisp.exs
Created July 12, 2019 15:01
Lisp Parser
defmodule Lisp do
@doc "Removes the wrapping parenthesis and breaks the expression up into individual arguments and sub-expressions, then parses each of those"
def parse("(" <> lisp) do
remove_parens = String.slice(lisp, 0..-2)
Regex.scan(~r/(?:\(.*\)|[^\s]+)/, remove_parens)
|> List.flatten
|> Enum.map(&parse/1)
end
@doc "parses individual operators and arguments. Currently all it does is convert numbers"