public static class Enum<T>
{
  public static T Parse(string s)
...

C# On Seriously why is there no T...

by Wolfbyte, February 21, 2011 06:14 Star_fullStar_fullStar_fullStar_fullStar_full

Create your own generic Enu...

861f311cc4a077c439099d0e5d251e73 Talk
Assembly GetFromCache(string name) {
  if(!assemblyCache.Contains(name)) return null;
  return assemblyCache[name];
...

C# On Getting data from a list of...

by Wolfbyte, December 14, 2010 04:03 Star_fullStar_fullStar_fullStar_full

Lots of small methods and t...

861f311cc4a077c439099d0e5d251e73 Talk
class Program
    {
        static void Main(string[] args)
...

C# On Generic type converter

by Wolfbyte, November 02, 2010 01:52

If you are willing to pollu...

861f311cc4a077c439099d0e5d251e73 Talk

C# On ASP.NET MVC List Helper

by Wolfbyte, August 23, 2010 04:23 Star_fullStar_fullStar_fullStar_fullStar_full

@Ants: If you look at the i...

861f311cc4a077c439099d0e5d251e73 Talk
public static class ListExtensions
{
    public static string RenderList<T>(this HtmlHelper helper, IEnumerable<T> list,
...

C# On ASP.NET MVC List Helper

by Wolfbyte, August 20, 2010 09:30 Star_fullStar_fullStar_fullStar_fullStar_full

Working off of @Ants versio...

861f311cc4a077c439099d0e5d251e73 Talk

Ruby On change coins

by Wolfbyte, July 26, 2010 08:40

Whoops. Double-posted again

861f311cc4a077c439099d0e5d251e73 Talk
def make_change(amount, coins = [100, 50, 20, 10, 5, 1, 0.5, 0.1])
 make_change_rec(amount, coins.sort { |a,b| b <=> a })
end
...

Ruby On change coins

by Wolfbyte, July 26, 2010 08:39

Here's a recursive version....

861f311cc4a077c439099d0e5d251e73 Talk
def in_pos_activation?(&block)
  return is_pos_activation? { true } unless block_given?
  session[:pos_activation] && yield
...

Ruby On better way?

by Wolfbyte, July 26, 2010 07:36

I'm a fan of re-entrancy wh...

861f311cc4a077c439099d0e5d251e73 Talk
def transact( objs, actions )
  return true if objs.empty?
...

Ruby On Code transactions

by Wolfbyte, August 20, 2008 09:01 Star_fullStar_fullStar_fullStar_fullStar_full

This version behaves in muc...

861f311cc4a077c439099d0e5d251e73 Talk
def transact( objs, actions )
  (objs.empty? or (objs[0].send(actions[0]) and transact(objs[1..-1],actions) )) or (objs[0].send(actions[1]) and false)
end

Ruby On Code transactions

by Wolfbyte, August 20, 2008 08:19 Star_fullStar_fullStar_fullStar_fullStar_full

Even less readable, but how...

861f311cc4a077c439099d0e5d251e73 Talk

Ruby On Ruby Custom Sort

by Wolfbyte, August 05, 2008 01:37

@macournoyer - Cool. I re-p...

861f311cc4a077c439099d0e5d251e73 Talk

Ruby On Ruby Custom Sort

by Wolfbyte, August 04, 2008 10:52

You can't seem to delete an...

861f311cc4a077c439099d0e5d251e73 Talk
require 'csv'

def sort_csv2(filename, fields=["ID"], reverse=false)
...

Ruby On Ruby Custom Sort

by Wolfbyte, August 04, 2008 10:41 Star_fullStar_fullStar_fullStar_fullStar_full

This version constructs an ...

861f311cc4a077c439099d0e5d251e73 Talk
class Object
  def tap
    yield self if block_given?
...

Ruby On Easy - descending range

by Wolfbyte, August 01, 2008 05:18

To make it easier to extend...

861f311cc4a077c439099d0e5d251e73 Talk
byes, heard = 0, true
while byes < 3 do
  puts "Huh?! Speak up, sonny!" unless heard
...

Ruby On Exercise: Deaf Grandma

by Wolfbyte, August 01, 2008 03:11

@Maciej Piechotka - Yep you...

861f311cc4a077c439099d0e5d251e73 Talk

Ruby On Exercise: Deaf Grandma

by Wolfbyte, July 31, 2008 12:55

@houston b-g - You are corr...

861f311cc4a077c439099d0e5d251e73 Talk
def granny_can_hear( message )
  message.upcase == message
end
...

Ruby On Exercise: Deaf Grandma

by Wolfbyte, July 30, 2008 01:41

Hey, welcome to ruby. I'm n...

861f311cc4a077c439099d0e5d251e73 Talk
def granny_can_hear( message )
  message.upcase == message
end
...

Ruby On Exercise: Deaf Grandma

by Wolfbyte, July 30, 2008 01:40

Hey, welcome to ruby. I'm n...

861f311cc4a077c439099d0e5d251e73 Talk
module Enumerable
  def cluster
    c=inject(Hash.new(0)){|h,i|h[i]+=1;h}
...

Ruby On Enumerable#cluster

by Wolfbyte, July 22, 2008 03:05

@Jeremy - Be aware that uni...

861f311cc4a077c439099d0e5d251e73 Talk
puts "Yes means No and No means Yes. Delete all files [Y]?"

...

Ruby On BOFH shell login script

by Wolfbyte, July 22, 2008 02:46

OK well the original was da...

861f311cc4a077c439099d0e5d251e73 Talk
module Enumerable
  def cluster
    counts = {}
...

Ruby On Enumerable#cluster

by Wolfbyte, July 18, 2008 04:27

How about this that does it...

861f311cc4a077c439099d0e5d251e73 Talk
/// <summary>
...

C# On I hate to do this, but...

by Wolfbyte, July 17, 2008 01:40 Star_fullStar_full

I can't resist posting the ...

861f311cc4a077c439099d0e5d251e73 Talk
require 'rexml/document'

class REXML::Elements
...

Ruby On cleaner way to limit result...

by Wolfbyte, July 15, 2008 05:43

Be wary of converting it to...

861f311cc4a077c439099d0e5d251e73 Talk
public static string AsCommaSeparatedValues<T>(this IEnumerable<T> items, Func<T, string> translator)
{
  return items.Select(translator).AsCommaSeparatedValues();
...

C# On Traversing a List and colle...

by Wolfbyte, July 10, 2008 08:22 Star_fullStar_fullStar_fullStar_fullStar_full

Curses! I wasn't logged in ...

861f311cc4a077c439099d0e5d251e73 Talk