Skip to content

Instantly share code, notes, and snippets.

View akamud's full-sized avatar
👳‍♂️

Mahmoud Ali akamud

👳‍♂️
View GitHub Profile
@akamud
akamud / Chunk.cs
Created May 24, 2021 21:09
Código exemplificando o novo método Chunk do IEnumerable
using System;
using System.Collections.Generic;
using System.Linq;
var listaGrande = Enumerable.Range(1, 100);
foreach (var lote in listaGrande.Chunk(10))
{
// Cada lote aqui tem no máximo 10 itens
Acao(lote.ToList());
}
using System;
namespace Projeto
{
public class MinhaClasse
{
private Random _random;
public MinhaClasse()
{
@akamud
akamud / EndiannessAwareBinaryReader.cs
Last active November 20, 2021 00:54
C# BinaryReader aware of the machine's Endianness, using new BinaryPrimitives introduced in .NET Core 2.1+. Based on this answer from StackOverflow: https://stackoverflow.com/a/58341527/1710624
public class EndiannessAwareBinaryReader : BinaryReader
{
public enum Endianness
{
Little,
Big,
}
private readonly Endianness _endianness = Endianness.Little;
@akamud
akamud / http.cs
Last active June 16, 2020 02:46
System.Net.Http.Json
/** GET **/
// Jeito antigo
public async Task<Usuário> ObterUsuário(string uri)
=> JsonConvert.DeserializeObject<Usuário>(await httpClient.GetStringAsync(uri));
// Com System.Net.Http.Json
public async Task<Usuário> ObterUsuário(string uri)
=> await httpClient.GetFromJsonAsync<Usuário>(uri);
/** POST **/
@akamud
akamud / how-to.ps1
Created May 2, 2020 12:02 — forked from lucasteles/how-to.ps1
Rename all file names and replace all files content
# copy the replace-everything.ps1 to the folder
# run
.\replace-everything.ps1 -Folder . -FilePattern *.cs -TextToChange "from" -NewText "To"
@akamud
akamud / NovosLivros.tsv
Last active May 2, 2021 00:36
Novos Livros Lambda3
Livro Autor
Mastering Vim Quickly Jovica Ilic
Domain-Driven Design: Tackling Complexity in the Heart of Software Eric Evans
Building Microservices Sam Newman
Cracking the Coding Interview Gayle Laakmann McDowell
Art of Scalability: Scalable Web Architecture, Processes, and Organizations for the Modern Enterprise Martin L. Abbott, Michael T. Fisher
Building Microservices with ASP.NET Core: Develop, Test, and Deploy Cross-Platform Services in the Cloud Kevin Hoffman
Kotlin in Action Dmitry Jemerov, Svetlana Isakova
xUnit Test Patterns: Refactoring Test Code Gerard Meszaros
Reactive Design Patterns Roland Kuhn Dr., Brian Hanafee, Jamie Allen
@akamud
akamud / simulator.sh
Created August 1, 2019 22:34
Open your iOS simulator's data folder
open "`xcrun simctl get_app_container booted com.company.yourapp data`"
@akamud
akamud / .vsvimrc
Last active August 24, 2018 16:40
VsVim RC
set clipboard=unnamed
imap jj <ESC>
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
nnoremap <Leader>a :noh<CR>
nnoremap <Leader>c *Nciw
nnoremap <Leader>f :/\%<c-r>=line('.')<cr>l
nnoremap <CR> o<ESC>
@akamud
akamud / ColorExtensions.cs
Created March 17, 2018 16:45
Color extensions to fix iOS Color Space
public static class ColorExtensions
{
public static UIColor ToCorrectUIColor(this Color color)
{
return new UIColor(new CGColor(CGColorSpace.CreateSrgb(), new nfloat[] { (float)color.R, (float)color.G, (float)color.B, (float)color.A }));
}
public static CGColor ToCorrectCGColor(this Color color)
{
return new CGColor(CGColorSpace.CreateSrgb(), new nfloat[] { (float)color.R, (float)color.G, (float)color.B, (float)color.A });

Keybase proof

I hereby claim:

  • I am akamud on github.
  • I am akamud (https://keybase.io/akamud) on keybase.
  • I have a public key ASAD_Afzhz3Z7R0j1SSfF7BZuidUaGaAt6TMCoiX3jEAPwo

To claim this, I am signing this object: