Skip to content

Instantly share code, notes, and snippets.

@schacon
schacon / better-git-branch.sh
Created January 13, 2024 18:41
Better Git Branch output
#!/bin/bash
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NO_COLOR='\033[0m'
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@luidones
luidones / AddedOrSingleOrDefault.cs
Last active January 4, 2016 00:59
Extension method to check if the condition is satisfied first in the added but not commited items then in the database.
internal static T AddedOrSingleOrDefault<T>(this IDbSet<T> source, DbContext context, Func<T, bool> comparer)
where T : class
{
T result = null;
var entry = context.ChangeTracker.Entries<T>()
.SingleOrDefault(e => e.State == EntityState.Added && comparer(e.Entity));
if (entry != null)
result = entry.Entity;
@svetoslavovm
svetoslavovm / datediff.js
Created November 11, 2012 20:39 — forked from remino/datediff.js
JavaScript: DateDiff & DateMeasure: Calculate days, hours, minutes, seconds between two Dates
(function() {
function DateDiff(date1, date2) {
this.days = null;
this.hours = null;
this.minutes = null;
this.seconds = null;
this.date1 = date1;
this.date2 = date2;