Skip to content

Instantly share code, notes, and snippets.

View csaunders's full-sized avatar

Christopher Saunders csaunders

View GitHub Profile
[11:28:41] <csaunders> maybe you can leverage increment/decrement?
[11:29:09] <csaunders> items = Item.where(query)
[11:29:31] <csaunders> value > 0 ? items.increment(value) : items.decrement(value)
[11:29:33] <csaunders> ¯\(°_o)/¯
[11:29:57] <csaunders> also I think my syntax is wrong :/
[11:30:09] <csaunders> but those might have an answer
[11:31:08] <csaunders> keep in mind, increment/decrement don't fire callbacks…
cancelChanges: ->
model = @get('model')
if transaction = model.get('transaction')
transaction.rollback()
else
alert "Could not roll back changes"
@set('isEditing', false)

Text Editor

The software we'll be using for remote programming has plugins for the following text editors:

  • Emacs
  • Sublime Text
  • Vim

Sublime text allows you to use it for free, with a nag screen; otherwise you can use the online text editor that comes with floobits. The onine editor is alright.

@csaunders
csaunders / changelog.md
Created November 4, 2013 15:43
Shopify Theme gem changelog

v0.0.11

  • Locks JSON api version which fixed an issue with downloading large binary files -- Tyler Ball
  • Respect API limits when downloading theme assets from Shopify API -- Chris Saunders
source 'https://rubygems.org'
gem 'shopify_theme'
shops GET /shops(.:format) shops#index => shops_path
POST /shops(.:format) shops#create => shops_path
new_shop GET /shops/new(.:format) shops#new => new_shop_path
edit_shop GET /shops/:id/edit(.:format) shops#edit => edit_shop_path
shop GET /shops/:id(.:format) shops#show => shop_path(shop)
PUT /shops/:id(.:format) shops#update => shop_path(shop)
DELETE /shops/:id(.:format) shops#destroy => shop_path(shop)
require 'openssl'
require 'base64'
class WebhooksController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :verify_webhook, :fetch_shop
def create
case topic
when 'orders/fulfilled'
diff --git a/.gitignore b/.gitignore
index 8b6632c..2a33328 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ rdoc
pkg
doc
.yardoc
+.rbenv-version
diff --git a/Gemfile b/Gemfile
@csaunders
csaunders / simplemath_c.rl
Created January 11, 2014 23:10
Simple Math State Machine
#include <string.h>
#include <stdio.h>
%%{
machine simplemath;
number = digit+;
operator = '+';
main := (digit operator digit) 0 @{ res = 1; };
}%%
module ShopProductSink
module ApiCreatable
extend ActiveSupport::Concern
module ClassMethods
def initialize_from_resource(resource)
attributes = usable_keys.reduce({}) do |result, key|
result[key] = resource.public_send(key) if resource.respond_to?(key)
result
end