Skip to content

Instantly share code, notes, and snippets.

🤹‍♂

Chris F Carroll chrisfcarroll

🤹‍♂
Block or report user

Report or block chrisfcarroll

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chrisfcarroll
chrisfcarroll / AutoHotKey for a Mac User with an Apple keyboard on Windows.ahk
Last active Jul 13, 2019
AutoHotKey script for they who, being Mac Users with an Apple keyboard, yet still insist on using Windows. Also some arrange-windows-on-a-big-screen keys . Takes a similar approach as Parallels to keyboard mapping: rather than a wholesale swap of Cmd <-> Ctrl, instead duplicate favourite ctrl-key shortcuts to the Cmd key. For the big screen: som…
View AutoHotKey for a Mac User with an Apple keyboard on Windows.ahk
; Language: English
; https://gist.github.com/chrisfcarroll/dddf32fea1f29e75f564
;
; Uses unicode. Save this file as utf-8 with BOM.
; Else it shall not work.
;
#NoEnv ; Recommended
;SendMode Input ; Recommended
SendMode Event
SetWorkingDir %userprofile% ; Ensures a consistent starting directory.
@chrisfcarroll
chrisfcarroll / tmMakeImage
Last active May 6, 2019
A commandline script for MacOS, to create a TimeMachine Backup Volume on a non-Apple formatted disk
View tmMakeImage
#!/bin/bash
# 2015 Updates to sunkid's script. chrisfcarroll
# - added more quote marks to cope with e.g. spaces in volume names.
# - get machine UUID from ioreg instead of parsing and system report.
# - added steps to tell Time Machine to use your new backup drive.
# - renamed.
# Make it executable with e.g. chmod a+x tmMakeImage && mv tmMakeImage /usr/local/bin.
#
# A bash script to create a time machine disk image suitable for
# backups with OS X 10.6 (Snow Leopard) and later.
@chrisfcarroll
chrisfcarroll / Uninstall-Programs-Or-Features.ps1
Last active Apr 30, 2019
PowerShell commandline Uninstall-Programs-Or-Features.ps1
View Uninstall-Programs-Or-Features.ps1
<#
.SYNOPSIS
Uninstall one or more Windows Program or Feature, by name or regular expression.
.DESCRIPTION
Lists Programs And Features installed on the current machine which match
the -matchingName parameter and then, after force or confirmation, uninstalls them.
Examples
@chrisfcarroll
chrisfcarroll / force-integrated-graphics.sh
Created Dec 31, 2018
force-integrated-graphics.sh for MacBook 17" 2010–2011 With Broken Radeon graphics chip
View force-integrated-graphics.sh
#! /bin/sh
kextoffdir="/kextoff"
loginhookscript="/Library/LoginHook/LoadDelayedAMDRadeonX3000kext.sh"
echo "---------------------------------------------------------------
Run this script twice.
First, from a Recovery Mode commandline to run csrutil disable.
Second, after rebooting to a Single user mode commandline, with / partition mounted writeable, to do all the things that must be done with csrutil status= disabled
@chrisfcarroll
chrisfcarroll / LogAssert.cs
Last active Nov 29, 2018
Runtime Assertion, Log.Assert, TryLog, TryElse methods
View LogAssert.cs
public static class LogAssert
{
public static void Assert(this ILogger logger, Func<bool> assertion, string failureMessage = "Try failed", LogEventLevel level = LogEventLevel.Debug, string successMessage=null, IEnumerable args = null)
{
try
{
var ok = assertion();
if (ok && successMessage!=null) { logger.Write(level, successMessage, args ?? new object[0]); }
if (!ok) { logger.Write(level, failureMessage, args ?? new object[0]); }
@chrisfcarroll
chrisfcarroll / WebClientBaseAndWrapper.cs
Last active Nov 15, 2018
.Net WebClientBase, WebClientWrapper and WebClientFake for a testable System.Net.WebClient
View WebClientBaseAndWrapper.cs
public abstract class WebClientBase : IDisposable
{
WebHeaderCollection headers = new WebHeaderCollection();
public abstract void UploadValuesAsync(Uri address, string method, NameValueCollection data);
public abstract void UploadValuesAsync(Uri address, string method, NameValueCollection data, object userToken);
public abstract byte[] UploadData(Uri address, string method, byte[] data);
public abstract byte[] UploadFile(Uri address, string method, string fileName);
public abstract byte[] UploadValues(Uri address, string method, NameValueCollection data);
@chrisfcarroll
chrisfcarroll / HtmlPartialSection.cs
Last active Nov 6, 2018
Razor sections for Partials. Html.PartialSection() and Html.RenderPartialSection() offer sections accessible to partial pages, with optional de-duplication.
View HtmlPartialSection.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
namespace Helpers
{
/// <summary>Create or Render a <see cref="Helpers.PartialSection"/>s via the current <see cref="HtmlHelper"/></summary>
@chrisfcarroll
chrisfcarroll / DeSerializeExcludingFieldsContractResolver.cs
Last active Nov 5, 2018
ContractResolvers for Newtonsoft.Json which can ignore fields either by predicate or by name
View DeSerializeExcludingFieldsContractResolver.cs
using System;
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
public class DeSerializeExcludingFieldsContractResolver : DefaultContractResolver
{
readonly Type type;
readonly Predicate<JsonProperty> ignoreProperty;
@chrisfcarroll
chrisfcarroll / StringMaskedExtension.cs
Last active Nov 5, 2018
String.Masked() extension method
View StringMaskedExtension.cs
public static class StringExtensions
{
/// <summary>
/// Overwrite the right-most fraction 1/<paramref name="maskFractionOneOver"/> of <paramref name="str"/> with <paramref name="maskCharacter"/>
/// </summary>
/// <param name="str"></param>
/// <param name="maskFractionOneOver"></param>
/// <param name="maskCharacter"></param>
/// <example>"1234".Masked() => "123*"</example>
/// <returns>the masked string</returns>
View trello-wrap-n-stack-to-fit.user.js
// ==UserScript==
// @name Trello Wrap-n-Stack-To-Fit
// @namespace http://tampermonkey.net/
// @version 0.73
// @description Trello: Auto-wrap, stack and resize your Trello lists so they don't go offscreen. And kill that horizontal scroll-bar.
// @author chrisfcarroll
// @match https://trello.com/*
// @grant none
// ==/UserScript==
// jshint -W097
You can’t perform that action at this time.