Skip to content

Instantly share code, notes, and snippets.

View wasabigeek's full-sized avatar
💭
imposter syndrome

Nicholas Koh wasabigeek

💭
imposter syndrome
View GitHub Profile
@wasabigeek
wasabigeek / a_and_b.html
Last active October 12, 2017 04:26
An Incremental Approach to React with Django: React-Router - Before Refactoring
<!-- /templates/app/a.html -->
<div id="reactComponent"></div>
<!-- /templates/app/b.html -->
<div id="reactComponent"></div>
@wasabigeek
wasabigeek / app.html
Last active October 12, 2017 04:22
An Incremental Approach to React with Django: React-Router - After Refactor
<!-- /templates/app/app.html -->
<!-- replaces /templates/app/a.html and templates/app/b.html -->
<div id="reactComponent"></div>
def validate_symbol_and_lookup(symbol):
if not symbol:
return apology("must provide symbol", 400)
stock = lookup(symbol)
if not stock:
return apology("invalid stock symbol", 400)
return stock
symbol = request.form.get("symbol")
# apology() doesn't get rendered if symbol is invalid
# run the Windows Postgres service via shell, so it only starts when you boot WSL
net.exe start postgresql-x64-9.6
[
{
"i": "460",
"n": "Abomasnow"
},
{
"i": "63",
"n": "Abra"
},
{
@wasabigeek
wasabigeek / create_expenses_table.sql
Created December 31, 2020 14:39
Window Function Calls in Postgres, Visualised (Example Data)
create table expenses (
id serial primary key,
description varchar,
category varchar(255),
created_at date,
cost decimal(2));
insert into expenses
(description, category, created_at, cost)
values
@wasabigeek
wasabigeek / react.js
Last active January 3, 2021 09:50
Stimulus VS React
import React, { useState } from "react";
const SubscribeButton = ({ initialSubscribed = false }) => {
const [isSubscribed, setIsSubscribed] = useState(initialSubscribed);
const [isHovered, setIsHovered] = useState(false);
const handleClick = () => {
if (isSubscribed) {
// DELETE destroy
// imagine this is in .then()
@wasabigeek
wasabigeek / mocha_patch.rb
Created January 6, 2022 15:38
Mocha kwarg matching patch
module Mocha
class Mock
# change to *args, **kwargs
def method_missing(symbol, *args, **kwargs, &block)
check_expiry
check_responder_responds_to(symbol)
# change to *arg, **kwargs
invocation = Invocation.new(self, symbol, *args, **kwargs, &block)
if (matching_expectation_allowing_invocation = all_expectations.match_allowing_invocation(invocation))
matching_expectation_allowing_invocation.invoke(invocation)
@wasabigeek
wasabigeek / parnas_afterword.md
Created March 5, 2022 08:31
Parts of "On the Criteria to be used in Decomposing Systems" that were not covered in the Blog Post

Blog Post: https://www.wasabigeek.com/blog/what-does-a-1972-paper-have-to-do-with-the-single-responsibility-principle/

The bits of the paper I deliberately left out:

  • Comparisons:
    • correctness and comprehensibility were deemed similar for both Modularizations, so I left it out.
    • independent development: Modularization 2 was deemed better, as in Modularization 1 the devs building each module would have to agree upon and develop the shared input storage.
  • Efficiency:
    • I had trouble understanding this bit, think it had more relevance to the programming systems of the time: "(Modularization 2), if implemented with the conventional assumption that a module consists of one or more subroutines, will be less efficient in most cases."
  • An anecdotal example of building a translator was given in further support of "Information Hiding".