Skip to content

Instantly share code, notes, and snippets.

View jamesmanning's full-sized avatar

James Manning jamesmanning

View GitHub Profile
@jamesmanning
jamesmanning / CallPremailerApi.cs
Created June 5, 2012 15:42
linqpad script (needs reference to Newtonsoft.Json) for calling premailer API - see http://premailer.dialect.ca/api
void Main()
{
var webClient = new WebClient();
var requestParameters = new NameValueCollection()
{
{ "url", "http://www.hondaelcerritonews.com/news/2012/MayNewsletter/?view=Email" },
{ "preserve_styles", "false" },
{ "remove_ids", "true" },
{ "remove_classes", "true" },
void Main()
{
var instances = new AbstractBase[]
{
new RegularTaskApproach(),
new AsyncAwaitApproach(),
new RegularTaskDerivedFromAsyncAwaitApproach(),
new RegularTaskUsingBaseAsyncAwaitApproach(),
};
@jamesmanning
jamesmanning / Program.cs
Created May 6, 2012 12:32
simple TCP client and server
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
USE [master]
GO
CREATE DATABASE [testing]
GO
USE [testing]
GO
CREATE TABLE [dbo].[Items](
@jamesmanning
jamesmanning / heredoc.rb
Created April 25, 2012 05:25
ruby flexible quoting adds initial newline that here-doc does not
def test_old_style_here_doc
here_doc_style = <<WHEE
foo
bar
WHEE
flexible_quote_style = %{
foo
bar
}
@jamesmanning
jamesmanning / weird.rb
Created April 25, 2012 05:14
weird array slice behavior
def test_slicing_arrays_is_weird
array = [:peanut, :butter, :and, :jelly]
assert_equal :peanut, array[0]
assert_equal :butter, array[1]
assert_equal :and, array[2]
assert_equal :jelly, array[3]
# this confirms that 4 is an invalid index into the array
assert_equal nil, array[4]
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Threading;
using System.Threading.Tasks;
using log4net;
using log4net.Config;
class Program
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Threading;
using System.Threading.Tasks;
using log4net;
using log4net.Config;
class Program
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System.Threading;
class Program
{
static void Main(string[] args)
{