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 class AzureTableStorage<T> where T : TableEntity, IAzureStorageTable, new()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudTableClient tableClient;
CloudTable table;
public AzureTableStorage(string tableName)
{
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}");
}
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 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);
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)
{
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)
@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();
}
System.Net.ServicePointManager.SecurityProtocol =
SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 |
SecurityProtocolType.Tls12;
#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
}
public void Execute(IServiceProvider serviceProvider)
{
ITracingService tracer = (ITracingService) serviceProvider.GetService(typeof(ITracingService));
tracer.Trace("Traza que queremos dejar");
}