Skip to content

Instantly share code, notes, and snippets.

View jaywick's full-sized avatar

Jay Wick jaywick

View GitHub Profile
@jaywick
jaywick / singleton-csharp-snippet.cs
Last active December 26, 2015 02:59
Simple C# singleton pattern snippet
class MyClass
{
#region Singleton Access
private static readonly Lazy<Singleton> instance = new Lazy<Singleton>(() => new Singleton());
public static Singleton Instance
{
get { return instance.Value; }
}
@jaywick
jaywick / launch-unity.ahk
Last active August 29, 2015 14:00
Launch Unity from Visual Studio
IfWinExist, ahk_class UnityContainerWndClass
{
WinActivate
Send ^p ; sends Ctrl+P
}
else
{
MsgBox, 64, Unity is not open. Please open the project to run from Visual Studio.
}
@jaywick
jaywick / Program.cs
Created May 17, 2014 14:19
copy-as-path
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace copypath
{
static class Program
{
/// <summary>
@jaywick
jaywick / SafeEnumerateFiles.cs
Created August 31, 2014 09:27
Safe EnumerateFiles extension for DirectoryInfo without UnauthorizedAccessException
public static IEnumerable<FileInfo> SafeEnumerateFiles(this DirectoryInfo target, string pattern = "*.*")
{
var allFiles = Enumerable.Empty<FileInfo>();
var stack = new Stack<DirectoryInfo>();
stack.Push(target);
while (stack.Any())
{
var current = stack.Pop();
@jaywick
jaywick / my-apps.bat
Last active September 27, 2016 12:07
Choco installs of my favourite PC apps
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco feature enable --name=allowGlobalConfirmation
choco install dropbox
choco install 7zip
choco install autohotkey
choco install googlechrome
choco install vlc
choco install icofx
@jaywick
jaywick / clean-stackoverflow-2015.css
Created June 9, 2015 12:16
Cleaner StackOverflow Stylesheet for Stylish
.topbar { display: none; }
.community-bulletin { display: none; }
#hireme { display: none; }
#hot-network-questions {display:none;}
body {margin-top: 30px}
.tagged-ignored {display: none;}
pre
{
padding: 10px 15px;
border: rgb(207, 207, 207) solid 1px;
@jaywick
jaywick / app.gradle
Created June 21, 2015 11:29
Android Studio - Unit Testing - Gradle Files
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
compile(project(':lib'))
}
@jaywick
jaywick / MakeSafeFile.cs
Created June 30, 2015 05:26
Return file name safe from illegal file system characters
static string MakeSafeFileName(string name, char replaceChar = '_')
{
var temp = name;
foreach (var character in Path.GetInvalidFileNameChars().Concat(Path.GetInvalidPathChars()))
{
temp = temp.Replace(character, replaceChar);
}
return temp;
@jaywick
jaywick / OnEnterKeyListener.java
Created August 6, 2015 00:40
Android - Listen to Enter key down event on a View such as an EditText
package io.jaywick.android.helpers;
import android.view.KeyEvent;
import android.view.View;
public abstract class OnEnterKeyListener implements View.OnKeyListener
{
public abstract void onEnterKeyDown();
@Override
using System;
using System.Drawing;
using System.Windows.Forms;
/// WinForms trap app boilerplate
/// Full credit to @alanbondo:
/// https://alanbondo.wordpress.com/2008/06/22/creating-a-system-tray-app-with-c/
namespace TrayApp
{
public class App : Form