Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am m0sa on github.
  • I am m0sa ( on keybase.
  • I have a public key ASAavKcbBv6nHLYVkk6S6ok_cEEKg0TWjww4sulsl1EfzAo

To claim this, I am signing this object:

m0sa / mathjax-editing.js
Last active Apr 8, 2016 — forked from dpvc/mathjax-editing.js
StackExchange MathJax editing code
View mathjax-editing.js
// The MIT License (MIT)
// Copyright (c) 2016 Stack Exchange
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
m0sa /
Created Dec 4, 2015
SourceFrom file size Encoding inconsitency
  • install SourceLink (via run chocho install sourcelink) and be sure it's in your path
  • copy the test.csx to a solution where the 1.1.0 Microsoft.CodeAnalysis.CSharp package is installed
  • start the VS development console (msbuild has to be in the path), run csi test.csx

Example output:

v:\example> csi .\CompilationCrazy.csx

SourceLink 1.1.0

876aa6db6eb96d35bbdee9f1586d9f94ff90d928 v:\example\precompilation\obj\huge.cs

m0sa / StringBuilderInterpolationOptimizer.cs
Last active Oct 19, 2015
Roslyn Adventures: Optimizing StringBuilder string interpolation
View StringBuilderInterpolationOptimizer.cs
class StringBuilderInterpolationOptimizer : CSharpSyntaxRewriter
private readonly SemanticModel _model;
public StringBuilderInterpolationOptimizer(SemanticModel model)
_model = model;
// we use the semantic model to get the type information of the method being called
private static bool CanRewriteSymbol(SymbolInfo symbolInfo, out bool appendNewLine)
View roslyn-string-vs-stream-sourcetext.linq
<Query Kind="Program">
m0sa / so_hangouts_auth.user.js
Last active Jun 8, 2016
SO Hangouts Authuser Redirect
View so_hangouts_auth.user.js
// ==UserScript==
// @name SO Hangouts Authuser Redirect
// @namespace
// @version 1.1
// @description authuser=1
// @author m0sa
// @include*
// @include*
// @grant none
// ==/UserScript==
View protobuf-codedom-vs-roslyn.linq
<Query Kind="Program">
<NuGetReference Prerelease="true">Microsoft.CodeAnalysis</NuGetReference>
<NuGetReference Prerelease="true">Microsoft.CodeAnalysis.Common</NuGetReference>
<NuGetReference Prerelease="true">Microsoft.CodeAnalysis.CSharp</NuGetReference>
View Program.Original.cs
namespace ConsoleApplication1
class Program
static void Main(string[] args)
string foobar = _s("$foo$ bar", new { foo = Foo() }), baz = Baz();
static string Foo() { return "Foo"; }
m0sa / RssController.cs
Created Sep 27, 2012
Syndication of Google+ articles and notes to an RSS feed
View RssController.cs
// the controler:
public class RssController : Controller
private readonly IGoogleSettings _settings;
public RssController(IGoogleSettings settings)
_settings = settings;
m0sa /
Created Apr 3, 2012
Example of the ZeroMQ XPUB socket, that shows how the producer can be controlled by the number of subscribers
import thread
import time
import zmq
from zmq.core.socket import Socket
# global zmg context
context = zmq.Context()
endpoint = "tcp://*:8888"
# the subscriber thread function