Skip to content

Instantly share code, notes, and snippets.

View myobie's full-sized avatar

Nathan myobie

View GitHub Profile
-- 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
@myobie
myobie / init.rb
Created October 31, 2008 21:20 — forked from zackchandler/init.rb
# works
require 'rest_client'
# broken
dependency 'rest-client'
# broken
dependency 'rest_client'
# this might work!?
### The controller
def index
@products = Product.all(:order => [:model_number, :model_name])
display @products
end
### The model
belongs_to :manufacturer
require 'rubygems'
require 'daemons'
puts 'I am not a daemon yet.'
# Become a daemon
Daemons.daemonize
loop do
puts 'Woo hoo!'
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"
# 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
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
@myobie
myobie / gist:37528
Created December 18, 2008 15:29 — forked from wmoxam/gist:37525
#!/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
#
### 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"
# 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])