Skip to content

Instantly share code, notes, and snippets.

View elusive's full-sized avatar
💭
Migrating from ng to react!

John Gilliland elusive

💭
Migrating from ng to react!
View GitHub Profile
@elusive
elusive / docker_stops.sh
Created August 7, 2016 22:28
Docker stop all and remove all (images and containers)
# stop all containers:
docker stop $(docker ps -q)
# remove all containers:
docker rm $(docker ps -a -q)
# remove all docker images:
docker rmi $(docker images -q)
@elusive
elusive / .gitconfig
Last active September 24, 2017 18:43
Add alias for formatted git log call
[filter "hawser"]
clean = git hawser clean %f
smudge = git hawser smudge %f
required = true
[user]
name = John Gilliland
email = [email protected]
[filter "lfs"]
process = git-lfs filter-process
clean = git-lfs clean -- %f
@elusive
elusive / EnumExtensions.cs
Last active May 23, 2018 12:21
Enum<T> Extensions
// From the OpenRA Game Engine I was reading the code and found this nice enum ext!
public static class Enum<T>
{
public static T Parse(string s) { return (T)Enum.Parse(typeof(T), s); }
public static T[] GetValues() { return (T[])Enum.GetValues(typeof(T)); }
public static bool TryParse(string s, bool ignoreCase, out T value)
{
// The string may be a comma delimited list of values
var names = ignoreCase ? Enum.GetNames(typeof(T)).Select(x => x.ToLowerInvariant()) : Enum.GetNames(typeof(T));
@elusive
elusive / file_renamer.py
Created May 11, 2019 05:08
Simple python script to rename a directory of files using regex pattern.
#!/usr/bin/env python
####################
# file_renamer.py
# [email protected]
#
import os, glob, re
@elusive
elusive / TaskExtensions.cs
Created January 4, 2021 14:54
Task extension methods for executing in series/sequence.
public static class TaskExtensions
{
/// <summary>
/// Executes the next task after the completion of the first.
/// </summary>
/// <param name="first">Currently executing task.</param>
/// <param name="next">Function returning the task to execute next.</param>
/// <returns>The next task instance.</returns>
public static Task Then(this Task first, Func<Task> next)
{
@elusive
elusive / ProcessStartInfoExtensions.cs
Created January 4, 2021 15:00
Extension methods and result class for executing at the command line from C#, with a timeout.
public static class ProcessStartInfoExtensions
{
public const int WaitForExitMilliseconds = 500;
/// <summary>
/// Starts a process with support for cancellation via the
/// provided token. Console output for the process is redirected
/// to the provided delegates.
/// </summary>
/// <param name="processStartInfo"><see cref="ProcessStartInfo" /> instance.</param>
@elusive
elusive / CleanupDotnet.ps
Created January 19, 2021 15:43
Cleanup Dotnet Project
Get-ChildItem .\ -include bin, obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
@elusive
elusive / simplehttp.py
Created February 18, 2021 19:53
Share files via HTTP
# in wsl use this:
python -m SimpleHTTPServer
# but in windows use this:
python -m http.server
@elusive
elusive / IgnoreFilesInExistingRepo.sh
Created April 2, 2021 17:29
Add to .gitignore and apply
git rm -r --cached .
git add .
git commit -m "updated .gitignore is now working"
#!/bin/bash
### Copy of https://gist.github.com/redthor/3776c1f726cafff41c9eda6f271466c3
### Adding in comments explaining each line/command in order to help learning
### Set DRY_RUN=1 to only echo the commands instead of executing them
#DRY_RUN=1