Skip to content

Instantly share code, notes, and snippets.

@SLaks
SLaks / SourceParser.cs
Created December 22, 2013 03:36
Parses PDBs from http://referencesource.microsoft.com/netframework.aspx and extracts source files to findable locations
//const string OriginalPath = @"C:\Users\SSL\Development\RefSrc\Source";
const string PDBPath = @"C:\Users\SSL\Development\Symbols\RefSrc\Symbols";
const string OriginalPath = @"C:\Users\SSL\Development\Symbols\RefSrc\Source\.NET 4.5\4.6.0.0";
const string TargetPath = @"C:\Users\SSL\Development\3rd-Party Source\Microsoft\.Net 4.5.1";
const string ErrorLog = TargetPath + @"\Errors.log";
static readonly Regex GoodLine = new Regex(@"^[a-zA-Z0-9\\:]{5}");
void Main() {
var pdbs = from file in Directory.EnumerateFiles(PDBPath, "*.pdb", SearchOption.AllDirectories)
group file by Path.GetFileName(file) into g
select g.OrderByDescending(p => new FileInfo(p).Length).First();
@SLaks
SLaks / DesignerThemeDictionary.cs
Created December 22, 2013 02:28
Trying to create a design-time ResourceDictionary of VS theme colors
using System;
using System.Collections;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.Internal.VisualStudio.PlatformUI;
using Microsoft.Internal.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Platform.WindowManagement;
using Microsoft.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Shell;
@SLaks
SLaks / Details.md
Last active December 31, 2015 14:28
Unreadable HTML properties
@SLaks
SLaks / Problems.md
Last active December 24, 2015 12:09
Failed attempts to provide IntelliSense for Node.js in Visual Studio.

This is a failed attempt to make require('./folder/file.js') return the exports object created by that file.

The problem is that the IntelliSense engine runs all imported files before running any user code, so I cannot create a personalized module object for each file separately. Creating a single global module object won't let me figure out what exports come from each module. (If it's possible to pass a parameter to another file, I could solve that)

if (pwd == 'correcthorsebatterystaple' || pwd == 'Tr0ub4dour&3' || pwd == 'Tr0ub4dor&3') { // easteregg
score = 0;
word = ['', 'lol']
if (pwd == 'correcthorsebatterystaple') {
// TRANSLATORS this text is displayed rarely, whenever a user selects a password that is from this comic:
// http://imgs.xkcd.com/comics/password_strength.png
bubble_text.update(_("Whoa there, don't take advice from a webcomic too literally ;)"))
} else {
// TRANSLATORS this text is displayed rarely, whenever a user selects a password that is from this comic:
// http://imgs.xkcd.com/comics/password_strength.png
@SLaks
SLaks / Bugs-1.js
Last active December 20, 2015 05:58
Interview Questions
function ajaxFindIndex(userIds, callback) {
for (var i = 0; i < userIds.length; i++) {
$.getJSON("http://some-api.com/get-user", { id: userIds[i] }, function (user) {
if (callback(user))
return i;
});
}
return -1;
}
@SLaks
SLaks / LogModule.cs
Created October 22, 2012 15:30 — forked from pawelpabich/LogModule.cs
Faster Log4Net and NLog modules for Autofac
using System;
using System.Linq;
using Autofac;
using Autofac.Core;
using NLog;
using log4net;
using LogManager = NLog.LogManager;
namespace AutofacIdea
{
@SLaks
SLaks / ExcelResult.cs
Created July 4, 2012 02:40
ExcelExporter.Mvc – A simple ActionResult for returning Excel files from ASP.Net MVC actions using ExcelExporter
using System;
using System.Collections.Generic;
using System.IO;
using System.Web.Mvc;
namespace ExcelExporter.Mvc {
///<summary>An ActionResult that sends an Excel spreadsheet to the client.</summary>
public class ExcelResult : FilePathResult {
static readonly Dictionary<ExcelFormat, string> ContentTypes = new Dictionary<ExcelFormat, string> {
{ ExcelFormat.Excel2003, "application/vnd.ms-excel" },
@SLaks
SLaks / gist:2418150
Created April 19, 2012 03:17
Reverse Indentation
//One style to revile them all...
function binarySearch(arr, ele)
{
var beginning = 0, end = arr.length, target;
while (true)
{
target = ((beginning + end) >> 1);
if ((target === end || target === beginning) && arr[target] !== ele)
{
return -1;
@SLaks
SLaks / gist:2037478
Created March 14, 2012 16:01
Evil Razor scoping trick
public delegate IDisposable ViewScope();
public static class Scope {
public static readonly ViewScope StateOfEvil = new object().EnterScope;
private static IDisposable EnterScope(this object id) {
HttpContext.Current.Items.Add(id, null);
return new Disposable(() => HttpContext.Current.Items.Remove(id));
}
}