Skip to content

Instantly share code, notes, and snippets.

@bitsprint
bitsprint / not_first_child.css
Created July 29, 2012 09:43
Select all elements except first
tr:not(:first-child) {
color: red;
}
@bitsprint
bitsprint / TestDataBuilder.cs
Created March 14, 2013 13:50
TestDataBuilder
namespace Tests.Core.Builder
{
using System;
public class TestDataBuilder<T, U> where T : TestDataBuilder<T, U>, new() where U : new()
{
private readonly U entity = new U();
protected TestDataBuilder()
{
@bitsprint
bitsprint / server.csx
Last active December 15, 2015 06:08
server.csx
#load "ApiControllerWithHub.csx"
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.IO;
using System.Net;
using System.Net.Http;
@bitsprint
bitsprint / ApiControllerWithHub.csx
Created March 21, 2013 14:47
ApiControllerWithHub.csx
public abstract class ApiControllerWithHub<THub> : ApiController where THub : IHub
{
Lazy<IHubContext> hub = new Lazy<IHubContext>(
() => GlobalHost.ConnectionManager.GetHubContext<THub>()
);
protected IHubContext Hub
{
get { return hub.Value; }
}
@bitsprint
bitsprint / string.js
Created May 22, 2013 15:31
String functions
/*
var s = "Replace {foo}";
var o = { foo: "this"};
var result = s.interpolate(o);
console.log(result);
// Replace this
*/
String.prototype.interpolate = function (o) {
return this.replace(/{([^{}]*)}/g, function (a, b) {
var r = o[b];
@bitsprint
bitsprint / number.js
Created May 22, 2013 15:43
Number functions
Number.prototype.formatMoney = function (c, d, t) {
var n = this,
s = n < 0 ? "-" : "",
j = (j = i.length) > 3 ? j % 3 : 0;
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d === undefined ? "," : d,
t = t === undefined ? "." : t,
var i = parseInt(n = Math.abs(+n || 0).toFixed(c), 10) + "";
@bitsprint
bitsprint / date.js
Created May 22, 2013 15:47
Date functions
Date.prototype.formatDDMMYYYY = function () {
return ('0' + this.getDate()).slice(-2) +
'/' + ('0' + (this.getMonth() + 1)).slice(-2) +
'/' + this.getFullYear();
};
Date.prototype.formatDDMMYYYYWithHMS = function () {
return ('0' + this.getDate()).slice(-2) +
'/' + ('0' + (this.getMonth() + 1)).slice(-2) +
'/' + this.getFullYear() +
@bitsprint
bitsprint / UiExtensions.js
Created May 23, 2013 07:49
jQuery UI DateTime extensions
var App = { namespace: 'foo' };
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery'
, 'jqueryui'
, App
@bitsprint
bitsprint / logger.js
Created May 23, 2013 08:33
Base Logger
var App = App || {};
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
App
], factory);
} else {
@bitsprint
bitsprint / consoleLogger.js
Created May 24, 2013 09:54
Console Logger
var App = App || { };
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'App'
], factory);