Skip to content

Instantly share code, notes, and snippets.

@teyc
teyc / CLibrary_Sample.cs
Created September 5, 2015 11:16
DotNet CoreCLR dnxcore50 on OS X console
namespace CLibrary
{
public class Sample
{
public string OperatingSystem
{
get
{
return "OS X";
}
@teyc
teyc / README.md
Last active September 9, 2015 11:17
How dnx compiles and loads assemblies

When dnx executes, it loads a list of IAssemblyLoaders, of which one is a ProjectAssemblyLoader

https://github.com/aspnet/dnx/blob/master/src/Microsoft.Dnx.Runtime/Loader/ProjectAssemblyLoader.cs

and the ProjectAssemblyLoader embeds an ICompilationEngine,

Dnx also includes a DesignTimeHost. https://github.com/aspnet/dnx/blob/master/src/Microsoft.Dnx.DesignTimeHost/Program.cs I'm not sure where this is used, but a DTH usually embeds a Roslyn compiler.

Update: See https://github.com/aspnet/dnx/commit/a3d1f0f29c1f4e49326cf66e330dc56cd0105576 where you can pass a command line option to ApplicationHost.cs to use an out of process DesignTimeHost compiler.

@teyc
teyc / PersistentRemoteWebDriver.cs
Last active September 17, 2015 04:42
A persistent web driver that keeps the browser open so that you can continue scripting from where you left off.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using OpenQA.Selenium.Remote;
namespace Readify.FunctionalTests.Selenium
{
/// <summary>
@teyc
teyc / WriteSeq.cs
Last active September 26, 2018 05:12
Pipes objects to Seq
// How to debug your powershell scripts by piping the intermediate results to Seq
// 1. Compile this into WriteSeq.dll
// 2. > Import-Module .\WriteSeq.dll
// 3. > Get-ChildItems C:\ | ? { $_.Name -ilike { "*Program*" } | Write-Seq | Format-Table
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management.Automation;
@teyc
teyc / retryJquery.js
Last active November 24, 2015 21:55
Doing retries with Promises
function retry(maxAttempts, millisecond, fn) {
var deferred = $.Deferred();
var attempts = 0;
function wait(milliseconds) {
var deferred = $.Deferred();
setTimeout(deferred.resolve, milliseconds);
return deferred.promise();
}
@teyc
teyc / ChuiTey.ps1
Last active December 2, 2015 05:07
Boxstarter for Windows 10 .Net Development Environment
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
# Timezone
& tzutil /s "E. Australia Standard Time"
# Development
mkdir C:\dev\projects -ErrorAction SilentlyContinue | Out-Null
mkdir C:\dev\toyapps -ErrorAction SilentlyContinue | Out-Null
mkdir C:\dev\readify -ErrorAction SilentlyContinue | Out-Null
@teyc
teyc / AttributedSettingKeyConvention.cs
Last active April 15, 2016 02:08
ConfigInjector - Dotted Nested Class
public class AttributedSettingKeyConvention : ISettingKeyConvention
{
public string KeyFor(Type settingType)
{
var attribute = (ConfigurationSettingAttribute) settingType.GetCustomAttributes(typeof(ConfigurationSettingAttribute), false).FirstOrDefault();
if (attribute != null)
{
return attribute.Key;
}
else
@teyc
teyc / README.md
Last active January 23, 2016 01:31
Angular.js testing on the command line

This is a basic worked example of how you can test angular applications that doesn't require a browser, just through a console.

Installation and configuration

C:\temp> npm install
C:\temp> mkdir spec\support
C:\temp> echo {} > spec\support\jasmine.json
@teyc
teyc / README.md
Last active February 27, 2016 10:02
Angular custom input controls

Angular custom input controls

This gist demonstrates how to create a custom control that plays nicely with angular forms.

The angular forms lifecycle consists of transforming models into viewmodels, watching UI for changes, and updating viewmodels, and finally transforming viewmodels back into models.

This example displays a view model value that's 10 more than the original model value. So if I provide 42, the view renders it as 52. But if I type 42, the viewmodel will be reverse transformed into 32.

@teyc
teyc / Firewall.sh
Last active March 26, 2016 09:42
Linux setup
sudo apt-get install ufw
sudo ufw disable
sudo ufw default deny
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable