Skip to content

Instantly share code, notes, and snippets.

View lanwin's full-sized avatar
🤡
-

Steve Wagner lanwin

🤡
-
View GitHub Profile
@lanwin
lanwin / gist:2948383
Created June 18, 2012 13:30
ASP.Net WebApi: Answer text/html requests with application/json
public class JsonWithHtmlMediaTypeFormatter : JsonMediaTypeFormatter
{
public JsonWithHtmlMediaTypeFormatter()
{
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
}
public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, string mediaType)
{
base.SetDefaultContentHeaders(type, headers, mediaType);
@lanwin
lanwin / objectdiff.cs
Created May 31, 2012 08:14
ObjectDiff to compare objects with checking if properties, fields, and arrays are the same
static class ObjectDiff
{
static IEnumerable<Member> GetMembers(object obj)
{
foreach(var propertyInfo in obj.GetType().GetProperties().Where(p => p.CanRead))
{
var info = propertyInfo;
yield return new Member
{
Name = info.Name,
@lanwin
lanwin / rabbit_based_message_bus.cs
Created February 14, 2012 08:30
This is an example how to use our Rabbit Service Bus.
/* Initialize bus. In this case via Autofac */
builder.RegisterModule(new RabbitModule
{
HostName = "localhost",
UserName = "user",
Password = string.Empty,
Exchanges = {
new Exchange("exchange1"){Durable=true;},
new Exchange("exchange2"){Durable=true;}
}
@lanwin
lanwin / add_users_to_projects.sh
Created February 2, 2012 08:41
Script to Automatically add all GitLab users to all projects
#!/bin/sh
baseurl=http://mygitlaburl
usermail=adminuser@mymailserver
userpass=adminpassword
repo_access=2 #0=denied 1=read 2=read&write
project_access=2 #0=deined 1=read 2=report 3=admin
# login
curl -s -I -c cookies.txt -d "utf8=✓&user[email]=$usermail&user[password]=$userpass&commit=Sign+in" $baseurl/users/sign_in
@lanwin
lanwin / functional-utils.js
Created September 29, 2015 14:30 — forked from bendc/functional-utils.js
A set of pure and immutable ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@lanwin
lanwin / gist:852890
Created March 3, 2011 15:06
Simply object extension with provides an maybe monad.
public static class ObjectExtensions
{
public static IEnumerable<T> ToMaybe<T>(this T obj)
{
return Equals(obj,null) ? Enumerable.Empty<T>() : new[] {obj};
}
}
@lanwin
lanwin / test.html
Created April 23, 2015 10:28
Endless XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set # 3
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
function onload(s) {
@lanwin
lanwin / example.html
Created April 20, 2015 11:51
Endless XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
function func() {
@lanwin
lanwin / designer.html
Last active August 29, 2015 14:18
designer
<link href="../core-icon-button/core-icon-button.html" rel="import">
<link href="../core-toolbar/core-toolbar.html" rel="import">
<link href="../core-header-panel/core-header-panel.html" rel="import">
<link href="../core-drawer-panel/core-drawer-panel.html" rel="import">
<link href="../core-menu/core-submenu.html" rel="import">
<link href="../core-item/core-item.html" rel="import">
<polymer-element name="my-element">
<template>
@lanwin
lanwin / gist:ad98f0b37222b4f08478
Created April 9, 2015 09:45
XMLHttpRequest leaves a tmp file for every request when responseType = 'blob' is set
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
for(var i=0;i<10;i++) {