This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let date = new Date(); | |
let today = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); | |
console.log(today.toISOString()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let date = new Date(); | |
let today = ("0" + date.getDate()).slice(-2) + "/" + ("0"+(date.getMonth()+1)).slice(-2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
private static readonly HttpClient _httpClient = new HttpClient(); | |
static void Main(string[] args) | |
{ | |
var url = ""; | |
byte[] fileBytes = null; | |
var httpMessage = new HttpRequestMessage(HttpMethod.Get, url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static TextFieldParser GetTextFieldParser(string source) | |
{ | |
if (!source.IsUrl()) | |
return new TextFieldParser(source); | |
var file = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "files", $"{DateTime.Now:yyyyMMddHHmmssfff}", Path.GetFileName(source)); | |
var path = Path.GetDirectoryName(file); | |
if (!Directory.Exists(path)) | |
Directory.CreateDirectory(path); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XmlSerializer serializer = new XmlSerializer(typeof(MetadataFile)); | |
MemoryStream memoryStream = new MemoryStream(); | |
//Configuration remove tag omit-xml-declaration | |
XmlWriterSettings settings = new XmlWriterSettings(); | |
settings.OmitXmlDeclaration = true; | |
XmlWriter writer = XmlWriter.Create(memoryStream, settings); | |
//Remove namespace | |
StringWriter stringWriter = new StringWriter(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.ServiceBus.Messaging; | |
using System; | |
using System.Configuration; | |
namespace RecoverDeadLetterQueuesGeneric | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void RenameToken(JToken token, string newName) | |
{ | |
var parent = token.Parent; | |
if (parent == null) | |
throw new InvalidOperationException("The parent is missing."); | |
var newToken = new JProperty(newName, token); | |
parent.Replace(newToken); | |
} | |
JToken cpf = serializedCustomer["documents"]?["cpf"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var content = "{ \"name\": \"Leandro Grando\" }"; | |
// Remove all spaces and new lines from object | |
var spacelessContent = Regex.Replace(content, @"\s+", string.Empty); | |
// Minify json string | |
var minifiedJson = Regex.Replace(content, "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); | |
// Negate regex - not tested in c# | |
var negated = ^((?!gmail.com).)*$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<system.webServer> | |
<security> | |
<requestFiltering> | |
<requestLimits maxAllowedContentLength="1073741824" /> | |
</requestFiltering> | |
</security> | |
</system.webServer> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class JTokenExtensions | |
{ | |
private JToken LookupPreviousData(string value, JToken resourceToken) | |
{ | |
if (!resourceToken.HasValues) | |
return null; | |
if (!Regex.Match(value, ProjectionMatch).Success) | |
return null; |
NewerOlder