Skip to content

Instantly share code, notes, and snippets.

Tony Schneider tonywok

Block or report user

Report or block tonywok

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Keybase proof

I hereby claim:

  • I am tonywok on github.
  • I am tonywok ( on keybase.
  • I have a public key ASBcoIdY2d_xFoFbXJyD0jt9pJCvZj3e2lIltd14lQcLKQo

To claim this, I am signing this object:

View dag_spike.rb
require "tsort"
require 'bundler/inline'
gemfile do
source ''
gem 'pry'
gem 'pry-byebug'
tonywok / rpn.rb
Created Oct 13, 2018
Toy RPN Expression Evaluator
View rpn.rb
require "forwardable"
class Operator
# TODO: probably raise if stuff isn't implemented
# TODO: probable register implementations
class Operand
# TODO: probably raise if stuff isn't implemented
# TODO: probable register implementations
View acronym.exs
module Acronym
def abbreviate(string) do
|> String.codepoints
|> Enum.with_index
|> Enum.reduce("", fn({letter, idx}, acronym) ->
cond do
String.upcase(letter) == letter and String.downcase(letter) != letter ->
acronym <> letter, idx-1) == " " ->
tonywok /
Last active Sep 25, 2015
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.


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 / gist:d4395f242e8b29f3f126
Last active Aug 29, 2015
More Flexible User Models
View gist:d4395f242e8b29f3f126

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 / gist:a954531b5395d52ead6f
Created Jun 23, 2014
Some helpers for dealing with missing data and handling defaults w/o making a bunch of nested if/else
View gist:a954531b5395d52ead6f
Neo.UI.Mixin.Maybe =
maybeAnchored: (bool, url, dom...) ->
if bool
React.DOM.a(href: url, dom)
maybeDisplayed: (bool, dom...) ->
if bool then dom else null
View ember data jsbin
<!DOCTYPE html>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="">
<script type="text/x-handlebars">
tonywok / active_model_serializer.rb
Created Apr 2, 2014
Hacking polymorphic has_many into AMS. (e.g has_many :tasks, embed: :ids, include: true, polymorphic: true)
View active_model_serializer.rb
module ActiveModel
class Serializer
module Associations
class HasMany
def key_with_polymorphism
return @name if !option(:key) && option(:polymorphic)
alias_method_chain :key, :polymorphism
View jsbin.fuxijasi.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>
<script src=""></script>
You can’t perform that action at this time.