Skip to content

Instantly share code, notes, and snippets.

View AlexZeitler's full-sized avatar
👷‍♂️
Building stuff

Alexander Zeitler AlexZeitler

👷‍♂️
Building stuff
View GitHub Profile
@mattdot
mattdot / gist:1086078
Created July 16, 2011 06:39
WCF Web API: Extension methods for requesting a response in JSON, and for setting Basic auth headers
public static class HttpClientExtensionMethods
{
public static void SetBasicAuth(this HttpClient httpClient, string userName, string password)
{
var byteArray = Encoding.ASCII.GetBytes(userName + ":" + password);
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
}
public static void AcceptJson(this HttpClient httpClient)
{
@pmhsfelix
pmhsfelix / gist:1140101
Created August 11, 2011 16:32
Operation URI resolution
[ServiceContract]
class TheResolverTestService
{
[WebGet(UriTemplate="op1/{prm1}/{prm2}")]
public void Oper1(string prm1, int prm2)
{
}
[WebGet(UriTemplate = "op2/{prm1}/middle/{prm2}")]
[OperationContract(Name="op2")]
@darkiri
darkiri / gist:2039990
Created March 14, 2012 22:17
is there a method which returns all .net base types/structs that System.Convert is able to convert to/from?
typeof (Convert)
.GetMethods(BindingFlags.Static|BindingFlags.Public)
.Where(m=>m.Name.StartsWith("To"))
.Select(m=>m.GetParameters().First().ParameterType)
.Distinct()
@tony4d
tony4d / p4merge4git.md
Created August 24, 2012 19:00
Setup p4merge as a visual diff and merge tool for git
@benfoster
benfoster / gist:3655639
Created September 6, 2012 12:15
Consuming my ASP.NET Web API client
static void Main(string[] args)
{
var configuration = ClientConfiguration.Initialize(configure =>
{
configure.WithApiKey("1234-5678");
configure.WithBaseUri("http://localhost.fiddler:64511");
configure.WithSiteId(1);
});
var pages = configuration.GetPagesClient();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Raven.Client.Document;
namespace OurNamespace
{
public sealed class RavenStore :IDisposable
{
@michaelcox
michaelcox / SpecRunner.js
Last active January 11, 2024 06:05
Browser Unit Testing with Backbone Mocha Chai and RequireJS
require.config({
baseUrl: '/backbone-tests/',
paths: {
'jquery' : '/app/libs/jquery',
'underscore' : '/app/libs/underscore',
'backbone' : '/app/libs/backbone',
'mocha' : 'libs/mocha',
'chai' : 'libs/chai',
'chai-jquery' : 'libs/chai-jquery',
'models' : '/app/models'
@jimothyGator
jimothyGator / README.md
Last active April 25, 2024 18:00
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@kagemusha
kagemusha / gist:5866759
Created June 26, 2013 11:37
Using Debugger with Grunt
version: grunt-cli v0.1.8
1. Install node-inspector globally (-g)
npm install -g node-inspector
2. Add debugger statements to your code
3. Run your grunt task in debug mode
@makomweb
makomweb / csharp_implicit_type_conversion.cs
Last active August 29, 2015 13:56
C# implicit type conversion (see http://msdn.microsoft.com/en-us/library/zk2z37d3.aspx for a more detailed explanation)
public class ImplicitConversionTest
{
public class A
{
public string Member { get; set; }
public static implicit operator string(A self)
{
return self.Member;
}