Skip to content

Instantly share code, notes, and snippets.

View lunrcore-query.cs
await foreach (Result result in idx.Search("love"))
{
// do something with that result
}
View lunrcore-index.cs
var index = await Index.Build(async builder =>
{
builder
.AddField("title")
.AddField("body")
await builder.Add(new Document
{
{ "title", "Twelfth-Night" },
{ "body", "If music be the food of love, play on: Give me excess of it…" },
View DictionaryEntryDeconstructor.cs
public static class Util
{
/// <summary>
/// An extension method that enables the deconstruction of dictionary entries.
/// </summary>
/// <example>
/// ```cs
/// foreach ((string key, Foo value) in someDictionaryOfFoos)
/// {
/// // Do something with `key` and `value`...
View tuple_sample5.cs
public void Deconstruct(out int x, out int y)
{
x = X;
y = Y;
}
View tuple_sample4.cs
(double x, double y) = GetMiddlePoint(point1, point2);
// Proceed to using the x and y coordinates of the center
View tuple_sample3.cs
Weave(new[] { 1, 2, 3 }, new[] { 4, 5, 6 }) -> [1, 4, 2, 5, 3, 6]
View tuple_sample2.cs
IEnumerable<T> Weave<T>(IEnumerable<T> first, IEnumerable<T> second)
=> first
.Zip(second, (a, b) => (a, b))
.SelectMany(pair => new[] { pair.a, pair.b });
View tuple_sample1.cs
(U, T) Swap<T, U>((T x, U y) pair) => (pair.y, pair.x);
View undefinedTrapBookmarklet.js
javascript: {
Object.defineProperty(Object.prototype, undefined, {
set: function(v) {
debugger;
}
})
};
void(0);
View bugFarm.js
let someProperty, someOtherProperty;
function setProperty(target, propertyName, value) {
target[propertyName] = value;
}
function getProperty(target, propertyName) {
return target[propertyName];
}