Skip to content

Instantly share code, notes, and snippets.

@RobertAudi
RobertAudi / example.rb
Last active March 23, 2020 14:53 — forked from redconfetti/example.rb
Custom Rspec matcher for checking class for constant, with optional class type.
# frozen_string_literal: true
class ExampleClass
PI = 3.14159265359
end
@RobertAudi
RobertAudi / Int+Extenstion.swift
Last active May 2, 2020 12:07 — forked from gbitaudeau/Int+Extenstion.swift
Convert large numbers to smaller format
import Foundation
extension Int {
func abbreviate() -> String {
typealias Abbrevation = (threshold: Double, divisor: Double, suffix: String)
let abbreviations: [Abbrevation] = [
(0, 1, ""),
(1000.0, 1000.0, "K"),
(100_000.0, 1_000_000.0, "M"),
@RobertAudi
RobertAudi / 01-safe-download.rb
Created May 4, 2021 08:06 — forked from janko/01-safe-download.rb
A safe way in Ruby to download a file to disk using open-uri (with/without comments)
require "open-uri"
require "net/http"
Error = Class.new(StandardError)
DOWNLOAD_ERRORS = [
SocketError,
OpenURI::HTTPError,
RuntimeError,
URI::InvalidURIError,