Skip to content

Instantly share code, notes, and snippets.

@potatosalad
potatosalad / gist:1528977
Created December 28, 2011 18:16 — forked from Chris-Galten/gist:1528941
Making categories
step 'the following category records' do |table|
table.hashes.each do |hash|
a = AttributeSet.find_or_create_by(slug: 'myattritubetest', label: 'myattributetest', description: 'myattributeset')
if hash['parents'].present?
path = hash['parents'].split(', ')
ancestor = Category.find_or_create_by(title: path.shift, attribute_set_id: a.id)
path.each_with_index do |ancestor_title, index|
category = Category.find_or_create_by(title: ancestor_title, parent_id: ancestor.id, attribute_set_id: a.id)
ancestor = category
end
window.History.Adapter.bind window, 'statechange', ->
State = window.History.getState()
window.History.log State.data, State.title, State.url
if State.data.content?
$('.product-page').html(State.data.content)
dimensions = ":input[name='size_id'], :input[name='color_id'], :input[name='config_id']"
window.History.replaceState { content: $('.product-page').html() }, null, window.location
--- /Users/andrew/Work/Rejuvenation/web/vendor/assets/javascripts/cloud-zoom.js Mon Jan 9 14:09:04 2012
+++ /Users/andrew/Work/Rejuvenation/web/vendor/assets/javascripts/cloud-zoom.js Tue Jan 17 20:01:30 2012
@@ -20,20 +20,19 @@
function CloudZoom(jWin, opts) {
var sImg = $('img', jWin);
- var img1;
- var img2;
+ var img1;
+ var img2;
@potatosalad
potatosalad / project-web-reload.conf
Created February 11, 2012 03:32
Upstart + Bluepill + Unicorn with hot restart
# /etc/init/project-web-reload.conf
pre-start script
initctl restart project-web
sleep 15
end script
exec /usr/local/rvm/bin/default_bluepill restart
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
require 'stalker'
stalker_config_file = File.join(Rails.root, 'config', 'stalker.yml')
if File.file?(stalker_config_file)
environment = defined?(Rails) && Rails.respond_to?(:env) ? Rails.env : ENV["RACK_ENV"]
settings = YAML.load(ERB.new(File.new(stalker_config_file).read).result)[environment]
if settings.present?
begin
Stalker.connect(settings['beanstalk_url'])
@potatosalad
potatosalad / destructive_class_methods.rb
Created September 17, 2012 21:24
Destructive class methods for Ruby (hopefully all of them)
# ruby -rmongoid destructive_class_methods.rb
class DestructiveClassMethods
include Mongoid::Document
end
File.open('destructive_class_methods.txt', 'wb') do |f|
DestructiveClassMethods.methods.sort.each do |method|
f.puts method
end
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
require 'formula'
class Beanstalk < Formula
homepage 'http://kr.github.com/beanstalkd/'
url 'https://github.com/downloads/kr/beanstalkd/beanstalkd-1.8.tar.gz'
sha1 'b8c274d7233e02c6793d8d119608ad7c878b0954'
def install
system "make", "install", "PREFIX=#{prefix}"
end
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()