Skip to content

Instantly share code, notes, and snippets.

@jchannon
jchannon / ToDynamic.cs
Created October 17, 2017 19:15 — forked from orhanveli/ToDynamic.cs
Object or Array to Dynamic in C#
public static class Extensions
{
public static dynamic ToDynamic(this object value)
{
if (value.IsListOrArray ()) {
var list = new List<ExpandoObject> ();
IEnumerable enumerable = value as IEnumerable;
foreach (object o in enumerable) {
list.Add (o.ToDynamic ());
@jchannon
jchannon / httpStatusCodes.js
Created April 23, 2016 12:41 — forked from marlun78/httpStatusCodes.js
An HTTP Status Codes object
/**
* HTTP Status Codes
* Copyright (c) 2012, marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* Taken from: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
* Visual Studio find regex: ^(\d{3}) ([^\r\n]+)\r\n
* Visual Studio replace regex: '$1': '$2', //
* Notes wrapped in parens moved manually
*/
@jchannon
jchannon / recipes.go
Last active November 2, 2015 17:41 — forked from philcleveland/routes.go
Currently how I define my routes for api's in Go. Up for discussion
type Recipe struct{}
func NewRecipe(*router router) *router {
router.HandleFunc("/recipe/{id}", GetById)
}
func GetById(writer w, *request r) *handler {
//do something
}
@jchannon
jchannon / NancyOwinSelfHostWindowsAuth.cs
Last active September 22, 2015 11:40 — forked from damianh/NancyOwinSelfHostWindowsAuth.cs
Nancy owin self hosting with Microsoft.Owin.HttpListener and windows authentication on .NET 4.0 (Personal opinion: avoid windows NTLM auth in web applications, even intranet ones. Use standards based SSO.)
namespace ConsoleApplication1
{
using System;
using System.Collections.Generic;
using System.Net;
using System.Security.Principal;
using Microsoft.Owin.Hosting;
using Nancy;
using Owin;
Assuming your web app supports deep linking, like an AngularJS one would.
Assume basic crud of Foo. So list, create, edit and delete.
If a user bookmarks in your app an edit page eg/http://mydomain.com/foo/123, thanks to deep linking you now skip over the list part of navigation.
So the user's browser hits:
http://example.org/#/foos/1
namespace TestinNancyWithOwinTesting
{
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Testing;
using Owin;
using Microsoft.Owin.Testing;
var fs = require('fs'),
path = require('path'),
Promise = require('rsvp').Promise,
request = require('request'),
files = [
'https://www.google.com/images/srpr/logo11w.png',
'http://rack.1.mshcdn.com/media/ZgkyMDEzLzA5LzE2L2JjL0Jpbmdsb2dvb3JhLmFkYjJkLnBuZwpwCXRodW1iCTEyMDB4OTYwMD4/996d9598/35b/Bing-logo-orange-RGB.png',
'http://assets.fontsinuse.com/static/use-media-items/15/14246/full-2048x768/52c4c6bc/Yahoo_Logo.png'
Create Function dbo.fn_ConvertCSVtoTable ( @input nvarchar(max), @token nchar(1))
Returns @Result Table
(ColumnValue nvarchar(max))
As
Begin
Declare @x XML
Select @x = CAST('<CSV>'+ REPLACE(@input, @token,'</CSV><CSV>')+ '</CSV>' AS XML)
Hello there Twitter person,
It seems you have a programming problem and you'd like some help. There's a number
of (mostly) friendly people around here who can help - but first you will need to
provide us with some code that repoduces your problem and upload it to a github
repository (www.github.com). That way, we can download it, test it and see what's
wrong.
Thank you!
static void Main(string[] args)
{
Console.Write("Hello World!!");
Method1("Hi", 123);
}
public static void Method1(string myString, int myInt)
{
Method2(myString); //myInt does not appear by R# as not used
}