Skip to content

Instantly share code, notes, and snippets.

View dnordstrom's full-sized avatar

Daniel Nordstrom dnordstrom

View GitHub Profile
@dnordstrom
dnordstrom / gist:1201314
Created September 7, 2011 18:25
Ugly code
def in_range?(day)
return true if start_date.nil? || end_date.nil?
# Overlaps onto new year, e.g. winter season
if start_date.month > end_date.month
if day.to_date.month >= start_date.month && day.to_date.month <= 12 # Checking date still in current year
if day.to_date.month >= start_date.month
if day.to_date.month == start_date.month
return true if day.to_date.day >= start_date.day
return false
end
sdfsdsfdfsdsf
@dnordstrom
dnordstrom / gist:1396063
Created November 26, 2011 18:10
Re-gisted!
class DevicesController < ApplicationController
before_filter :authenticate_user!, :only => [:new, :create, :edit, :update, :destroy]
def update_registration_id
@device = Device.find_by_device_id(params[:device_id])
@device.registration_id = params[:registration_id]
@device.save
end
@dnordstrom
dnordstrom / markup_helper_spec.rb
Created December 5, 2011 19:29
String testing
require_relative "../../lib/coffeeshop"
require_relative "../spec_helper"
include CoffeeShop
include SpecHelper
include MarkupHelper
describe MarkupHelper do
before :all do
@base = CoffeeShop::Application.base
@dnordstrom
dnordstrom / LOLfile
Created December 9, 2011 20:09
LOL?!?
daniel-win:hyde Daniel$ rvmsudo hyde
Password:
[2011-12-09 20:34:41] INFO WEBrick 1.3.1
[2011-12-09 20:34:41] INFO ruby 1.9.3 (2011-10-30) [x86_64-darwin11.2.0]
[2011-12-09 20:34:41] INFO WEBrick::HTTPServer#start: pid=2845 port=80
localhost - - [09/Dec/2011:20:34:52 CET] "GET / HTTP/1.1" 200 12
- -> /
localhost - - [09/Dec/2011:20:34:53 CET] "GET /favicon.ico HTTP/1.1" 200 12
- -> /favicon.ico
localhost - - [09/Dec/2011:20:48:26 CET] "GET /scrape?info_hash=%a60N%1bu%1f%5et%b7%bd%ee%0f%5e%da%97%80%2a%f7M%1f&info_hash=%2b%f9%e5%40%3a%b2%13%1c%84%aa%db%04%ca%d0%cdv%fb%af%a4%d9&info_hash=_%b9%deM%0c%c0%0fy%c9%ee%01~%15%adJw%0e%9f%0e%94&info_hash=%d0%ebn4%f1%2aML%89%8c%9b%ddy%88%86%e4%09%d9%8d%96&info_hash=%80JL%9e%ed%f9M%1cf%87%3f%f7%c1%96%408%e2l%be%c8&info_hash=2%01%18%8b%3eeo%5c%ece%29~%80y%19%28%0b%e6%99c&info_hash=%94%1d%b3%25w%d3K%ef%d2%5e%f3%b1%fc%9e%05%94%a6%e0%ff%e0&info_hash=I-My%c0b%d8%3ev%a7%ed%87%a3%cb%a9%40YH%14%ea&info_hash=%97zvCX1%bf%3e%9f%11%1c%c7%1em%a0e.%85O%0d&info_hash=%b3%40I%ab%13p%84%
@dnordstrom
dnordstrom / gist:1526086
Created December 28, 2011 03:41
Question

Radar: Anyway, I figure you have more insight into Spree DB schema etc than me, and definitely more experience, so; about "that thing" from earlier, the shit site that was my first Rails (and Spree) project. I've installed latest Spree and I'm now considering DB migration approaches to get data from the old 0.11 site to the new site:

  1. Could run migrations on the new clean setup and go from there (i.e. transfer old content to the new site when the schema is in place.)
  2. Could also import an SQL dump to the new DB and just attempt to get that running.

I looked at the Spree migrations added to your repo the past year and while they aren't many, there are some. Namely:

20111007143030_namespace_top_level_models.rb 20111107143030_migrate_namespaced_polymorphic_models.rb 20111128153359_new_preferences.rb

@dnordstrom
dnordstrom / gist:1526108
Created December 28, 2011 03:47
Question

Radar: Anyway, I figure you have more insight into Spree DB schema etc than me, and definitely more experience, so; about "that thing" from earlier, the shit site that was my first Rails (and Spree) project. I've installed latest Spree and I'm now considering DB migration approaches to get data from the old 0.11 site to the new site:

  1. Could run migrations on the new clean setup and go from there (i.e. transfer old content to the new site when the schema is in place.) However, I'm not sure how many, or which, tables I'll need to transfer the data from so it could be troublesome. I remember doing this in old PHP projects years ago, and it wasn't fun.

  2. Could also import an SQL dump to the new DB and just attempt to get that running. However, I'm not sure just how much the following recent migrations in Spree could complicate things, seeing as the site is relatively old.

I looked at the Spree migrations added to your repo the past year and while they aren't many, there are some. Namely:

  • 20110111122537
@dnordstrom
dnordstrom / rails new asggifts -d mysql
Created December 29, 2011 16:01
rails new asggifts -d mysql
 create
 create README
 create Rakefile
 create config.ru
 create .gitignore
 create Gemfile
 create app
 create app/assets/images/rails.png
 create app/assets/javascripts/application.js
 create app/assets/stylesheets/application.css
== 1 =
Command: rails new asggifts -d mysql
Output: https://gist.github.com/1534716
@dnordstrom
dnordstrom / gist:1536797
Created December 30, 2011 00:00
Command line progress of Spree upgrade/migration
##
# Command line logging during Spree 0.11 to 1.0.0.rc1 migration.
# (Skipping source control commands.)
##
Sites
> rvm gemset create asgseedbank-1.0.0rc
Sites
> rvm gemset use asgseedbank-1.0.0rc