Skip to content

Instantly share code, notes, and snippets.

@SLaks
SLaks / Importer.cs
Created Aug 2, 2021
ShulCloud Import Script
View Importer.cs
// 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 Jul 12, 2021
Export services from Castlight
View Console script.js
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 Jan 5, 2021
Console Snippets to manipulate YouTube Music playlists in bulk
View Snippets.js
// 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'));
View gist:e43f3d534e6f0171d99f
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 Aug 29, 2015
Stack trace for settings sync error
View gist:2e12bd5871c66e417579
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 Aug 29, 2015
LINQ Y Combinator
View 1st YCombinate.cs
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) {
View Output
MoveNext: True
MoveNext: False
MoveNext: True
MoveNext: False
@SLaks
SLaks / gist:acbf0addcfe07d65ab19
Created Oct 29, 2014
Internal Roslyn Exports
View gist:acbf0addcfe07d65ab19
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 Oct 28, 2014
Creates a shim to make an object implement a compatible interface
View ReflectionUtils.cs
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);
View gist:9bf269354c15a9516471
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.