Skip to content

Instantly share code, notes, and snippets.

rodrigoramirez93 / DatabaseContextHelper.cs
Last active May 9, 2020
Delete all data from every table in database except table "__EFMigrationsHistory"
View DatabaseContextHelper.cs
//this methods aims to be used on a testing database. It's extremely harmful, proceed with caution
public static class DatabaseContextHelper
public static readonly string DisableTablesConstraintsCommand = "EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' ";
public static readonly string DeleteAllTablesDataExceptMigrationsTableCommand = "EXEC sp_MSforeachtable 'if (\"?\" NOT IN (\"[dbo].[__EFMigrationsHistory]\")) DELETE FROM ?'";
public static readonly string EnableTablesConstraintsCommand = "EXEC sp_MSForEachTable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL'";
public static void DeleteAllDataExceptMigrations(this DbContext context)
rodrigoramirez93 / script.js
Last active May 9, 2020
Change color randomly in javascript
View script.js
//live example at:
var makeColors = () => {
var minNum = 0;
var maxNum = 9;
var minLet = 65;
var maxLet = 71;
function randomNumber() {
rodrigoramirez93 / Compare the triplets c#.cs
Created May 19, 2017
Compare the triplets @ HackerRank // C#
View Compare the triplets c#.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Solution
static int[] solve(int a0, int a1, int a2, int b0, int b1, int b2)
int[] tripletAlice = { a0, a1, a2 };
You can’t perform that action at this time.