Skip to content

Instantly share code, notes, and snippets.

@paigecook
paigecook / XML-Example
Created August 8, 2013 12:47
Example XML file for Blog Post 8/8/2013
<?xml version="1.0" encoding="utf-8"?>
<SEMAPHORE>
<PARAMETERS>
<PARAMETER NAME='TBDB'>nasapoc</PARAMETER>
<PARAMETER NAME='SERVICE'>prefix</PARAMETER>
<PARAMETER NAME='TEMPLATE'>service.xml</PARAMETER>
<PARAMETER NAME='TERM_PREFIX'>11</PARAMETER>
</PARAMETERS>
<TERM_HINTS>
<TERM_HINT NAME='Soyuz T11' ID='OMII0IIN2112985674' INDEX='nasapoc' WEIGHT='39.1393' CLASS='Missions'>
@paigecook
paigecook / XML-Class
Created August 8, 2013 12:45
Classes created from XML-Example for Blog Post 8/8/2013
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class SEMAPHORE
{
private SEMAPHOREPARAMETER[] pARAMETERSField;
private SEMAPHORETERM_HINT[] tERM_HINTSField;
@paigecook
paigecook / JSON-Class
Created August 8, 2013 12:41
Classes created from JSON-Example for Blog Post 8/8/2013
public class Rootobject
{
public Parameters parameters { get; set; }
public Termhint[] termHints { get; set; }
public int total { get; set; }
}
public class Parameters
{
public string tbdb { get; set; }
@paigecook
paigecook / JSON-Example
Created August 8, 2013 12:40
Example JSON file for Blog Post 8/8/2013
{
"parameters":{
"tbdb":"nasapoc",
"service":"prefix",
"template":"service.json",
"term_prefix":"11"
},
"termHints":[
{
"name":"Soyuz T11",
@paigecook
paigecook / CookiesAwareWebClient.cs
Last active December 15, 2015 07:09
Cookies based authentication for NCrawler, overrides the base functionality of WebDownloaderV2
using System.Net;
namespace Crawler
{
public class CookiesAwareWebClient : WebClient
{
private CookieContainer outboundCookies = new CookieContainer();
private CookieCollection inboundCookies = new CookieCollection();
public CookieContainer OutboundCookies
@paigecook
paigecook / NinjectKernelActivator.cs
Created October 9, 2012 19:35
Example of a Ninject IHttpControllerActivator for an ASP.NET Web Api project.
using System;
using System.Net.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Dispatcher;
using Ninject;
namespace WebApiNinjectIHttpControllerActivator
{
public class NinjectKernelActivator: IHttpControllerActivator
{
@paigecook
paigecook / Example.cs
Created June 24, 2011 15:51
SO Question 6466936
using System;
using System.Collections.Generic;
using System.Data.Entity;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
@paigecook
paigecook / .gitignore
Created June 14, 2011 11:42
Git Ignore Settings
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@paigecook
paigecook / Person.cs
Created May 31, 2011 12:26
EF Serialization Entity
using System.Collections.ObjectModel;
using System.Collections.Generic;
namespace MyTest
{
public class Person
{
public Person()
{
Tags = new Collection<Tag>();
public static DbContextExtensions
{
public static void EntryAsModified<T>(this DbContext context, T entity) where T : class
{
context.Entry(entity).State = EntityState.Modified;
}
public static void EntriesAsModified<T>(this DbContext context, IEnumerable<T> entities) where T : class
{
foreach(var entity in entities)