Skip to content

Instantly share code, notes, and snippets.

View timmatheson's full-sized avatar
💭
Seeking new roles

Tim Matheson timmatheson

💭
Seeking new roles
View GitHub Profile
{
name : 'Image',
field: 'image',
id: 'image',
width: 30,
sortable: true,
formatter: imageFormatter = function( row, cell, value, columnDef, dataContext ){
if(dataContext['image_url'] == null){
return "";
}else{
{
editable: true,
enableAddRow: true,
enableCellNavigation: true,
asyncEditorLoading: true,
forceFitColumns: false,
topPanelHeight: 25
}
@timmatheson
timmatheson / email.rb
Created July 26, 2012 21:09
email verification code
require 'net/telnet'
class Email
def initialize(address)
@address = address
end
def verify
connect do
cmd("HELO")
@timmatheson
timmatheson / template.liquid.html
Created July 30, 2012 18:46
OrderCup Liquid Template Example
<link href='https://fonts.googleapis.com/css?family=Unna' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Squada+One' rel='stylesheet' type='text/css'>
<style type="text/css" media="print,screen">
ul{ list-style: none; }
ul.address{ float: left; width: 40%; }
h1{ font-family: 'Squada One', cursive; }
body{ font-family: 'Unna'; font-style: normal; }
#page{
padding: 0.5em 1em;
@timmatheson
timmatheson / missing_sequence.rb
Created August 7, 2012 19:58
Missing Sequence - detects the missing order numbers
require 'rubygems'
require 'benchmark'
class Array
def missing_sequence
prefix = self[0].split("-")[0]
mapped = self.map{|v| v.split("-")[-1].to_i }.sort
min = mapped[0]
max = mapped[-1]
((min..max).to_a - mapped).map{ |v| "#{prefix}-#{v}" }
class Study
def self.protocol_nickname
@@protocol_nickname ||= self.first.try(:protocol_nickname) || 'Untitled'
end
end
@timmatheson
timmatheson / metarific.liquid.erb
Created August 17, 2012 22:42
The Metarific Shopify Meta Tag Snippet
<link rel="canonical" href="{{ canonical_url }}" />
{% assign maxmeta = 155 %}
{% if template contains 'product' %}
{% assign mf = product.metafields.metarific %}
{% unless mf == empty %}
{% for mf in product.metafields.metarific %}
{% capture key %}{{ mf | first }}{% endcapture %}
{% if key == 'title' %}
<title>{{mf | last}}</title>
<meta name="title" content="{{mf | last}}" />
@timmatheson
timmatheson / theme.liquid.rb
Created August 19, 2012 00:29
Shopify Metarific include tag
{% include 'metarific' %}
require 'rubygems'
require 'aasm'
class User < ActiveRecord::Base
include AASM
aasm_state :new, :initial => true
aasm_state :advanced
aasm_state :expert
# old
def self.load_or_initialize_tz(timezone_name)
first(:conditions => ["RIGHT(tz_name, ?) = ? OR tz_name = ?", timezone_name.size, timezone_name, timezone_name]) || self.first || self.new(tz_name: timezone_name)
end
# new
def self.load_or_initialize_tz( timezone_name )
first(:conditions => {:tz_name => timezone_name }) || first || new(:tz_name => timezone_name)
end