Skip to content

Instantly share code, notes, and snippets.

View blaix's full-sized avatar

Justin Blake blaix

View GitHub Profile
@JSerZANP
JSerZANP / ContentView.swift
Created March 4, 2021 14:01
communication between native(swiftUI) and wkwebview
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
class Coordinator: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
var webView: WKWebView?
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.webView = webView
}
module Debug.Extra exposing (viewModel)
import Html exposing (Html, p, pre, text)
import Html.Attributes exposing (style)
quote =
"\""
@evancz
evancz / data-interchange.md
Last active December 31, 2024 01:04
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@blaix
blaix / adventure.md
Last active August 12, 2017 21:06
Adventure

Adventure

An RPG for our entire family.

Requirements

  • Use weapons like swords and bows (C), but without hurting or killing (N)
  • Gameplay that works for both young (3) and old (10+) kids
  • Just enough structure to avoid chaos while still focusing on having fun
@philngo
philngo / ccss.csv
Last active March 24, 2025 18:23
Common Core State Standards CSV
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 8 columns, instead of 7 in line 7.
id,content_type,category_id,category_name,grade_id,grade_name,item,description
CCSS.ELA-LITERACY.L.K.1,ELA-LITERACY,L,Language,K,Kindergarten,1,Demonstrate command of the conventions of standard English grammar and usage when writing or speaking.
CCSS.ELA-LITERACY.L.K.1.a,ELA-LITERACY,L,Language,K,Kindergarten,1a,Print many upper- and lowercase letters.
CCSS.ELA-LITERACY.L.K.1.b,ELA-LITERACY,L,Language,K,Kindergarten,1b,Use frequently occurring nouns and verbs.
CCSS.ELA-LITERACY.L.K.1.c,ELA-LITERACY,L,Language,K,Kindergarten,1c,"Form regular plural nouns orally by adding /s/ or /es/ (e.g., dog, dogs; wish, wishes)."
CCSS.ELA-LITERACY.L.K.1.d,ELA-LITERACY,L,Language,K,Kindergarten,1d,"Understand and use question words (interrogatives) (e.g., who, what, where, when, why, how)."
CCSS.ELA-LITERACY.L.K.1.e,ELA-LITERACY,L,Language,K,Kindergarten,1e,"Use the most frequently occurring prepositions (e.g., to, from, in, out, on, off, for, of, by, with)."
CCSS.ELA-LITERACY.L.K.1.f,ELA-LITERACY,L,Language,K,Kindergarten,

Things that programmers don't know but should

(A book that I might eventually write!)

Gary Bernhardt

I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.

#!/bin/bash
set -e
echo "-----------------------------------------------------"
echo "Installing the essentials..."
echo "-----------------------------------------------------"
sudo apt-get update
sudo apt-get -y upgrade
@blaix
blaix / mock-with-arg-verification.py
Created March 30, 2012 23:25
Mocking new instance of class and verifying the arguments in python with flexmock
# Mock new instances of a class (verify that it's initialized with specific arguments)
# First argument to __new__ is the class, so pass `object` because we don't care about that part
flexmock(MyClass).should_receive('__new__').once.with_args(object, 'arg1', 'arg2').and_return(fake_object)
MyClass('wrong', 'arguments') # => MethodSignatureError
MyClass('arg1', 'arg2') # => <fake_object>
@blaix
blaix / defaults-10.7.sh
Created September 10, 2011 13:13
Sane OS X 10.7 Settings
# Enable tabbing to everything
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# 2D Dock
defaults write com.apple.dock no-glass -bool true
# Always expand save dialog
defaults write -g NSNavPanelExpandedStateForSaveMode -bool true
# Don't hide ~/Library folder
@blaix
blaix / struct-play.rb
Created September 3, 2011 13:34
Struct with an OpenStruct-style initializer
class Struct
def self.create(params = {})
self.new.tap do |obj|
params.each do |key, val|
obj.send("#{key}=", val)
end
end
end
end