Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Dispatcher;
<PropertyGroup>
<UseMsDeployExe>true</UseMsDeployExe>
</PropertyGroup>
<PropertyGroup>
<AfterAddIisSettingAndFileContentsToSourceManifest>AddCustomSkipRules</AfterAddIisSettingAndFileContentsToSourceManifest>
</PropertyGroup>
<Target Name="AddCustomSkipRules">
<ItemGroup>
<MsDeploySkipRules Include="SkipDownloadsFiles">
<div id="discourse-comments"></div>
<script type="text/javascript">
var discourseUrl = "http://discourse.yourdomain.com/", //root URL of your Discourse forum
discourseEmbedUrl = 'http://yourdomain.com/discourse-on-ghost.html'; //URL of your blog post
(function() {
var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
d.src = discourseUrl + 'javascripts/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
<!-- SEO rules (from: http://www.seomoz.org/blog/what-every-seo-should-know-about-iis#chaining) -->
<!-- SEO | Section 1 | Whitelist -->
<rule name="Whitelist - Resources" stopProcessing="true">
<match url="^(?:css/|scripts/|images/|install/|config/|umbraco/|umbraco_client/|base/|webresource\.axd|scriptresource\.axd|__browserLink|[^/]*/arterySignalR/.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
</rule>
<!-- SEO | Section 2 | Rewrites (chaining) -->
<rule name="SEO - Remove default.aspx" stopProcessing="false">
<match url="(.*?)/?default\.aspx$" />
public ActionResult DiscourseLogin()
{
if (string.IsNullOrEmpty(Request.QueryString["sso"]) || string.IsNullOrEmpty(Request.QueryString["sig"]))
return Content("Invalid");
string ssoSecret = "YOUR SSO SECRET"; //must match sso_secret in discourse settings
string sso = Request.QueryString["sso"];
string sig = Request.QueryString["sig"];
@matijagrcic
matijagrcic / EFDiagnostics.cs
Created April 1, 2014 12:03
Entity Framework Diagnostics Clutch
public static string TracePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
"Dummy.txt");
public static void WriteTrace(string trace)
{
using (StreamWriter file = new StreamWriter(TracePath, true))
{
file.WriteLine(trace);
}
}

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

<script src="http://www.polymer-project.org/platform.js"></script>
<link rel="import" href="http://www.polymer-project.org/components/polymer-jsonp/polymer-jsonp.html">
<link rel="import" href="http://www.polymer-project.org/components/google-map/google-map.html">
<polymer-element name="google-map-with-markers" extends="google-map" attributes="markers">
<template>
<style>
:host {
position: relative;
@matijagrcic
matijagrcic / GitlabPoshGitIssues.ps
Created April 8, 2014 09:38
Get open issues for specific project using Powershell and Gitlab
$url = 'http://gitlab.yoursite.com/api/v3/projects/:id/issues?private_token=XXXXX'
(Invoke-RestMethod $url) | Select-Object id, title, state, description | Format-Table –AutoSize
$url = 'http://gitlab.yoursite.com/api/v3/projects/:id/issues?private_token=XXXXX'
(Invoke-RestMethod $url) | Select-Object id, title, state, description | Sort-Object state | Format-Table –AutoSize
$url = 'http://gitlab.yoursite.com/api/v3/projects/:id/issues?private_token=XXXXX'
(Invoke-RestMethod $url) | Select-Object id, title, state, description | Where-Object {$_.state -eq 'closed'} | Format-Table –AutoSize
@matijagrcic
matijagrcic / Disable You need to format the disk in drive message.cmd
Created April 17, 2014 07:24
Use when you have a TrueCrypt disk and annoying message "You need to format the disk in drive" appears.
list disk
select disk #
list partition
select partition #
set id=64
exit