Skip to content

Instantly share code, notes, and snippets.


Samo Prelog m0sa

View GitHub Profile
m0sa /
Created May 4, 2017 10:52

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 April 8, 2016 15:18 — 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 December 4, 2015 09:03
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 October 19, 2015 08:23
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 June 8, 2016 08:13
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==
m0sa / protobuf-codedom-vs-roslyn.linq
Last active August 29, 2015 14:10
Roslyn vs CodeDom IL
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>
m0sa / Program.Original.cs
Created November 2, 2014 00:25
Walk the #line
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 September 27, 2012 18:46
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 April 3, 2012 22:32
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