Skip to content

Instantly share code, notes, and snippets.

Avatar

Javier Lozano jglozano

View GitHub Profile
@jglozano
jglozano / AccessFilter.cs
Created Jan 21, 2022
Reading Body from HttpRequest
View AccessFilter.cs
// snippet around reading from HttpRequest.Body
var request = context.Request;
request.EnableBuffering();
// deserialize into temp structure using System.Text.Json.JsonSeralizer
var temp = await JsonSerializer.DeserializeAsync<RequestTemp>(request.Body,
options: new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
request.Body.Seek(0, SeekOrigin.Begin);
@jglozano
jglozano / TempFiles.sh
Created Oct 12, 2019
Git Refresh - Create Temp Files
View TempFiles.sh
for d in {1..6}; do touch "file${d}.md"; git add "file${d}.md"; git commit -m "adding file ${d}"; done
@jglozano
jglozano / git_lol_alias.md
Last active Aug 30, 2018
Git log oneline with a pretty graph
View git_lol_alias.md

The following alias, lol creates a clean, reable graph of the commits using the git log command as the base:

git config --global alias.lol 'log --oneline --graph --decorate --all'

@jglozano
jglozano / GetNextIdAsync.cs
Created Mar 2, 2018
Get Next ID from Sequence / StoredProc
View GetNextIdAsync.cs
public async Task<int> GetNextIdAsync()
{
using (var connection = GetDbConnection())
{
connection.Open();
var parameters = new DynamicParameters();
parameters.Add("@nextId", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
await connection.ExecuteAsync("[Schema].[sp_GetNextId]", parameters, commandType: CommandType.StoredProcedure).ConfigureAwait(false);
var result = parameters.Get<int>("@nextId");
@jglozano
jglozano / ConfigCorsPolicyProvider.cs
Created Feb 12, 2018
Configuration CORS Policy Provider
View ConfigCorsPolicyProvider.cs
public class ConfigCorsPolicyProvider : ICorsPolicyProvider
{
private readonly IConfigurationService configurationService;
public ConfigCorsPolicyProvider(IConfigurationService configurationService)
{
this.configurationService = configurationService;
}
public Task<CorsPolicy> GetCorsPolicyAsync(HttpRequestMessage request, CancellationToken cancellationToken)
View BrowserJsonFormatter.cs
public class BrowserJsonFormatter : JsonMediaTypeFormatter
{
public BrowserJsonFormatter()
{
SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
SerializerSettings.Formatting = Formatting.Indented;
}
public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, MediaTypeHeaderValue mediaType)
{
@jglozano
jglozano / beyond-compare-setup.md
Last active Feb 9, 2018
Beyond Compare Git Diff/Merge Setup
View beyond-compare-setup.md

Diff

git config --global diff.tool bc3 git config --global difftool.bc3.path "c:/Program Files/Beyond Compare 4/bcomp.exe"

3way Merge

git config --global merge.tool bc3 git config --global mergetool.bc3.path "c:/Program Files/Beyond Compare 4/bcomp.exe"

@jglozano
jglozano / .bash_profile
Last active Jan 27, 2021
bash profile that adds support for Git
View .bash_profile
# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
fi
View keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

View Luke.txt
In those days a decree went out from Caesar Augustus that the whole world should be enrolled. This was the first enrollment, when Quirinius was governor of Syria. So all went to be enrolled, each to his own town. And Joseph too went up from Galilee from the town of Nazareth to Judea, to the city of David that is called Bethlehem, because he was of the house and family of David, to be enrolled with Mary, his betrothed, who was with child. While they were there, the time came for her to have her child, and she gave birth to her firstborn son. She wrapped him in swaddling clothes and laid him in a manger, because there was no room for them in the inn. Now there were shepherds in that region living in the fields and keeping the night watch over their flock. The angel of the Lord appeared to them and the glory of the Lord shone around them, and they were struck with great fear. The angel said to them, “Do not be afraid; for behold, I proclaim to you good news of great joy that will be for all the people. For today