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
-- Original | |
SELECT DATEADD(day, - (1 * DATEPART(dw, RegisterDateTime)), CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, RegisterDateTime)))) AS Week, | |
COUNT(ProductRegistrationID) AS RegistrationCount, SUM(CONVERT(TINYINT, ContentExpert)) AS ContentExpertCount | |
FROM ProductRegistrations | |
WHERE (RegisterDateTime > DATEADD(year, - 1, DATEADD(day, (1 * DATEPART(dw, GETDATE())), GETDATE()))) | |
GROUP BY DATEADD(day, - (1 * DATEPART(dw, RegisterDateTime)), CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, RegisterDateTime)))) | |
ORDER BY Week DESC | |
-- My Attempt to convert |
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
# works | |
require 'rest_client' | |
# broken | |
dependency 'rest-client' | |
# broken | |
dependency 'rest_client' | |
# this might work!? |
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
### The controller | |
def index | |
@products = Product.all(:order => [:model_number, :model_name]) | |
display @products | |
end | |
### The model | |
belongs_to :manufacturer |
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 'rubygems' | |
require 'daemons' | |
puts 'I am not a daemon yet.' | |
# Become a daemon | |
Daemons.daemonize | |
loop do | |
puts 'Woo hoo!' |
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 LdapServer | |
include DataMapper::Resource | |
property :id, Serial | |
property :host, String, :length => 255 | |
property :port, Integer, :default => 389 | |
property :base_dn, String, :length => 255, :default => "dc=example,dc=com" | |
property :object_class, String, :default => "organizationalPerson" | |
property :email_attr, String, :default => "mail" |
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
# Solved! | |
class Thing | |
# these associations are fine | |
belongs_to :user | |
belongs_to :assigned_user, :class_name => "User", :child_key => [:assigned_user_id] | |
# this is not working | |
has n, :subscriptions | |
has n, :subscribers, :through => :subscriptions, :class_name => 'User', :child_key => [:ticket_id], :remote_name => :user |
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 Book | |
belongs_to :group | |
has n, :subscriptions | |
has n, :subscribers, :through => :subscriptions, :class_name => 'User', | |
:child_key => [:book_id], :remote_name => :user | |
end | |
class Group | |
has n, :books | |
has n, :users, :through => Resource |
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
#!/usr/bin/env ruby | |
# | |
# Be sure to configure this node in the plugin configuration | |
# Memory stats must be run by root | |
# Ex: | |
# [passenger_memory] | |
# user root | |
# env.memory_stats_command path_to_passenger-memory-stats | |
# | |
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
### just post a string to a url, and we can figure out what type of post it is | |
chat_string = "Me: Hello | |
You: Hello back | |
Me: I need to get this blog done | |
Me: Like now | |
You: Yeah, you do | |
You: It really has been a while | |
Me: OK, that's enough from you" | |
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
# Rails initializer for CouchDB | |
begin | |
config = YAML::load(File.open('config/couchdb.yml')) | |
rescue | |
puts "ERROR: Could not read config/couchdb.yml" | |
exit(1) | |
end | |
begin | |
RelaxDB.configure(config[RAILS_ENV]) |
OlderNewer