Skip to content

Instantly share code, notes, and snippets.

package main
import (
"io"
"reflect"
"runtime"
"testing"
)
func main() {

Keybase proof

I hereby claim:

  • I am nearlyunique on github.
  • I am adam_straughan (https://keybase.io/adam_straughan) on keybase.
  • I have a public key ASBygT5WYpAMo80InUjs77Z0Ln6i9craODoU2JBbKo1TQAo

To claim this, I am signing this object:

using System;
using System.Collections;
using System.Reflection;
namespace play {
public class Program {
public static void Main() {
TestRunner.Run(new Program());
Console.Read();
}
@NearlyUnique
NearlyUnique / PoorMansTests.cs
Created April 4, 2017 10:33
For use in glot.io if required
using System;
using System.Reflection;
namespace testing {
public static class TestRunner{
public static void Run(object target){
var mi = target.GetType().GetMethods(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.DeclaredOnly);
int passed=0,failed=0;
foreach(var m in mi){
var argCount = m.GetParameters().Length;
@rem List aws instaces in all regions
@echo off
for /F "tokens=*" %%a in ('aws ec2 describe-regions --profile=%1^|jq .Regions[].RegionName -r') do (
echo # Region:%%a
aws ec2 describe-instances --region=%%a --profile=%1 | jq ".Reservations[].Instances[]|.InstanceId+\" \"+.State.Name" -r
)
@NearlyUnique
NearlyUnique / iisexpress-verbs.ps1
Created July 15, 2016 14:14
Adds the PUT and DELETE verbs to iis express (or vsual studio version)
param (
[switch]$vs
)
$path = "$env:UserProfile\Documents\IISExpress\config\applicationhost.config"
if ($vs) {
if (!(test-path .vs)) {
"Not in solution directory! no '.vs' directory"
exit(1)
}
@NearlyUnique
NearlyUnique / Configurator.cs
Last active March 1, 2016 12:12
A wrapper around various configuration sources
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text.RegularExpressions;
namespace namespace NearlyUnique.Config
{
/// <summary>
/// A wrapper for multiple configuration sources
@NearlyUnique
NearlyUnique / sublime log formatter
Last active August 29, 2015 14:07
in "%APPDATA%\Sublime Text 2\Packages\Log", add 2 files
md "%APPDATA%\Sublime Text 2\Packages\Log"
pushd "%APPDATA%\Sublime Text 2\Packages\Log"
copy con LogSyntax.json
// [PackageDev] target_format: plist, ext: tmLanguage
{
"name": "Log File",
"scopeName": "logfile",
"fileTypes": ["log"],
"uuid": "58e4042d-72b2-4281-92f7-7bb0c38dba44",
@NearlyUnique
NearlyUnique / findObject.js
Last active August 29, 2015 14:05
find({abc:1,def:{ghi:"hi"}}, “ghi”) // finds the full object path to "def.ghi"
/*global console*/
function find(target, searchFor, path) {
"use strict";
try {
path = path || "";
var i, attr, attrs = Object.keys(target);
searchFor = searchFor.toLowerCase();
for (i = 0; i < attrs.length; i += 1) {
attr = attrs[i];
if (attr.toLowerCase().indexOf(searchFor) >= 0) {
@NearlyUnique
NearlyUnique / mongoQueryDate.js
Created August 14, 2014 13:21
create an ISODate for mongo queries, usage aDate : { $gt:queryDate({hour:-4}), $lt:queryDate() }
var queryDate = function (diff) {
var d = new Date(), p = function(num){return num<10?"0"+num:num+"";};
diff = diff || {};
d.setUTCFullYear(d.getUTCFullYear() + (diff.year||0));
d.setUTCMonth(d.getUTCMonth() + (diff.month||0));
d.setUTCDate(d.getUTCDate() + (diff.day||0));
d.setUTCHours(d.getUTCHours() + (diff.hour||0));
d.setUTCMinutes(d.getUTCMinutes() + (diff.min||0));
return ISODate(d.getUTCFullYear() + "-" +
p(d.getUTCMonth()+1) + "-" +