Skip to content

Instantly share code, notes, and snippets.

@Grynn
Grynn / VBA functions for working with files
Created April 9, 2010 22:36
VBA functions for working with files
Option Explicit
Function FileDelete(Filename As String) As String
Dim fso As New FileSystemObject
On Error Resume Next
Err.Clear
Call fso.DeleteFile(Filename)
On Error GoTo 0
If Err.Number <> 0 Then
@Grynn
Grynn / LavaBlast.Linq.Extensions.cs
Created December 14, 2011 07:48 — forked from EtienneT/LavaBlast.Linq.Extensions.cs
Support Lambda functions in place of IEqualityComparer<T>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace System.Linq
{
public class KeyEqualityComparer<T> : IEqualityComparer<T>
{
private readonly Func<T, T, bool> comparer;
@Grynn
Grynn / RotHelper.cs
Created December 14, 2011 08:47
COM running object table utility class
/// <summary>
/// COM running object table utility class
/// </summary>
public static class ROTHelper
{
public static IDictionary<string, object> GetActiveObjects(string MonikerFilter)
{
var ret = new Dictionary<string, object>();
IRunningObjectTable pprot;
@Grynn
Grynn / reset_perms.bat
Created July 31, 2012 14:08
Reset Permissions on Folder Hierarchy in Windows
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET TGT=%1
SET TGT=%TGT:"=%
IF "%TGT%"=="" SET TGT=*
takeown /f "%TGT%" /R /D Y > nul
icacls "%TGT%" /reset /t /q
icacls "%TGT%" /grant %USERNAME%:F /t /q
attrib -r -h -s "%TGT%" /s /l /d
@Grynn
Grynn / ListDiff.cs
Created September 6, 2012 09:22 — forked from praeclarum/ListDiff.cs
Computes a diff between two different IEnumerables. It's better than anything you have ever seen. Ever.
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace TheBestAppEver
{
/// <summary>
/// The type of <see cref="ListDiffAction{S,D}"/>.
@Grynn
Grynn / SafeEnumerateDirectory
Last active October 12, 2015 04:38
SafeEnumerateDirectory
struct FileNode
{
public string Name;
public bool IsDirectory;
public Exception Error;
public bool HasError { get { return this.Error!=null; } }
}
void Main()
/*
jquery.draghover.js
Emulates draghover event by tracking
dragenter / dragleave events of element + children.
https://gist.github.com/gists/3794126
http://stackoverflow.com/a/10310815/4196
@Grynn
Grynn / .gitignore
Last active December 19, 2015 16:48 — forked from LeeFlannery/.gitignore
# Personal files
*.user
#dev.config
#connections.config
# Build results
[Dd]ebug/
[Rr]elease/
[Bb]in/
[Oo]bj/
@Grynn
Grynn / conv.sh
Created July 18, 2014 03:06
Convert (almost) any video file to streamable MP4 using ffmpeg...
#!/bin/bash
set -e
set -o pipefail
VERBOSE=
MAX_TIME_SECONDS=
function usage {
cat <<EOF
@Grynn
Grynn / realpath.cmd
Created September 13, 2014 11:40
Magic incantation to jump to the realpath of current dir... (windows 7+, needs PHP to be installed and in the path)
@for /f %%i in ('php -r "echo realpath(__DIR__);"') do pushd %%i