Skip to content

Instantly share code, notes, and snippets.

View phillip-haydon's full-sized avatar
💭
Banana's are yellow.

Phillip Haydon phillip-haydon

💭
Banana's are yellow.
View GitHub Profile
@denisgolius
denisgolius / generate-ssh-key.sh
Created October 4, 2018 06:55 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@anvk
anvk / psql_useful_stat_queries.sql
Last active June 28, 2024 08:55
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@jchannon
jchannon / bootstrapper.cs
Last active August 31, 2017 01:11
This will handle Nancy content negotiation on errors so the client receives JSON, XML or HTML based on the client Accept headers
public class CustomBootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
pipelines.OnError += (ctx, exception) =>
{
ctx.Items.Add("OnErrorException", exception);
return null;
};
}
@grumpydev
grumpydev / Pluralizer.cs
Created April 19, 2013 14:34
Very simple pluralizer with the potential to handle multiple languages.
namespace ConsoleApplication2
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
/// <summary>
/// Simplistic pluraliser
/// </summary>
@benfoster
benfoster / gist:4474276
Created January 7, 2013 11:08
Inbound route testing with ASP.NET MVC
using NSubstitute;
using NUnit.Framework;
using System.Linq;
using System.Web;
using System.Web.Routing;
namespace Fabrik.Web.Hosted.Specs
{
[TestFixture]
public class InboundRouteTests
@thecodejunkie
thecodejunkie / gist:4415623
Last active December 10, 2015 09:38
Dynamic member resolution chaining
namespace DynamicMemberChaining
{
using System;
using System.Dynamic;
using Xunit;
public interface ITextResource
{
string this[string key] { get; }
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active June 28, 2024 08:56
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
[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");
}
}
results = RavenSession.Query<Suppliers_QueryIndex.ReduceResult, Suppliers_QueryIndex>()
.Where(x => x.LocationName == location)
.Search(x => x.Query, string.Join(" ", suggestions))
.Search(x => x.Query, term +"*")
.Take(5 - ravenResults.Count)
.As<Supplier>()
.ToList();
@aaronpowell
aaronpowell / License.md
Created May 16, 2012 07:18
A useful exception for when you don't want to implement a feature yourself

The MIT License

Copyright (c) 2012 Aaron Powell

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWA