Skip to content

Instantly share code, notes, and snippets.

View paulodiogo's full-sized avatar
:octocat:

NO NO NO paulodiogo

:octocat:
View GitHub Profile
@paulodiogo
paulodiogo / Download.cs
Created June 13, 2022 15:11
Progress while downloading a large file with HttpClient https://github.com/dotnet/runtime/issues/16681
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, <URL>) { };
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStreamAsync();
var response = await webDavClient.GetProcessedFile(uri, new GetFileParameters { CancellationToken = cancellationTokenSource.Token });
var size = response.ContentLength();
var destination = new MemoryStream();
byte[] buffer = new byte[bufferSize];
int read;
long totalRead = 0;
while ((read = await response.Stream.ReadAsync(buffer, 0, buffer.Length, cancellationTokenSource.Token)) != 0)
@paulodiogo
paulodiogo / migrate.xslt
Created June 4, 2021 02:49
Migrating from MvcSiteMapProvider to cloudscribe.Web.Navigation
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" doctype-public="XSLT-compat" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
@paulodiogo
paulodiogo / medirtempo.cpp
Last active April 1, 2021 18:39
Medição de tempo em C++
#include <sys/time.h>
struct timespec begin;
clock_gettime(CLOCK_MONOTONIC, &begin);
{
//RODAR METODO AQUI
}
struct timespec end;
clock_gettime(CLOCK_MONOTONIC, &end);
@paulodiogo
paulodiogo / redirect.cpp
Created December 4, 2020 00:46
Redirect input and output to files
//include
#include <bits/stdc++.h>
//configure
ifstream cin("input.txt");
ofstream cout("output.txt");
//Use cin and cout normally:
cin >> N;
@paulodiogo
paulodiogo / node-sass-install.mdf
Created December 3, 2020 14:28
Install node-sass locally
Download the binary from https://github.com/sass/node-sass/releases
Choose your node version build!
Open CMD:
> export SASS_BINARY_PATH=<BINARY FILE PATH>
> npm install node-sass
@paulodiogo
paulodiogo / Main.md
Last active November 1, 2020 14:41
Xamarin + HNibernate + Mono.Data.Sqlite.Portable

Packages:

FluentNHibernate

Mono.Data.Sqlite.Portable

NHibernate

Fluently.Configure()
import pandas as pd
import math
df = pd.read_excel("tabela3218.xlsx")
DADOS = {}
COLUNA1 = []
COLUNA2 = []
protected void MaskedOnKeyUp(object sender, KeyEventArgs e)
{
textBox.Text = Mascara(textBox.Text, "#.##0,00");
textBox.Select(textBox.Text.Length, 0);
}
static string Mascara(string valor, string mascara)
{
var translations = new Dictionary<char, Tuple<string, bool>>
{
@paulodiogo
paulodiogo / build.md
Last active October 31, 2019 15:45
BUILD bootstrap