Skip to content

Instantly share code, notes, and snippets.

@SLaks
SLaks / Importer.cs
Created August 2, 2021 20:13
ShulCloud Import Script
// Run this in LINQPad, and add a reference to my https://github.com/ShomreiTorah/Libraries/tree/master/ShomreiTorah.Common
const string domain = "<TODO: insert domain here>";
static readonly Regex parseId = new Regex(@"action=edit_addresses&id=(\d+)");
static readonly Regex findSccsrf = new Regex(@"<input type=""hidden"" name=""sccsrf"" value=""(\w+)""/>");
bool dryRun = false;
async Task Main() {
var cookies = new CookieContainer();
@SLaks
SLaks / Console script.js
Last active July 12, 2021 23:09
Export services from Castlight
copy(await (async () => {
var lastId = localStorage.SLaks___lastExportedId || /* Paste the last ID from the spreadsheet here: */ "";
function takeWhile(cb) {
let found = false;
return x => {
if (found) return false;
if (cb(x)) return true;
found = true;
return true;
}
@SLaks
SLaks / Snippets.js
Created January 5, 2021 18:19
Console Snippets to manipulate YouTube Music playlists in bulk
// First, load jQuery:
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
////////////////////////////////////////////////////////////////////////////
// Remove all disliked songs:
for (const el of $('ytmusic-responsive-list-item-renderer:has([like-status="DISLIKE"])').get()) {
el.dispatchEvent(new MouseEvent('contextmenu'));
@SLaks
SLaks / gist:e43f3d534e6f0171d99f
Created March 20, 2015 03:01
Roslyn Debugger Error
Error Evaluation of method System.Collections.Immutable.ImmutableHashSetDebuggerProxy`1[Microsoft.VisualStudio.Composition.RuntimeComposition+RuntimePart].get_Contents() requires use of the static field System.Collections.Immutable.AllocFreeConcurrentStack`1[System.Collections.Immutable.SecurePooledObject`1[System.Collections.Generic.Stack`1[System.Collections.Immutable.RefAsValueType`1[System.Collections.Immutable.SortedInt32KeyNode`1[System.Collections.Immutable.ImmutableHashSet`1+HashBucket[Microsoft.VisualStudio.Composition.RuntimeComposition+RuntimePart]]]]]].stack, which is not available in this context.
@SLaks
SLaks / gist:2e12bd5871c66e417579
Last active August 29, 2015 14:16
Stack trace for settings sync error
System.ArgumentException: The string is empty.
Parameter name: prefix
> Microsoft.Internal.VisualStudio.Shell.Validate.IsNotEmpty(string s, string paramName) Unknown
Microsoft.VisualStudio.Services.Settings.DiskStringStorage.NamesStartingWithInternal(string prefix) Unknown
Microsoft.VisualStudio.Services.Settings.DiskStringStorage.LogExceptions<T>(string name, System.Func<string, T> func, Microsoft.VisualStudio.Settings.Telemetry.SettingScenario scenario, Microsoft.VisualStudio.Settings.Telemetry.SettingAction action, T defaultValue) Unknown
Microsoft.VisualStudio.Services.Settings.DiskStringStorage.NamesStartingWith(string prefix) Unknown
Microsoft.VisualStudio.Services.Settings.DelegatingStringStorage.NamesStartingWith.AnonymousMethod__1(Microsoft.VisualStudio.Settings.IStringStorage v) Unknown
System.Linq.Enumerable.<SelectManyIterator>d__8<TSource, TResult>.MoveNext() Unknown
@SLaks
SLaks / 1st YCombinate.cs
Last active August 29, 2015 14:13
LINQ Y Combinator
static void Main() {
var fibonacci = from fib in YCombinate<ulong, ulong>.Definition
select n => n < 2 ? 1 : fib(n - 1) + fib(n - 2);
Console.WriteLine(fibonacci(5));
}
delegate TDelegate Recursive<TDelegate>(TDelegate r);
static class YCombinate<TArg, TReturn> {
public static class Definition {
public static Func<TArg, TReturn> Select(Recursive<Func<TArg, TReturn>> definition) {
MoveNext: True
MoveNext: False
MoveNext: True
MoveNext: False
@SLaks
SLaks / gist:acbf0addcfe07d65ab19
Created October 29, 2014 13:55
Internal Roslyn Exports
Microsoft.CodeAnalysis.Editor.CSharp.EventHookup.IHACK_EventHookupDismissalOnBufferChangePreventerService Microsoft.CodeAnalysis.CSharp.EditorFeatures
Microsoft.CodeAnalysis.Editor.ISignatureHelpProvider Microsoft.CodeAnalysis.EditorFeatures
Microsoft.CodeAnalysis.Editor.IQuickInfoProvider Microsoft.CodeAnalysis.EditorFeatures
Microsoft.CodeAnalysis.Editor.IHighlighter Microsoft.CodeAnalysis.EditorFeatures
Microsoft.CodeAnalysis.Editor.ICommandHandler Microsoft.CodeAnalysis.EditorFeatures
Microsoft.CodeAnalysis.Editor.IBraceMatcher Microsoft.CodeAnalysis.EditorFeatures
Microsoft.CodeAnalysis.Editor.ITextBufferAssociatedViewService Microsoft.CodeAnalysis.EditorFeatures
Microsoft.CodeAnalysis.Editor.ITodoListProvider Microsoft.CodeAnalysis.EditorFeatures
Microsoft.CodeAnalysis.Editor.IPreviewFactoryService Microsoft.CodeAnalysis.EditorFeatures
Microsoft.CodeAnalysis.Editor.Implementation.Outlining.OutliningTaggerProvider Microsoft.CodeAnalysis.EditorFeatures
@SLaks
SLaks / ReflectionUtils.cs
Created October 28, 2014 02:58
Creates a shim to make an object implement a compatible interface
using System;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using Sigil.NonGeneric;
namespace VSThemeBrowser.VisualStudio {
static class ReflectionUtils {
static readonly AssemblyBuilder assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("RoslynETAHost"), AssemblyBuilderAccess.Run);
static readonly ModuleBuilder module = assembly.DefineDynamicModule(assembly.GetName().Name);
InvalidOperationException, no message, apparently because m_value.CastToReferenceValue() returned null.
> Microsoft.VisualStudio.VIL.Host.dll!Microsoft.VisualStudio.VIL.DebuggerHost.MemoryManager2.VirtualAddress2.WriteReference(Ilrun.Slot value) Unknown
Microsoft.VisualStudio.VIL.Host.dll!Microsoft.VisualStudio.VIL.VisualStudioHost.InspectionFrame.SetVariableValue(Microsoft.VisualStudio.VIL.DebuggerHost.CorValue lVal, Ilrun.Slot rVal) Unknown
Microsoft.VisualStudio.VIL.Host.dll!Microsoft.VisualStudio.VIL.VisualStudioHost.InspectionFrame.SaveModifiedVariables() Unknown
Microsoft.VisualStudio.VIL.Host.dll!Microsoft.VisualStudio.VIL.VisualStudioHost.Interpreter.InterpretInspectionQuery(Microsoft.VisualStudio.Debugger.Evaluation.DkmInspectionContext inspectionContext, Microsoft.VisualStudio.Debugger.CallStack.DkmStackWalkFrame frame, Microsoft.VisualStudio.Debugger.Metadata.Assembly queryAssembly, string expression, string queryClassName, string queryMethodName, Microsoft.VisualStudio.VIL.VisualStudioHost.