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
// 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; } | |
} | |
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
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; |
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
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++; | |
} | |
} |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Diagnostics; | |
namespace ConsoleApplication11 { | |
class Program { |
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
dfdfd |
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
# 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, |
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
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) |
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
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 |
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
str = <<-EOS | |
Stallone | |
Star Trek | |
Star Wars | |
Starship Troopers | |
State Property | |
Stephen King | |
Steven Seagal | |
Steven Spielberg | |
Street Fighter |
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
This is a gist |
OlderNewer