This file contains hidden or 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 | |
| days = %w(first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth) | |
| things = ['a partridge in a pear tree', 'two turtledoves', 'three French hens', 'four calling birds', 'five golden rings', 'six geese a-laying', 'seven swans a-swimming', 'eight maids a-milking', 'nine ladies dancing', 'ten lords a-leaping', 'eleven pipers piping', 'twelve drummers drumming'] | |
| days.each_with_index do |day, i| | |
| puts "On the #{day} day of Christmas, my true love sent to me:" | |
| day_things = things[0..i].reverse.each_with_index.map do |thing, j| | |
| case j |
This file contains hidden or 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
| # Calculates the area of a triangle given the length of it's sides | |
| def heron(a, b, c) | |
| s = (a+b+c)/2 | |
| Math.sqrt(s*(s-a)*(s-b)*(s-c)) | |
| end |
This file contains hidden or 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 TiltHelper | |
| def initialize(prefix) | |
| @prefix = prefix | |
| end | |
| def include(partial) | |
| Tilt.new("#{@prefix}/#{partial}").render | |
| end | |
| end | |
| rule( /\.((?!erb$)([A-Za-z0-9]))+$/ => |
This file contains hidden or 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.Text.RegularExpressions; | |
| public static class StringHelpers { | |
| private const char _cr = '\u000D'; | |
| private const char _lf = '\u000A'; | |
| private const string _crlf = _cr + _lf; | |
| private static Regex _crlfRegex = new Regex(_cr + '|' + _lf + '|' + _crlf); | |
| public static string NormalizeNewline(this string str){ |
This file contains hidden or 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
| private static readonly Type StringType = typeof(string); | |
| private static readonly Dictionary<Type, bool> IsStringAssignable = new Dictionary<Type, bool> { { StringType, true } }; | |
| private static readonly Dictionary<Type, ConstructorInfo> SingleStringConstructor = new Dictionary<Type, ConstructorInfo>(); | |
| private static readonly Dictionary<Type, MethodInfo> ParseMethod = new Dictionary<Type, MethodInfo>(); | |
| public static T Get<T>(string setting) | |
| { | |
| object value = ConfigurationManager.AppSettings.Get(setting); |
This file contains hidden or 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
| /** @file | |
| * This software is licensed under the MIT license. | |
| * | |
| * @par The MIT License | |
| * | |
| * Copyright (c) 2012 Jo-Herman Haugholt | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| * of this software and associated documentation files (the "Software"), to deal | |
| * in the Software without restriction, including without limitation the rights |
This file contains hidden or 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
| /** | |
| * Simple example use of Paginator and jQuery | |
| * @requires jQuery | |
| * @requires Paginator.js | |
| */ | |
| var pager = new Paginator(); | |
| pager.setCurrent(5); | |
| pager.setLast(23); |
This file contains hidden or 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
| meter { | |
| -webkit-appearance: meter; | |
| -webkit-box-sizing: border-box; | |
| -moz-box-sizing: border-box; | |
| box-sizing: border-box; | |
| display: inline; | |
| display: -moz-inline-box; | |
| display: -webkit-inline-box; | |
| display: inline-block; |
NewerOlder