Skip to content

Instantly share code, notes, and snippets.

Rhys Campbell RhysC

  • Perth; Australia
Block or report user

Report or block RhysC

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
RhysC /
Created Jul 29, 2018
Cron jobs in docker (using node base to show we can use that image)
docker build -f ./cron.docker --tag cronsample:local .
docker run -d cronsample:local --name cronsample_rhysc
# Wait a bit, a minute in fact
docker container cp cronsample_rhysc:/var/log/cron.log ./cron.log
cat ./cron.log
# Should see "Hello world" printed on a new line for every minute the container has been running
RhysC / generate_select.sql
Created Jul 6, 2017
Generate Select * (with column names defined ) in postgres
View generate_select.sql
SELECT 'SELECT ' || string_agg(column_name, ', ') || ' FROM ' || table_name
FROM information_schema.columns
WHERE table_schema='my_schema'
GROUP BY table_name
RhysC / ActiveDirectorySnippets.txt
Created Nov 17, 2016
Active directory snippets
View ActiveDirectorySnippets.txt
# opens a GUI to manage users under the given account - fine for adding/upodate one or two accounts
runas /user:myDomain\myusername "C:\Windows\System32\rundll32.exe dsquery, OpenQueryWindow"
##POWERSHELL – to load the users, done from a server so it has the AD PS modules
import-module activedirectory
# basic search using ps filters
Get-ADUser -filter {GivenName -like "rickie"}
RhysC / Calendar.html
Last active Nov 11, 2016
Schedule or calendar html page using Knockout bindings, vanilla js and bootstrap shell. View here
View Calendar.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Calendar Demo</title>
<!-- BEGIN CALENDAR CSS - ideally these would be in a separate file - eg /calendar-template.css -->
RhysC / CopyLibFilesAslinksToBgoToYour.Msbuild
Last active May 19, 2016
Getting pesky linked DLLs in to the bin dir without subfolders (MSBUILD in csproj files)
View CopyLibFilesAslinksToBgoToYour.Msbuild
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="">
<!-- pervious msbuild project cruft clipped this is just a .csproj-->
<Content Include="..\OtherProject\libs\**\*.dll">
<!-- copy after the build so i can have the dlls in a linked lib folder in the project bt in the root in bin -->
RhysC / IgnoreUntilFactAttribute.cs
Created Mar 18, 2016
Xunit skip/ignore until a given date
View IgnoreUntilFactAttribute.cs
//using System;
//using Xunit;
public class IgnoreUntilFactAttribute : FactAttribute
public int Year { get; set; }
public int Month { get; set; }
public int Day { get; set; }
public override string Skip
RhysC / Dispatch.cs
Created Jan 5, 2016
Execute/Dispatch/Call all available methods on the object that can handle the parameter
View Dispatch.cs
void Main()
new MyObject().Dispatch(new Bar());
Easy more specific target
Hitting the Bar
Fooing it up
Easy target
RhysC / BuildAllProjectsFromACleanState.ps1
Created Oct 30, 2015
Make sure that each project can be built from a clean state (ie no rouge dlls from previous builds)
View BuildAllProjectsFromACleanState.ps1
$ErrorActionPreference = "Stop"
function cleanBin {
param ([string]$path)
write-host "Cleaning bin from: $path"
get-childitem $path -include bin -recurse | remove-item -force -confirm:$false -recurse
write-host "Cleaning obj from: $path"
get-childitem $path -include obj -recurse | remove-item -force -confirm:$false -recurse
RhysC / Guard.cs
Created Sep 3, 2015
Showing a proposed use of Guard with expression for static checks and correct name evaluation in exception messages
View Guard.cs
public static class Guard
public static void NotNull<T>(Expression<Func<T>> notNullableExpression) where T : class
var compliedExpression = notNullableExpression.Compile();
if (compliedExpression() == null)
var paramName = notNullableExpression.GetObjectNameGraph();
throw new ArgumentNullException(paramName);
RhysC / search-files.ps1
Last active Aug 29, 2015
Recursive file search
View search-files.ps1
function search-files {
param ( [string]$fileFilter,
$PathArray = @()
Get-ChildItem -Filter $fileFilter -Recurse |
Where-Object { $_.Attributes -ne "Directory"} |
ForEach-Object {
If (Get-Content $_.FullName | Select-String -Pattern $text) {
$PathArray += $_.FullName
You can’t perform that action at this time.