Skip to content

Instantly share code, notes, and snippets.

function ValidationRules(viewModel) {
function validateInteger(value, element, param) {
if (!value) {
return false;
}
var parsedNumber = parseFloat(value);
if (isNaN(parsedNumber)) {
return false;
} else {
return (value == parsedNumber);
<#@ template language="C#" #>
<#@ output extension=".sql" #>
<#@ assembly name="$(ProjectDir)bin\Debug\SiepaczeKoduSample.Infrastructure.dll" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="SiepaczeKoduSample.Infrastructure" #>
<#
IList<Dictionary> dictionary = TemplateHelper.GetDictionary(@"C:\Users\Zaba\Pictures\SiepaczeKodu\Dictionary.csv");
#>
public class Permutation
{
public static IEnumerable<string> GetPermutations(string s)
{
if (s.Length > 1)
return from ch in s
from permutation in GetPermutations(s.Remove(s.IndexOf(ch), 1))
select string.Format("{0}{1}", ch, permutation);
else
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class RequiredIfEmptyAttribute : ValidationAttribute, IClientValidatable
{
private readonly string[] _dependentProperties;
public RequiredIfEmptyAttribute(params string[] dependentPropertieses)
{
_dependentProperties = dependentPropertieses;
}
class Program
{
static void Main(string[] args)
{
Foo foo = new Foo();
var setValue = BuildSet<Foo, string>("Bar.Name");
var getValue = BuildGet<Foo, string>("Bar.Name");
setValue(foo, "abc");
Console.WriteLine(getValue(foo));
// 3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <ctime>
using namespace std;
class Figura
{
namespace editors {
export function getEditorClasses(): FactoryConstructor[] {
let list = [];
Object.keys(this).forEach(name => {
let obj = this[name];
if (obj.prototype instanceof editors.Factory) {
list.push(obj);
}
@Zabaa
Zabaa / DirectReport.sql
Created September 13, 2017 15:43
CTE Example
WITH DirectReports (ManagerID, EmployeeID, Title, Level)
AS
(
-- Anchor member definition
SELECT e.ManagerID, e.EmployeeID, e.Title,
0 AS Level
FROM dbo.MyEmployees AS e
WHERE e.ManagerID IS NULL
UNION ALL
-- Recursive member definition
@Zabaa
Zabaa / javascript.json
Last active November 5, 2017 18:30
React Redux component vscode snippet
{
"ReactReduxComponent": {
"prefix": "rrcomp",
"body": [
"import React, { PropTypes } from 'react';\r",
"import { connect } from 'react-redux';\r",
"import { bindActionCreators } from 'redux';\r",
"\r",
"class ${1:ReactComponent} extends React.Component {\r",
" constructor(props, context) {\r",
@Zabaa
Zabaa / ApplicationBuilder.cs
Last active April 16, 2018 14:45
Fluent Builder
using System;
using System.Collections.Generic;
namespace FunWithPatterns.Builder
{
public class ApplicationBuilder
{
private string _name;
private string _sureName;
private DateTime _birthDate;