Skip to content

Instantly share code, notes, and snippets.

View adamralph's full-sized avatar
🤗
Living the dream

Adam Ralph adamralph

🤗
Living the dream
View GitHub Profile
@markrendle
markrendle / CorsModule.cs
Last active May 28, 2017 07:38
Very basic CORS HttpModule
using System;
using System.Web;
namespace MyOtherSite
{
public class CorsModule : IHttpModule
{
public void Init(HttpApplication application)
{
application.BeginRequest += ApplicationOnBeginRequest;

String interpolation

var x = 1;

// same as string.Format("A {0} B", x) 
var y1 = $"A {x} B"; // y == "A 1 B"

// $@ for multiline
var y2 = $@"A
@bitbonk
bitbonk / Program.cs
Last active September 29, 2017 21:13
Host ScriptCs in a console application and install a script pack at startup
namespace ConsoleHostedScriptCs
{
using System;
using Common.Logging.Simple;
using NuGet;
using ScriptCs.Contracts;
using ScriptCs.Engine.Roslyn;
using ScriptCs.Hosting;
using PackageReference = ScriptCs.PackageReference;
@bradwilson
bradwilson / colors.ps1
Last active December 7, 2017 12:30
Custom Posh-Git prompt
# Background colors
$GitPromptSettings.AfterBackgroundColor = "DarkBlue"
$GitPromptSettings.AfterStashBackgroundColor = $GitPromptSettings.AfterBackgroundColor
$GitPromptSettings.BeforeBackgroundColor = $GitPromptSettings.AfterBackgroundColor
$GitPromptSettings.BeforeIndexBackgroundColor = $GitPromptSettings.AfterBackgroundColor
$GitPromptSettings.BeforeStashBackgroundColor = $GitPromptSettings.AfterBackgroundColor
$GitPromptSettings.BranchAheadStatusBackgroundColor = $GitPromptSettings.AfterBackgroundColor
$GitPromptSettings.BranchBackgroundColor = $GitPromptSettings.AfterBackgroundColor
$GitPromptSettings.BranchBehindAndAheadStatusBackgroundColor = $GitPromptSettings.AfterBackgroundColor
$GitPromptSettings.BranchBehindStatusBackgroundColor = $GitPromptSettings.AfterBackgroundColor
@damianh
damianh / Rename-Project.psm1
Last active May 25, 2018 23:10
Renames a csproj - Project Name, DirectoryName, AssemblyName and references to the project
# Works for me. You may need to tweak it. Stick it in your powershell profile FTW
function Rename-Project
{
# designed to run from the solution directory where the project is a child directory
param(
[string]$projectName=$(throw "projectName required."),
[string]$newProjectName=$(throw "newProjectName required.")
)
@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
[AttributeUsage(System.AttributeTargets.All, AllowMultiple = true, Inherited = true)]
public class ಠ_ಠAttribute : Attribute
{
public ILog Log { get; set; }
public ಠ_ಠAttribute()
{
Log.Info("This code is bad and you should feel bad");
}
}
@tvjames
tvjames / Vagrantfile
Last active August 11, 2022 14:27
Prepare a Windows Server 2008 R2 instance for use with vagrant-windows.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
namespace WebSocket
// Appache 2.0 license
// References:
// [1] Proposed WebSockets Spec December 2011 http://tools.ietf.org/html/rfc6455
// [2] John McCutchan (Google Dart Team Member) http://www.altdevblogaday.com/2012/01/23/writing-your-own-websocket-server/
// [3] A pretty good Python implemenation by mrrrgn https://github.com/mrrrgn/websocket-data-frame-encoder-decoder/blob/master/frame.py
// [4] WebSockets Organising body http://www.websocket.org/echo.html
// [5] AndrewNewcomb's Gist (starting point) https://gist.github.com/AndrewNewcomb/711664
@beevelop
beevelop / gitprint.js
Created April 11, 2017 10:31
Print GitHub markdown files
document.querySelector('#readme').setAttribute('style', 'position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 100; background-color: white')
document.querySelector('body').appendChild(document.querySelector('#readme'))
window.print()