Skip to content

Instantly share code, notes, and snippets.

View DaniCCardenas's full-sized avatar

Daniel Córdoba Cárdenas DaniCCardenas

View GitHub Profile
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracer = (ITracingService) serviceProvider.GetService(typeof(ITracingService));
tracer.Trace("Traza que queremos dejar");
}
#Source: https://stackoverflow.com/questions/52722373/create-database-and-collection-on-cosmos-db-sql-api-inside-azuredevopps-vsts
param($endpoint, $masterKey, $databaseName, $collectionName, $collectionRUs, $partitionKey)
Add-Type -AssemblyName System.Web
Add-Type -TypeDefinition @"
public enum CosmosResourceType
{
Database,
Collection
}
System.Net.ServicePointManager.SecurityProtocol =
SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls12;
@DaniCCardenas
DaniCCardenas / ProgramAsync.cs
Created November 6, 2018 10:22
Console app with async
using System.Threading.Tasks;
namespace ConsoleAsyncDemo
{
static class Program
{
static void Main(string[] args)
{
Main().Wait();
}
public class BulkUploadToSql<T>
{
public IList<T> InternalStore { get; set; }
public string TableName { get; set; }
public int CommitBatchSize { get; set; } = 1000;
public SqlConnection Connection { get; set; }
public async Task Commit()
{
if (InternalStore.Count > 0)
public static string GetCreateTableQuery<T>(IEnumerable<T> list, string tableName)
{
Type type = typeof(T);
var properties = type.GetProperties();
var query = new StringBuilder();
query.Append($"CREATE TABLE {tableName} (");
foreach (PropertyInfo info in properties)
{
static void EjemploRandom3()
{
for (int i = 0; i <= 10; i++)
{
var guid = Guid.NewGuid();
var justNumbers = new String(guid.ToString().Where(Char.IsDigit).ToArray());
var seed = int.Parse(justNumbers.Substring(0, 4));
var random = new Random(seed);
var value = random.Next(0, 5);
static void EjemploConTickCount()
{
var seed = Environment.TickCount;
var random = new Random(seed);
for (int i = 0; i <= 10; i++)
{
var value = random.Next(0, 5);
Console.WriteLine($"Iteración {i} - semilla {seed} - valor {value}");
}
static void EjemploRandom1()
{
for (int i = 0; i <= 10; i++)
{
var seed = Environment.TickCount;
var random = new Random(seed);
var value = random.Next(0, 5);
Console.WriteLine($"Iteración {i} - semilla {seed} - valor {value}");
}
public class AzureTableStorage<T> where T : TableEntity, IAzureStorageTable, new()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudTableClient tableClient;
CloudTable table;
public AzureTableStorage(string tableName)
{