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
internal static class Guard | |
{ | |
public static void AgainstNull(string name, object value) | |
{ | |
if (value == null) | |
{ | |
throw new ArgumentNullException(name); | |
} | |
} |
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
def secure_token | |
token_file = Rails.root.join(".secret") | |
unless File.exists?(token_file) | |
system("rake secret >> #{token_file}") | |
end | |
File.read(token_file).chomp | |
end |
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
require "spec_helper" | |
describe SimpleClass do | |
before do | |
subject.name = "Some Name" | |
subject.description = "Some Description" | |
end | |
its(:name) { should eq("Some Name") } |
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; | |
namespace CI.Demo | |
{ | |
public class Feature | |
{ | |
public string Name { get; private 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
group :assets do | |
... | |
gem "handlebars-source" | |
gem 'ember-rails' | |
gem 'ember-source', '1.0.0.rc6.3' | |
gem 'qunit-rails' | |
... | |
end |
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
#include <stdlib.h> | |
#include <assert.h> | |
#include "stack.h" | |
void stack_new(stack *s, int elementSize, freeFunction freeFn) | |
{ | |
s->list = malloc(sizeof(list)); | |
// make sure the malloc call didn't fail... | |
assert(s->list != NULL); |
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
#include <stdlib.h> | |
#include <string.h> | |
#include <assert.h> | |
#include "list.h" | |
void list_new(list *list, int elementSize, freeFunction freeFn) | |
{ | |
assert(elementSize > 0); | |
list->logicalLength = 0; |
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
public static HelperResult RenderIf<TType>(this HtmlHelper html, Func<TType, HelperResult> template, TType item, bool condition) | |
{ | |
return html.RenderIf(template, new TType[] { item }, condition); | |
} | |
public static HelperResult RenderIf<TType>(this HtmlHelper html, Func<TType, HelperResult> template, IEnumerable<TType> items, bool condition) | |
{ | |
if (condition) | |
{ | |
return new HelperResult(writer => |
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
public class CacheManager | |
{ | |
// CLR guarantees thread-safety during initialization | |
private static Dictionary<string, object> CacheKeyDictionary = new Dictionary<string, object>(); | |
public static TObj GetCachedObject<TObj>(string cacheKey, Func<TObj> creator) where TObj : class | |
{ | |
var cache = HttpContext.Current.Cache; | |
var obj = cache[cacheKey] as TObj; | |
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
#import <Foundation/Foundation.h> | |
@interface NSDate (OData) | |
- (id)initWithODataString:(NSString *)dateString; | |
- (NSString *)toODataQueryFormat; | |
+ (NSDate *)dateFromString:(NSString *)dateString; | |
@end |
OlderNewer