Skip to content

Instantly share code, notes, and snippets.

View lucasteles's full-sized avatar
:shipit:
Ship it!

Lucas Teles lucasteles

:shipit:
Ship it!
View GitHub Profile
@lucasteles
lucasteles / CpuDiagnoser.cs
Created April 13, 2022 14:30 — forked from MarkPflug/CpuDiagnoser.cs
BenchmarkDotNet CPU utilization
using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Loggers;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Validators;
@lucasteles
lucasteles / renew-gpgkey.md
Last active October 5, 2021 21:24 — forked from krisleech/renew-gpgkey.md
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

(*
WHAT'S GOING ON HERE?!
Sometimes you don't care about a particular type, you're interested in one field only, let's say `EntityId`.
Instead of using interface (which isn't even possible if don't own a type),
we can do structural typing in F# using SRTP and Active Patterns.
Active patterns are not required for this, but they do make code much easier to use.
*)
// So we have 2 types with field `EntityId: string`:
@lucasteles
lucasteles / ObjectSpread.cs
Created March 13, 2019 23:21 — forked from AlbertoMonteiro/ObjectSpread.cs
Spread object in C#
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
namespace Playground
{
public class Program
@lucasteles
lucasteles / RunLength.cs
Last active November 2, 2018 01:28 — forked from WennderSantos/RunLength.cs
RunLength. O(n)
using static System.Console;
using System.Linq;
public static class Program {
public static void Main(string[] args)
{
var input = "wwwwaaadexxxxxxywww";
WriteLine(input);
@lucasteles
lucasteles / IsAValidPosition.cs
Last active November 1, 2018 19:21 — forked from WennderSantos/IsAValidPosition.cs
Check if a position is inside the bounds of a rectangle. O(1)
using static System.Console;
public class Rectangle
{
public Rectangle(int width, int heigth, (int x, int y) lowestPosition)
{
Width = width;
Heigth = heigth;
LowestPosition = lowestPosition;
}
@lucasteles
lucasteles / Dapper.fs
Created August 13, 2018 03:14 — forked from vbfox/Dapper.fs
Minimal dapper in F#
module DapperFSharp =
open System.Data.SqlClient
open System.Dynamic
open System.Collections.Generic
open Dapper
let dapperQuery<'Result> (query:string) (connection:SqlConnection) =
connection.Query<'Result>(query)
let dapperParametrizedQuery<'Result> (query:string) (param:obj) (connection:SqlConnection) : 'Result seq =
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
public static class TaskTupleExtensions
{
#region (Task<T1>)
public static TaskAwaiter<T1> GetAwaiter<T1>(this ValueTuple<Task<T1>> tasks)
{
@lucasteles
lucasteles / AzCopyEmu.bat
Created October 26, 2017 16:52 — forked from anonymous/AzCopyEmu.bat
Copy files to azure emulator
azcopy /Source:%cd% /Dest:http://127.0.0.1:10000/devstoreaccount1/%1/ /DestType:blob /DestKey:Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== /Pattern:%2 /Y
@lucasteles
lucasteles / quake.fsx
Created March 23, 2017 00:38 — forked from lucascebertin/quake.fsx
F# - Quake log parser
open System
open System.Data
open System.IO
open System.Text.RegularExpressions
type DeathTypes =
| MOD_UNKNOWN=1 | MOD_SHOTGUN=2 | MOD_GAUNTLET=3 | MOD_MACHINEGUN=4
| MOD_GRENADE_SPLASH=5 | MOD_ROCKET=6 | MOD_ROCKET_SPLASH=7 | MOD_PLASMA=8
| MOD_PLASMA_SPLASH=9 | MOD_RAILGUN=10 | MOD_LIGHTNING=11 | MOD_BFG=12
| MOD_BFG_SPLASH=13 | MOD_WATER=14 | MOD_SLIME=15 | MOD_LAVA=16