This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Redcar | |
class Sparkup | |
def self.plugin_dir | |
File.join(File.dirname(__FILE__), "..") | |
end | |
attr_accessor :indent_spaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you have an xml representation of a data entity, and need to convert to CSV, this script works pretty well. | |
# Specify the file name of an xml file, and the node name of the object. So if you have an XML file of <Person> objects that has all the fields in child elements. | |
# Specify the Person node, and it will iterate through to create a csv. Each person will be a separate row. | |
require 'rubygems' | |
require 'nokogiri' | |
puts 'type xml file name' | |
xml_name = gets.chomp | |
f = File.open(xml_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mathn' | |
require 'csv' | |
def to_rad(angle) | |
angle/180 * Math::PI | |
end | |
def get_distance(from, to) | |
earth_radius = 6371 | |
dLat = to_rad(to.first - from.first) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/tmp/temp_textmate.J8yW2j:139:in /bin/bash: -c: line 0: unexpected EOF while looking for matching `'' | |
/bin/bash: -c: line 1: syntax error: unexpected end of fileto_a' for "sdfd":String (NoMethodError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mathn' | |
require 'csv' | |
def to_rad(angle) | |
angle/180 * Math::PI | |
end | |
def get_distance(from, to) | |
earth_radius = 6371 | |
dLat = to_rad(to.first - from.first) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Note = Backbone.Model.extend({}) | |
NoteView = Backbone.View.extend({ | |
el: null, | |
initialize: -> | |
this.model.view = this | |
$('.view').append("<div class=\"note\" id=\"note_#{this.model.get('id')}\"><a>X</a><p>#{this.model.get('body')}</p><cite>#{this.model.get('author')}</cite></div>") | |
this.el = $("#note_#{this.model.get('id')}") | |
self = this | |
this.el.children('a').click -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Wrapper | |
def self.wrap(string, column_to_wrap) | |
recursive_wrap(string.reverse.scan(/\S+\s?/), column_to_wrap).reverse | |
end | |
def self.recursive_wrap(array, column) | |
head = array[0] | |
if head.scan(/.{1,#{column}}/).length > 1 | |
head = head.strip.reverse.scan(/.{1,#{column}}/).collect{ |c| c.reverse }.reverse.join("\n") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CharityProductDeleteJob < Struct.new(:charity_id, :shop_id) | |
def perform | |
charity = Charity.find(charity_id) | |
shop = Shop.find(shop_id) | |
ShopifyAPI::Base.site = shop.api_url | |
products = ShopifyAPI::Product.find(:all, params: { handle: "#{charity.handle}-charity" }) | |
unless products.blank? | |
Rails.logger.debug "Destroy product" | |
products.each { |p| p.destroy } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aaronmcleod@MacBook-Pro $ rvm ruby-1.9.2-p290 | |
aaronmcleod@MacBook-Pro $ bundle exec rspec spec | |
................................................*...... | |
Pending: | |
CopyProcess::Processor#compile_files_to_element_types | |
# No reason given | |
# ./spec/copyprocess/processor_spec.rb:222 | |
Finished in 1.55 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "home" do | |
before do | |
@domain = "myshop.myshopify.com" | |
@token = SecureRandom.hex(16) | |
@shopify_session = ShopifyAPI::Session.new(@domain, @token) | |
end | |