Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace DynamicDispatch
{
interface IAnimalVisitor
@esfand
esfand / PrintValues
Created March 20, 2010 11:55
MSBuild Property Demo
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
DefaultTargets="PrintValues"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Add>$([MSBuild]::Add(5,9))</Add>
<Subtract01>$([MSBuild]::Subtract(90,768))</Subtract01>
<Mult01>$([MSBuild]::Multiply(4,9))</Mult01>
<Div01>$([MSBuild]::Divide(100,5.2))</Div01>
@vijayganeshpk
vijayganeshpk / OracleDynamicParameters.cs
Last active February 8, 2024 09:04
OracleDynamicParameters class for Dapper
using Dapper;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
public class OracleDynamicParameters : Dapper.SqlMapper.IDynamicParameters {
private static Dictionary<SqlMapper.Identity, Action<IDbCommand, object>> paramReaderCache = new Dictionary<SqlMapper.Identity, Action<IDbCommand, object>>( );
@sofoklis
sofoklis / customsi.scala
Last active January 10, 2018 10:01
Custom string interpolation
object Test {
// Implicit class is also a new feature in scala 2.10
implicit class CounterSC(val sc: StringContext) extends AnyVal {
// Define functions that we want to use with string interpolation syntax
def partsCount(args: Any*): Int = sc.parts.length
def argsCount(args: Any*): Int = args.length
def tokenCount(args: Any*): Int = sc.parts.length + args.length
def getParts(args: Any*): String =
namespace YourNamespace
{
/// <summary>
/// Uses the Name value of the <see cref="ColumnAttribute"/> specified to determine
/// the association between the name of the column in the query results and the member to
/// which it will be extracted. If no column mapping is present all members are mapped as
/// usual.
/// </summary>
/// <typeparam name="T">The type of the object that this association between the mapper applies to.</typeparam>
public class ColumnAttributeTypeMapper<T> : FallbackTypeMapper
@DotNetNerd
DotNetNerd / PhantomRunner.cs
Created May 23, 2013 11:20
Grabbing a site in C# using phantomJS
class Program
{
static void Main(string[] args)
{
var grabby = new Grabby();
string output = grabby.Grab("http://www.dotnetnerd.dk/cv");
Console.WriteLine(output);
File.WriteAllText("c:\\test.html", output);
}
@mathias-brandewinder
mathias-brandewinder / gist:6443302
Last active January 8, 2024 05:19
Experimenting with Accord SVM
#r @"..\packages\Accord.2.8.1.0\lib\Accord.dll"
#r @"..\packages\Accord.Math.2.8.1.0\lib\Accord.Math.dll"
#r @"..\packages\Accord.Statistics.2.8.1.0\lib\Accord.Statistics.dll"
#r @"..\packages\Accord.MachineLearning.2.8.1.0\lib\Accord.MachineLearning.dll"
open System
open System.IO
open Accord.MachineLearning
open Accord.MachineLearning.VectorMachines
@emiller
emiller / git-mv-with-history
Last active October 15, 2024 14:08
git utility to move/rename file or folder and retain history with it.
#!/bin/bash
#
# git-mv-with-history -- move/rename file or folder, with history.
#
# Moving a file in git doesn't track history, so the purpose of this
# utility is best explained from the kernel wiki:
#
# Git has a rename command git mv, but that is just for convenience.
# The effect is indistinguishable from removing the file and adding another
# with different name and the same content.
@MishaelRosenthal
MishaelRosenthal / InviteResponse.scala
Created January 21, 2014 13:17
Usage example for Scala Json writing and reading using Spray. The example includes: Polymorphism, nested case classes, case objects, external libraries classes (FiniteDuration), lists.
package com.liveperson.predictivedialer.common.sessions
import scala.concurrent.duration.FiniteDuration
/**
* User: michaelna
* Date: 1/15/14
* Time: 2:58 PM
*/
object InviteResponse {
module Counter =
type State = { Value: int }
static member Zero = { Value: 0 }
type Command =
| Incremement
| Decrement
type Event =
| Incremented