Skip to content

Instantly share code, notes, and snippets.

View tawman's full-sized avatar

Todd A. Wood tawman

View GitHub Profile
@tawman
tawman / UserPivot.sql
Created January 17, 2018 03:02
A Simple SQL PIVOT Query
SELECT *
FROM(SELECT * FROM UserRequirement) AS UserInfo
PIVOT (MIN(ExpirationDate)
FOR Requirement IN ([Alpha], [Bravo], [Charlie], [Delta], [Echo])
) AS UserPivot
@tawman
tawman / Fetch.cs
Created January 16, 2018 03:56
PetaPoco Multi Fetch call
public List <TRet> Fetch<T1, T2, TRet>(Func <T1, T2, TRet> cb, string sql, params object [] args)
{
return Query<T1, T2, TRet>(cb, sql, args).ToList();
}
@tawman
tawman / git-unite-win10-x64-build.log
Created February 7, 2017 16:12
Git.Unite Build on Win10 x64
C:\git> git clone https://github.com/tawman/git-unite.git
Cloning into 'git-unite'...
remote: Counting objects: 140, done.
remote: Total 140 (delta 0), reused 0 (delta 0), pack-reused 140R
Receiving objects: 100% (140/140), 3.89 MiB | 938.00 KiB/s, done.
Resolving deltas: 100% (61/61), done.
C:\git> cd .\git-unite\
C:\git\git-unite [master =]> .\build.bat
C:\git\git-unite>C:\Windows\Microsoft.NET\Framework\V4.0.30319\msbuild /t:clean /v:n /p:Configuration=DEBUG src\Git.Unit
@tawman
tawman / MeanPractice.txt
Created January 13, 2014 01:02
6th Grade Math Mean Practice Homework Problem
Gina and Imani have an average of 41 stickers. Gina and Ella have an average of 48 stickers. If Ella has 3 times as many stickers as Gina, how many stickers does Ella have? How many more stickers does Imani have than Gina?
@tawman
tawman / commands.sh
Created November 14, 2013 21:36
Xamarin Studio and NuGet Package Restore
# /Users/todd/projects/SignalR/.nuget/nuget.targets: Error: Command 'mono --runtime=v4.0.30319 ../../.nuget/NuGet.exe install "packages.config" -source "https://nuget.org/api/v2/;http://www.myget.org/F/aspnetwebstacknightly/" -RequireConsent -solutionDir "../../" -nocache' exited with code: 1. (Microsoft.AspNet.SignalR.Client.Portable)
kvothe:Microsoft.AspNet.SignalR.Client.Portable todd$ mono --runtime=v4.0.30319 ../../.nuget/NuGet.exe install "packages.config" -source "https://nuget.org/api/v2/;http://www.myget.org/F/aspnetwebstacknightly/" -RequireConsent -solutionDir "../../" -nocache
Package restore is disabled by default. To give consent, open the Visual Studio Options dialog, click on Package Manager node and check 'Allow NuGet to download missing packages during build.' You can also give consent by setting the environment variable 'EnableNuGetPackageRestore' to 'true'.
kvothe:Microsoft.AspNet.SignalR.Client.Portable todd$ export EnableNuGetPackageRestore=true
kvothe:Microsoft.AspNet.SignalR.Cli
@tawman
tawman / gist:4565494
Created January 18, 2013 15:48
Sliding and Absolute expiration in a dedicated Azure cache worker role question
public class AzureCacheFactory : IAzureCacheFactory
{
private readonly DataCache _cache;
private readonly DataCache _absoluteCache;
public AzureCacheFactory()
{
var factory = new DataCacheFactory();
_cache = factory.GetDefaultCache();
_absoluteCache = factory.GetCache("AbsoluteCache");
@tawman
tawman / git-flavor.sh
Created June 29, 2012 05:26
Flavor your git repository with some bacon!
#!/bin/bash
if [ ! -d $1/.git ]
then
echo "usage : $0 <repository root directory>"
exit
fi
declare -a baconbits=($(curl -s 'http://baconipsum.com/api/?type=all-meat&paras=5&start-with-lorem=1' | sed s/[^\ a-zA-Z\-]//g))
bitsize=${#baconbits[@]}
idx=0
@tawman
tawman / PowerShell.txt
Created April 15, 2012 19:34
PowerShell Command Object Pipeline
PS C:\> Get-Process -id 5904
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
1651 71 71700 74296 306 256.05 5904 chrome
PS C:\> Get-Process -id 5904 | Format-List *
__NounName : Process
Name : chrome
@tawman
tawman / BashShell.txt
Created April 15, 2012 19:31
Sample Bash Shell Process Listing Command Output
kvothe:~ todd$ ps aux -u 9633
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
todd 9633 0.0 0.7 961216 57948 ?? S 10:16AM 0:04.65 /Applications/Google Chrome.app/Contents/MacOS/Google Chrome -psn_0_7591741
kvothe:~ todd$ ps aux -u 9633 | file -
/dev/stdin: ASCII text
@tawman
tawman / SamplePetaPocoPageCustomSql.cs
Created March 19, 2012 19:57
Sample PetaPoco Page<T> Use Case for Pull Request to support Custom Count and Page SQL
public Page<SampleOption> GetAvailableSampleOptionsFor(int pageNumber, int pageSize, Guid companyId, Guid requirementId, string whereClause, string searchText, string orderBy)
{
// Build our own Paging Count(*) query to use
var countQuery = Sql.Builder.Append(@"
WITH pcr(Id, ParentSampleGroupId, GroupLevel) AS
(SELECT cg.Id, cg.ParentSampleGroupId, 0 as GroupLevel
FROM SampleGroup cg INNER JOIN SampleWidgetGroupLimit l ON l.SampleGroupId = cg.Id
WHERE l.SampleWidgetId = @1
union all
select np1.Id, np1.ParentSampleGroupId, GroupLevel + 1