Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Celso Jr celsojr

🏠
Working from home
View GitHub Profile
@celsojr
celsojr / Factorial.cs
Last active Jul 30, 2021
Factorial operation with csharp 8 in a functional style (no Tail Call, no TCO)
View Factorial.cs
using System;
using static System.Console;
namespace Snippets
{
static class Program
{
static void Main()
{
static long Fact(long x)
@celsojr
celsojr / Await.cs
Last active Aug 5, 2021
Simple custom awaiter
View Await.cs
using System;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
static class Program
{
static async Task Main()
{
Console.WriteLine("One second pls...");
@celsojr
celsojr / App.cs
Last active Aug 8, 2021
Small experiment with the parallel programming model and the thread-safe collection BlockingCollection
View App.cs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
@celsojr
celsojr / CK62 Layers.AHK
Last active Aug 8, 2020
Customize the CK62 keyboard. More infos here: https://www.youtube.com/watch?v=cWivLDI0DnU
View CK62 Layers.AHK
SetCapsLockState, AlwaysOff
CapsLock & /::Up
CapsLock & SC15D::Down
CapsLock & SC138::Left
CapsLock & SC11D::Right
CapsLock & l::Home
CapsLock & .::End
CapsLock & ,::Delete
CapsLock & `;::PgUp
CapsLock & '::PgDn
View carousel.scss
@celsojr
celsojr / BeginSecureTransaction.snippet
Last active May 8, 2020
Begin secure transaction with MSSMS
View BeginSecureTransaction.snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<_locDefinition xmlns="urn:locstudio">
<_locDefault _loc="locNone"/>
<_locTag _loc="locData">Title</_locTag>
<_locTag _loc="locData">Description</_locTag>
<_locTag _loc="locData">Author</_locTag>
<_locTag _loc="locData">ToolTip</_locTag>
</_locDefinition>
<CodeSnippet Format="1.0.0">
@celsojr
celsojr / RestoreDatabase.snippet
Last active May 8, 2020
Database restoration snippet for MSSMS
View RestoreDatabase.snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<_locDefinition xmlns="urn:locstudio">
<_locDefault _loc="locNone"/>
<_locTag _loc="locData">Title</_locTag>
<_locTag _loc="locData">Description</_locTag>
<_locTag _loc="locData">Author</_locTag>
<_locTag _loc="locData">ToolTip</_locTag>
</_locDefinition>
<CodeSnippet Format="1.0.0">
View UndoAction.cs
// POST api/v1/author/{authorId}/undo
/// <summary>
/// Undo a deleted action on Author
/// </summary>
/// <remarks>Undo a deleted action on Author</remarks>
/// <param name="authorId"></param>
[HttpPost("{authorId:length(24)}/undo", Name = nameof(UndoDeletedAuthor))]
[ProducesResponseType(StatusCodes.Status410Gone)]
[ProducesResponseType(StatusCodes.Status201Created)]
public async Task<IActionResult> UndoDeletedAuthor(string authorId)
View HttpDelete.cs
// DELETE api/v1/author/{authorId}
/// <summary>
/// Deletes an Author
/// </summary>
/// <remarks>Deletes an Author</remarks>
/// <param name="authorId"></param>
[HttpDelete("{authorId:length(24)}", Name = nameof(DeleteAuthor))]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(DeleteModel<>), StatusCodes.Status200OK)]
public async Task<IActionResult> DeleteAuthor(string authorId)
@celsojr
celsojr / JsonFromQuery.sql
Last active Jun 11, 2020
Generating a Json file from a SQL query
View JsonFromQuery.sql
DECLARE @Participantes TABLE
(
Numero INT
)
INSERT INTO @Participantes VALUES (1), (2), (3)
DECLARE @RESPONSAVEL_TECNICO INT = 1
DECLARE @TRUE INT = 1
DECLARE @PRINCIPAL INT = 1