Skip to content

Instantly share code, notes, and snippets.

Samo Prelog m0sa

Block or report user

Report or block m0sa

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am m0sa on github.
  • I am m0sa (https://keybase.io/m0sa) on keybase.
  • I have a public key ASAavKcbBv6nHLYVkk6S6ok_cEEKg0TWjww4sulsl1EfzAo

To claim this, I am signing this object:

@m0sa
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
m0sa / readme.md
Created Dec 4, 2015
SourceFrom file size Encoding inconsitency
View readme.md
  • 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
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">
<NuGetReference>Microsoft.AspNet.Mvc</NuGetReference>
<NuGetReference>Microsoft.CodeAnalysis.CSharp</NuGetReference>
<Namespace>System.CodeDom.Compiler</Namespace>
<Namespace>System.Web.Razor</Namespace>
<Namespace>System.Web.WebPages.Razor</Namespace>
<Namespace>Microsoft.CodeAnalysis</Namespace>
<Namespace>Microsoft.CodeAnalysis.CSharp</Namespace>
<Namespace>Microsoft.CodeAnalysis.Emit</Namespace>
<Namespace>Microsoft.CodeAnalysis.Text</Namespace>
@m0sa
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 http://m0sa.net/
// @version 1.1
// @description authuser=1
// @author m0sa
// @include https://plus.google.com/hangouts/_/stackoverflow.com/*
// @include https://hangouts.google.com/hangouts/_/stackoverflow.com/*
// @grant none
// ==/UserScript==
View protobuf-codedom-vs-roslyn.linq
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.IO.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Reflection.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Runtime.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Text.Encoding.dll</Reference>
<Reference>&lt;RuntimeDirectory&gt;\System.Threading.Tasks.dll</Reference>
<NuGetReference Prerelease="true">Microsoft.CodeAnalysis</NuGetReference>
<NuGetReference Prerelease="true">Microsoft.CodeAnalysis.Common</NuGetReference>
<NuGetReference Prerelease="true">Microsoft.CodeAnalysis.CSharp</NuGetReference>
<NuGetReference>protobuf-net</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
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
m0sa / ZeroMQ-XPUB.py
Created Apr 3, 2012
Example of the ZeroMQ XPUB socket, that shows how the producer can be controlled by the number of subscribers
View ZeroMQ-XPUB.py
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
You can’t perform that action at this time.