Skip to content

Instantly share code, notes, and snippets.

Prerequirments

Routes:

POST /users/456/verification called by frontend to create verification & redirect to verification process GET /users/456/verification returns status of your verification POST /webhooks/verifications/:id called by 3rd party

Table

Hey, let’s talk about memoization.

I would like to address one of our coding habits. I notice that we have a tendency to overuse memoization. I would like to point out that memoization is a double edge sword and does not always yield expected results.

Here is an example. I pulled it from recent code I saw:

require 'benchmark'
require 'active_support/all'
EDUCATION_DURATION_ESTIMATE = 10.years
// Let's say we have a product that validates emails.
// Person visits our websites gives us a list of emails and we validate that those emails are real.
// Our value is "Great customer experience".
// We have two engineers in our company and they both inline with our values.
// However they disagree on qualities that our code should have.
// Person "A" believes that we should optimize for maintenability.
// Person "B" is sure that we should optimize for change.
// They both send to implement an email validator.
@antonvolkoff
antonvolkoff / shit_grouper.rb
Created February 14, 2020 12:41
Grouping by year
module ShitGrouper
def self.group(array)
array.group_by(&:year)
end
def self.ungroup(hash)
hash.values.flatten
end
end
@antonvolkoff
antonvolkoff / function.js
Last active February 9, 2020 14:26
Serverless hello
console.log("Hello! v4")
@antonvolkoff
antonvolkoff / rule.ts
Created January 19, 2020 14:35
Rules for switchboard
class Rule {
private operations: Array<any>;
constructor() {
this.operations = [];
}
filter(options): Rule {
this.operations.push({ action: 'filter', options });
return this;
@antonvolkoff
antonvolkoff / freeze_class.rb
Created December 15, 2019 15:10
You can freeze classes in ruby
class Point
attr_reader :x, :y
def initialize(x, y)
@x = x
@y = y
freeze
end
def move!(x_offset, y_offset)
@antonvolkoff
antonvolkoff / setup.md
Last active January 16, 2018 12:48 — forked from shashankmehta/setup.md
Setup PHP 5.1 and Composer on OSX via Brew

First install Brew on your MAC

  • Setup Brew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • brew update
  • brew tap homebrew/dupes
  • brew tap homebrew/php
  • Install PHP 7.1.+ brew install php71 --with-postgresql
  • Install mcrypt: brew install mcrypt php71-mcrypt
  • Finally, install composer: brew install composer
0x4737C38880A57d49Cdb7570aAd9D2D41d344F159
@antonvolkoff
antonvolkoff / True Trello Printer
Created November 29, 2016 15:43 — forked from mathiasrw/True Trello Printer
Ever wanted to print your Trello board? Export as JSON and paste it into the code.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>True Trello Printer</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<style>
body{margin:15%;}
.panel-body{