Skip to content

Instantly share code, notes, and snippets.

// first param is the class, second is the primary key
public class Order : ActiveRecord<Order,int> {
BelongsTo<Customer> Customer { get; set; }
[PrimaryKey(AutoIncrement=true)]
public int Id { get; set; }
public string Details { get; set; }
}
@SamSaffron
SamSaffron / gist:101357
Created April 24, 2009 21:51
Control Vlc
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Management;
using System.Net.Sockets;
using System.IO;
static class LinqExtension {
public static IEnumerable<T> SampleEvery<T>(this IEnumerable<T> items, int sample) {
int i = 0;
foreach (var item in items) {
if ((i % sample) == 0) {
yield return item;
}
i++;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
namespace ConsoleApplication11 {
class Program {
# ok
class List
named_scope :without_address, lambda { |address_id| { :joins => :address_list_memberships, :conditions => ['address_list_memberships.address_id <> ?', address_id]}}
end
# ugly
class List
def self.without_address_lookup(address_id)
{
:joins => :address_list_memberships,
create proc spShog9
as
set nocount on
create table #results (row varchar(max), id int)
declare @currentCol varchar(100)
declare @AvgLength int
declare @MaxLength int
declare @colNames varchar(max)
create view UserTotals
as
select UserId, Reputation, Questions, [Answers], Upvotes, Downvotes from
(
select
UserId = u.Id,
u.Reputation as Reputation,
sum(case when p.ParentId is null then 1 else 0 end) as Questions,
sum(case when p.ParentId is not null then 1 else 0 end) as [Answers]
from Users u
@SamSaffron
SamSaffron / test.rb
Created February 15, 2010 20:55
Test
str = <<-EOS
Stallone
Star Trek
Star Wars
Starship Troopers
State Property
Stephen King
Steven Seagal
Steven Spielberg
Street Fighter
This is a gist