Skip to content

Instantly share code, notes, and snippets.

View chrisfcarroll's full-sized avatar
🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼

Chris F Carroll chrisfcarroll

🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼
View GitHub Profile
~/Software/Clojure/pallet-crate-tomcat7-demo]lein run
16:35:14.723 [main] DEBUG pallet.compute.jclouds - extensions (:slf4j :sshj)
16:35:14.734 [main] DEBUG pallet.compute.jclouds - options []
16:35:17.279 [main] DEBUG pallet.core - pallet version: 0.7.2
16:35:17.290 [main] INFO pallet.core - retrieving nodes
16:35:23.639 [main] INFO pallet.core - lift-nodes phases [:destroy-server], groups []
Exception in thread "main" java.lang.NumberFormatException: Invalid number: 09
at clojure.lang.LispReader.readNumber(LispReader.java:253)
at clojure.lang.LispReader.read(LispReader.java:171)
at clojure.lang.RT.readString(RT.java:1707)
@chrisfcarroll
chrisfcarroll / gist:28fc739fb63d19f242d1
Created February 5, 2016 10:57
Stub or Mock, as far as possible, the Asp.Net MVC controller HttpContext and also System.Web.HttpContext.Current
public partial class HttpRequestOverridableWrapper : HttpRequestWrapper
{
readonly string appVirtualDir;
public HttpRequestOverridableWrapper(HttpRequest httpRequest, string appVirtualDir)
: base(httpRequest)
{
this.appVirtualDir = appVirtualDir;
}
public override string ApplicationPath { get { return appVirtualDir; } }
@chrisfcarroll
chrisfcarroll / QUnitTestIf.cshtml
Last active February 14, 2016 18:54
An Asp.Net MVC PartialView for in-browser page testing. Makes it possible to test complex UIs and widgets 'in situ' but with zero client-side pageweight in production.
@model IEnumerable<string>
@if (Request.IsLocal
&& ( Request.QueryString["test"]!=null
||
Request.QueryString.ToString().Split('&').Any(k=>k.Equals("test",StringComparison.InvariantCultureIgnoreCase))
))
{
<div id="unit-tests">
<script src='~/scripts/qunit-1.20.0.js'></script>
@chrisfcarroll
chrisfcarroll / Cacher.cs
Last active February 19, 2016 11:02
A simple memoizer backed by System.Runtime.Caching.MemoryCache.Default
using System;
using System.Reflection;
using System.Runtime.Caching;
/// <summary>Memoize the results of method calls.</summary>
class Cacher
{
public readonly string UniqueName;
public readonly int CacheTimeSeconds;
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>title</title></head><body>Here</body></html>
@chrisfcarroll
chrisfcarroll / youtube-dl-prompt.ps1
Created July 8, 2017 10:19
Youtube Downloader Prompting Wrapper : wraps youtube-dl.exe for a start-menu icon that prompts for the url to download.
param( [Parameter(Mandatory=$true)][string]$UrlToDownload )
$downloadDirectory="C:\Users\Services\Downloads"
cd $downloadDirectory
write-host ""
write-host ""
write-host "Downloading $urlToDownload to $downloadDirectory ..."
write-host ""
write-host ""
$Error.Clear()
youtube-dl.exe $urlToDownload
@chrisfcarroll
chrisfcarroll / Curl.ps1
Last active September 12, 2017 12:20
PowerShell wrapper for Invoke-WebRequest with Proxy
#
$env:Proxy="http://YOUR-CORPORATE-PROXY-HERE" ;
Add-Type -AssemblyName 'Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
function curl
{
param(
[Parameter(Mandatory=$true)][string]$Uri,
[Object]$Body,
[String]$ContentType,
[PSCredential]$Credential,
@chrisfcarroll
chrisfcarroll / karabiner.json
Last active September 21, 2017 13:14
Windows on Mac : Just the main Windows Ctrl-keystroke -> Cmd-keystroke mappings. Using Karabiner.
{
"profiles": [
{
"complex_modifications": {
"parameters": { /* ... etc ... */ },
"README": "********************************************************************************************************",
"README": "*" COPY JUST THE ELEMENTS OF THIS "rules" array into your profiles.complex_modifications.rules array. "*",
"README": "********************************************************************************************************",
"rules": [
@chrisfcarroll
chrisfcarroll / SerilogStringListSink.cs
Last active September 21, 2017 20:58
A StringList Sink for Serilog. Typical usage:
using System;
using System.Collections.Generic;
using System.IO;
using Serilog;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Formatting.Display;
@chrisfcarroll
chrisfcarroll / LoggingConfig.cs
Created November 9, 2017 11:45
Serilog Typical setup for Log to RollingFile from Config. with fallback
static class LoggingConfig
{
/// <summary>
/// After calling this method, use the logger with
/// <code>Log.Logger....</code>
/// e.g.
/// <see cref="Log.Logger"/>.<see cref="ILogger.Debug(string,object[])"/>
/// </summary>
public static ILogger RegisterLogger(ILogger overrideLogger=null)
{