Skip to content

Instantly share code, notes, and snippets.

@michael-newton-15below
michael-newton-15below / GrabNugets.fsx
Created November 20, 2012 15:07
Nuget.Core example
#r "Nuget.Core"
#r "System.Xml.Linq"
open NuGet
open System
open System.Linq
let repoFac = new PackageRepositoryFactory()
let repo = repoFac.CreateRepository("http://btn-tc01:8083")
let FiveFiveVersion = new SemanticVersion("5.5.0")
let packages = repo.FindPackages("Database.PASNGR", new VersionSpec(), false, false)
@nh2
nh2 / haskell-pcap-writing.hs
Created November 25, 2012 22:56
Haskell PCAP writing / dump (instance Storable PktHdr)
module PktHdrStorableInstance where
import Foreign.Marshal.Utils (with)
import Foreign.Ptr (plusPtr)
import Foreign.Storable
import Network.Pcap
import Network.Pcap.Base (toPktHdr)
#include <pcap.h>
@robstewart57
robstewart57 / AsyncTimeouts.hs
Created December 3, 2012 13:28
Timeouts in async haskell package
{-# LANGUAGE DeriveDataTypeable #-}
import Control.Concurrent (threadDelay)
import Control.Exception (Exception,throw)
import Control.Monad (void)
import Control.Concurrent.Async (Async,race,wait,withAsync)
import Data.Typeable (Typeable)
data ThreadTimeoutException = ThreadTimeoutException
deriving (Show, Typeable)
@mslinn
mslinn / PaypalTransaction.scala
Last active October 25, 2016 01:31
Attempt to persist entities with >22 fields via Slick. Cannot find documentation on how nested tuples are supposed to work; tried creating two helper classes (CustomerAddress and PaymentDetail). Compiler error is: scala: overloaded method value <> with alternatives: [R(in method <>)(in method <>)(in method <>)(in method <>)(in method <>)(in meth…
package com.micronautics.paypal
import java.util.{ List, Map }
import collection.JavaConversions._
import collection.immutable.HashMap
import controllers.Email
import org.joda.time.DateTime
import slick.driver.MySQLDriver.simple._
import java.util
@nairdo
nairdo / NuGetPackageFolder.cs
Last active December 14, 2016 14:04
From the NuGet Package Explorer's MainWindow.xaml.cs and the PackageViewModel PackageFolder class...
///
/// Example building a package (from the NuGet PackageBuilderTest.cs class)
///
// Act
var builder = new PackageBuilder { Id = "test", Version = new SemanticVersion("1.0"), Description = "test" };
builder.Authors.Add("test");
foreach (var name in fileNames)
{
@janbaer
janbaer / gist:4585893
Created January 21, 2013 13:05
GetAssemblyDirectory - Returns the directory name for the executing assembly
private static string GetAssemblyDirectory()
{
return new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Directory.FullName;
}
@krishnanraman
krishnanraman / gist:4759672
Last active October 25, 2016 01:32
Tony Morris class
// And by the way, please feel free to contribute, correct errors, etc!
trait Functor[F[_]] {
def fmap[A, B](f: A => B): F[A] => F[B]
}
object Functor {
val ListFunctor: Functor[List] =
new Functor[List] {
def fmap[A, B](f: A => B) =
@takezoux2
takezoux2 / detect-jdbc-driver-name.scala
Created February 13, 2013 04:42
Detect jdbc driver name from jdbc url.
def detectDriverNameFromUrl(url : String) : Option[String] = {
val splits = url.split(":")
if(splits.length < 2){
return None
}
if(splits(0) != "jdbc"){
return None
}
@michael-newton-15below
michael-newton-15below / build.fsx
Created February 13, 2013 13:20
Literate build file.
(**
## References
As they aren't part of a project, fsx files need
to reference all of their dependencies within the
file.
You'll always want to reference FakeLib. VersionUpdater
is an inhouse tool we use for handling feature branch
@michael-newton-15below
michael-newton-15below / build.fsx
Created February 13, 2013 13:23
Literate build.fsx
(**
## References
As they aren't part of a project, fsx files need
to reference all of their dependencies within the
file.
You'll always want to reference FakeLib. VersionUpdater
is an inhouse tool we use for handling feature branch