Skip to content

Instantly share code, notes, and snippets.

@uncas
uncas / journal.gs
Created January 4, 2020 13:48
Creates status mail from google spreadsheet
var _sendEmail = true;
function debugGoalStatus() {
_sendEmail = false;
sendGoalStatus();
}
function sendGoalStatus() {
// TODO: (Nice to have) Only send jubel-email if not already sent!
var events = getEvents();
@uncas
uncas / QueryStringRouting
Created October 8, 2014 11:26
QueryStringRouting
public class QueryStringRouting : RouteBase
{
public override RouteData GetRouteData(HttpContextBase httpContext)
{
NameValueCollection queryString = httpContext.Request.QueryString;
if (!string.IsNullOrWhiteSpace(queryString["bla"]))
{
//add your logic here based on querystring
var routeData = new RouteData(this, new MvcRouteHandler());
routeData.Values.Add("controller", "Home");
@uncas
uncas / gist:6513434
Created September 10, 2013 18:24
Determine whether email has gravatar or not by checking the length of the downloaded image (6951 equals the default image).
private static string GetGravatarUrl(
string email,
int size = 200,
string defaultPicture = null)
{
if (string.IsNullOrWhiteSpace(email))
return null;
byte[] b1 = Encoding.UTF8.GetBytes(email.Trim().ToLower());
var provider = new MD5CryptoServiceProvider();
byte[] hash = provider.ComputeHash(b1);
@uncas
uncas / git-conflicts.ps1
Created July 23, 2012 08:32
Extract stats of git merge conflicts.
$mergeIds = (git log --pretty=format:'%h' --merges)
$mergeCount = $mergeIds.count
$conflictCount = 0
$totalFileCount = 0
foreach ($mergeId in $mergeIds) {
$log = (git log $mergeId -n 1)
if ($log -contains " Conflicts:") {
$log
"Conflict: Yes"
$fileCount = $log.count - 8
@uncas
uncas / NuGetCopy.ps1
Created March 6, 2012 18:41
Copy nuget packages from 'packages' folder to local folder
# Input:
$inputFolder = "D:\Projects"
$destinationFolder = "D:\LocalNuGetFeed\"
if (!(Test-Path $destinationFolder))
{
mkdir $destinationFolder
}
$files = gci $inputFolder -recurse
$packages = $files | where {$_.extension -eq ".nupkg"}
@uncas
uncas / profile.ps1
Created February 28, 2012 09:28 — forked from markembling/profile.ps1
My preferred prompt for Powershell - includes git info.
# My preferred prompt for Powershell.
# Displays git branch (and stats) when inside a git repository.
# See http://gist.github.com/180853 for gitutils.ps1.
. (Resolve-Path D:/Users/ole/Documents/WindowsPowershell/gitutils.ps1)
function prompt {
$userLocation = $env:username + ' ' + $pwd
$host.UI.RawUi.WindowTitle = $userLocation
Write-Host($pwd) -nonewline -foregroundcolor Green
@uncas
uncas / gitutils.ps1
Created February 28, 2012 09:28 — forked from markembling/gitutils.ps1
Powershell functions for git information
# Git functions
# Mark Embling (http://www.markembling.info/)
# Is the current directory a git repository/working copy?
function isCurrentDirectoryGitRepository {
if ((Test-Path ".git") -eq $TRUE) {
return $TRUE
}
# Test within parent dirs