Skip to content

Instantly share code, notes, and snippets.

public partial class MyContext
{
private static Dictionary<Type, EntitySetBase> _mappingCache =
new Dictionary<Type, EntitySetBase>();
private string GetTableName(Type type)
{
EntitySetBase es = GetEntitySet(type);
return string.Format("[{0}].[{1}]",
@ro31337
ro31337 / gist:9e5cdb33343b2d8ab635
Created October 1, 2014 18:20
Knockout sample
<span data-bind="text: Name"></span>
var ViewModel = new function() {
var self = this;
self.Name = ko.observable("Sample User");
}
ko.applyBindings(ViewModel);
var ViewModel = new function() {
var self = this;
self.Name = ko.observable("Sample User");
self.DateOfBirth = ko.observable();
}
ko.applyBindings(ViewModel);
<span data-bind="text: Name"></span>
<span data-bind="dateString: DateOfBirth, datePattern: 'MM/DD/YYYY'"></span>
ko.bindingHandlers.dateString = {
update: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var value = valueAccessor(),
allBindings = allBindingsAccessor();
var valueUnwrapped = ko.utils.unwrapObservable(value);
var pattern = allBindings.datePattern || 'mmmm d, yyyy';
if (valueUnwrapped == undefined || valueUnwrapped == null) {
$(element).text("");
}
else {
#import
@interface CustomUITableViewCell : UITableViewCell
{
NSMutableArray *columns;
}
- (void)addColumn:(float)column;
@end
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect rect = self.bounds;
UIColor *separatorColor = [UIColor colorWithRed:208.0/255.0 green:208.0/255.0 blue:208.0/255.0 alpha:1.0];
for (int i = 0; i < [columns count]; i++)
{
@ro31337
ro31337 / gist:8be745dba280927d849f
Created February 11, 2015 16:36
AutoFixture performance
using System;
using System.Diagnostics;
using Ploeh.AutoFixture;
namespace ConsoleApplication1
{
class Program // by Roman Pushkin - roman.pushkin/at/gmail
{
static void Main(string[] args)
{
@ro31337
ro31337 / gist:0ef33cbd85c445d1beeb
Last active September 1, 2015 22:21
EmailAddress value object bug
=== Buggy ===
class EmailAddress
include Comparable
def initialize(string)
if string =~ /@/
@raw_email_address = string.downcase.strip
else
raise ArgumentError, "email address must have an '@'"
@ro31337
ro31337 / gist:6f3f0058ff63e4dc037d
Created September 10, 2015 23:53
What's better: (1) or (2) ?
***********
*** (1) ***
***********
=== html ===
...
<body>
<div class="component-a">
</div>
@ro31337
ro31337 / app.js
Created September 20, 2015 05:32
if (Meteor.isClient) {
// counter starts at 0
Session.setDefault('counter', 0);
Template.hello.helpers({
counter: function () {
return Session.get('counter');
}
});