Skip to content

Instantly share code, notes, and snippets.

@tonywok
tonywok / sorcery-cards-2022-03-30.csv
Created March 30, 2022 21:32
Incomplete Sorcery TCG cards
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
name,card_type,rarity,image_url,initial_life,rules_box,type_line,mana_cost,element,earth_threshold,fire_threshold,water_threshold,wind_threshold,power,artist,set_identifier,flavor_text
Unland Eel,minion,ordinary,"https://static.wixstatic.com/media/965b5c_e7cafce2a0b74891a23c78cadf248c38~mv2.png/v1/fill/w_846,h_1182,al_c,usm_0.66_1.00_0.01,enc_auto/965b5c_e7cafce2a0b74891a23c78cadf248c38~mv2.png",,"**Submerge**, **Waterbound**
This Eel gains +2 power when attacking as it surfaces.",An Ordinary Beast of the deadly depths,2,water,,,1,,2,Francesca Baerald,1,
Unravel,magic,ordinary,"https://static.wixstatic.com/media/965b5c_e9547880aa9e4807b5453683d002fe67~mv2.png/v1/fill/w_846,h_1182,al_c,usm_0.66_1.00_0.01,enc_auto/965b5c_e9547880aa9e4807b5453683d002fe67~mv2.png",,Destroy target Relic or Undead minion.,Ordinary Magic of rot and rebirth,1,water,,,1,,,Severine Pineaux,1,"For life to rise, the dead must crumble."
Tide Naiads,minion,exceptional,"https://static.wixstatic.com/media/965b5c_796dab1d1f9b4eedb938817ee887d
@tonywok
tonywok / postgressql_db_adapter.rb
Last active May 27, 2021 10:14
PostgresSQL Async DB Adapter
gem "db"
gem "db-postgres"
gem "thread-local"
require "db"
require "db/postgres"
require "active_record/connection_adapters/postgresql_adapter"
module ActiveRecord
# NOTE: This is the active record connection entry point.
# This method is called internally based on the adapter specified in database.yml
@tonywok
tonywok / first_class_command_notes.rb
Last active January 19, 2021 10:17
First Class Commands Ruby Notes
# https://raganwald.com/2016/01/19/command-pattern.html
class State
attr_reader :history, :future
attr_accessor :text
def initialize(text)
@history = []
@future = []
@text = text

Keybase proof

I hereby claim:

  • I am tonywok on github.
  • I am tonywok (https://keybase.io/tonywok) on keybase.
  • I have a public key ASBcoIdY2d_xFoFbXJyD0jt9pJCvZj3e2lIltd14lQcLKQo

To claim this, I am signing this object:

@tonywok
tonywok / dag_spike.rb
Created February 13, 2019 13:55
dag-spike
require "tsort"
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'pry'
gem 'pry-byebug'
end
@tonywok
tonywok / rpn.rb
Created October 13, 2018 17:33
Toy RPN Expression Evaluator
require "forwardable"
class Operator
# TODO: probably raise if stuff isn't implemented
# TODO: probable register implementations
end
class Operand
# TODO: probably raise if stuff isn't implemented
# TODO: probable register implementations
@tonywok
tonywok / acronym.exs
Created April 7, 2017 17:41
acronym.exs
module Acronym
def abbreviate(string) do
string
|> String.codepoints
|> Enum.with_index
|> Enum.reduce("", fn({letter, idx}, acronym) ->
cond do
String.upcase(letter) == letter and String.downcase(letter) != letter ->
acronym <> letter
String.at(string, idx-1) == " " ->
@tonywok
tonywok / stolen-laptop.md
Last active October 21, 2021 06:35
Preparing for your laptop to be stolen

Preparing for your Laptop to be stolen by some Asshole

Note, at the time of writing this, I use a mac. Adjust to your preference.

Assumptions

If you're reading this and haven't done these things, and your laptop is still in your possession. Stop everything and do them now.

  1. You have an encrypted hard drive (e.g FileVault)
@tonywok
tonywok / gist:d4395f242e8b29f3f126
Last active August 29, 2015 14:13
More Flexible User Models

More Flexible Users

Applications are built for users. We give them distinguishing properties, connect them to other entities, respond to their actions, and make various decisions based on any combination of those things.

In rails, it's almost guaranteed that sitting inside of app/models/ is a class called User. I'm sure you're intimately familiar with this class. In fact, I suspect that if you were to hack together a heat-map representing your code editor, user.rb would probably be molten.

The Setup

Taking this into consideration, how would you describe the responsibility of your User model? I've noticed a few trends while working in rails:

@tonywok
tonywok / gist:a954531b5395d52ead6f
Created June 23, 2014 22:12
Some helpers for dealing with missing data and handling defaults w/o making a bunch of nested if/else
Neo.UI.Mixin.Maybe =
maybeAnchored: (bool, url, dom...) ->
if bool
React.DOM.a(href: url, dom)
else
dom
maybeDisplayed: (bool, dom...) ->
if bool then dom else null