Skip to content

Instantly share code, notes, and snippets.

View AlbertoMonteiro's full-sized avatar
😎
Writting every day lines fo happy code

Alberto Monteiro AlbertoMonteiro

😎
Writting every day lines fo happy code
View GitHub Profile
@AlbertoMonteiro
AlbertoMonteiro / IgnoreCertificate.cs
Last active June 19, 2017 12:09
Ignorar certificado no WebClient (IgnoreCertificate)
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
@AlbertoMonteiro
AlbertoMonteiro / Windows Context Menus.reg
Last active November 8, 2015 16:18
Set of Windows Context Menu helpers
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\vs14cmd]
@="Visual Studio 2015 Command Line"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\vs14cmd\command]
@="cmd.exe /s /k pushd \"%V\" && call \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsDevCmd.bat\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\vs14cmd]
@="Visual Studio 2015 Command Line"
@AlbertoMonteiro
AlbertoMonteiro / Program.cs
Last active October 16, 2015 03:24
Vai que é tua
using System;
using System.Collections.Generic;
using System.Linq;
namespace MegaLinqTeste
{
class Program
{
static void Main(string[] args)
{
@AlbertoMonteiro
AlbertoMonteiro / FileSize.cs
Last active June 4, 2020 14:44
FileSize em C# e JavaScript
public static class LongExtensions
{
private static readonly string[] Sizes = { "bytes", "KB", "MB", "GB", "TB" };
public static string ToFileSize(this long? bytesSize) => bytesSize.HasValue ? ToFileSize(bytesSize.Value) : "0 bytes";
public static string ToFileSize(this long bytesSize) => SizeWithMaxSize.TakeWhile(e => bytesSize >= e.Item2).Select(size=> $"{bytesSize / size.Item2:0.#} {size.Item1}").Last();
private static IEnumerable<Tuple<string, double>> SizeWithMaxSize => Sizes.Select((s, i) => new Tuple<string, double>(s, Pow(1024, i)));
}
Microsoft (R) VersÆo do Mecanismo de Compila‡Æo 4.0.30319.34209
[Microsoft .NET Framework, VersÆo 4.0.30319.34209]
Copyright (C) Microsoft Corporation. Todos os direitos reservados.
Restoring NuGet packages...
Todos os pacotes listados em packages.config j  estÆo instalados.
Todos os pacotes listados em packages.config j  estÆo instalados.
EntityFramework -> D:\Projetos\entityframework\bin\ReleaseNet40\EntityFramework.dll
Restaurando pacotes NuGet ...
Para evitar que o NuGet baixe pacotes durante a constru‡Æo, abra a caixa de di logo Op‡äes do Visual Studio, clique no n¢ Gerenciador de Pacotes e desmarque a op‡Æo 'Allow NuGet to download missing packages'.
@AlbertoMonteiro
AlbertoMonteiro / gist:d45e0e5cbd8c6c1d8ee2
Created May 19, 2015 21:26
Todas modificações entre dois commits
https://github.com/fortesinformatica/FortesConecta/compare/commit1~..commit2
@AlbertoMonteiro
AlbertoMonteiro / LambdaInJS.js
Created May 13, 2015 21:03
C# Lambda in Javascript
String.prototype.toFunc = function() {
var parts = this.split("=>");
var args = parts[0];
var body = parts[1];
var argsList = args.replace(/[()]/gi, "").split(",");
return new Function(argsList, "return " + body)
};
@AlbertoMonteiro
AlbertoMonteiro / DispatchUtility.cs
Created March 12, 2015 14:06
DispatchUtility.cs
public static class DispatchUtility
{
private const int S_OK = 0; //From WinError.h
private const int LOCALE_SYSTEM_DEFAULT = 2 << 10; //From WinNT.h == 2048 == 0x800
public static bool ImplementsIDispatch(object obj)
{
bool result = obj is IDispatchInfo;
return result;
}