Skip to content

Instantly share code, notes, and snippets.

View niki-timofe's full-sized avatar

Никита Тимофеев niki-timofe

  • Russia, St. Petersburg
  • 00:46 (UTC +03:00)
View GitHub Profile
@niki-timofe
niki-timofe / ObjectIdGuidExtensions.cs
Last active March 13, 2024 18:55
Convert GUID to ObjectID
public static class ObjectIdGuidExtensions
{
private const byte TimeBasedGuidVersion = 1;
private static readonly DateTimeOffset UuidEpoch = new(1582, 10, 15, 0, 0, 0, TimeSpan.Zero);
public static Guid ToGuid(this string objId)
{
var oIdSpan = new ReadOnlySpan<byte>(Convert.FromHexString(objId));
var timestamp = BinaryPrimitives.ReadUInt32BigEndian(oIdSpan[..4]);
const factorial = f => n => n === 0 ? 1 : n * f(n - 1);
const fibonacci = f => n => n < 2 ? n : f(n - 1) + f(n - 2);
const Y = f => (g => g(g))(g => (f)(x => g(g)(x)));
Y(factorial)(5);
Y(fibonacci)(5);
@niki-timofe
niki-timofe / lbcMonitor.js
Last active December 14, 2017 23:48
App for LocalBitcoins.net
const crypto = require('crypto');
const request = require('request');
const hmacKey = '';
const hmacSecret = '';
const since = new Date('2017-12-07');
const bankFilter = bn =>
bn.includes('люб') ||