Skip to content

Instantly share code, notes, and snippets.

View bradstewart's full-sized avatar

Brad Stewart bradstewart

View GitHub Profile
@bradstewart
bradstewart / machine.js
Created April 28, 2021 18:34
Generated by XState Viz: https://xstate.js.org/viz
const operationMachine = Machine({
id: 'op',
initial: 'ready',
context: {
loadPoolId: '',
blockTime: '',
exampleData: 0,
},

Keybase proof

I hereby claim:

  • I am bradstewart on github.
  • I am bstew (https://keybase.io/bstew) on keybase.
  • I have a public key ASBoPsS_AFHkozCPRXgtCNgwFTCL48CwCdhEwnCsDoi5Rgo To claim this, I am signing this object:
{
  "body": {
    "key": {
# initializers/twilio.rb
require 'twilio-ruby'
Twilio.configure do |config|
config.account_sid = account_sid
config.auth_token = auth_token
end
@bradstewart
bradstewart / gist:4c824b0c41ba7f271eac
Created February 6, 2015 00:10
Add attributes to instance
def add_attributes(model, hash)
hash.each do |name, value|
setter_method = "#{name}=".to_sym
model.define_singleton_method(name.to_sym)
model.define_singleton_method(setter_method)
model.send(setter_method, value)
end
end
##
# Abstract class designed to decorate ActiveRecord models with methods for
# acting on instances which are stored in both local and remote databases.
#
# @note Decorator instances should be initialized with an instance of the ActiveRecord
# model to be acted on. This instance is available within decorators as {#object}.
#
# @abstract Subclass and override {#create}, {#update}, {#destroy} to implement.
#
class AbstractDecorator < SimpleDelegator
@bradstewart
bradstewart / html
Last active August 29, 2015 13:59
Select2view
<select data-view="Select2NextTaskView" data-view-resource="task" data-bind="action.next_task_id">
<option></option>
<option data-foreach-task="options" data-bind-value="task.id" data-bind="task.title"></option>
</select>
@bradstewart
bradstewart / feed_activity.coffee
Created April 14, 2014 18:07
Batman.js View from Model accessor
# This started as "why can't data-partial also take a keypath," but I actually
# like having a Batman.View which can attach jQuery plugins and stuff for each
# activity that's added.
class App.FeedActivity extends Batman.Model
# ...
@accessor 'show', ->
@layout('show')