View group_child_by_date.js
// grab article.comments, group by date (roll times up to full days), count up instances to get full counts per day.
// gotta be a better way...
db.Article.aggregate(
{$unwind: '$Comments'},
{$group: { _id: '$Comments.DateCreated', count : {$sum: 1 }}},
{$match: { '_id' : { $gte: ISODate('2014-02-21 00:00:00'), $lte: ISODate('2014-02-28 23:59:59') } }},
{$project: { _id: 0, count: 1, 'date': '$_id', h: { $hour: '$_id' }, m: { $minute: '$_id'}, s: { $second: '$_id' }, ml: {$millisecond: '$_id'} } },
{$project: { count: 1, 'dt': { "$subtract" : [ "$date", { "$add" : [ "$ml", { "$multiply" : [ "$s", 1000 ] }, { "$multiply" : [ "$m", 60, 1000 ] }, { "$multiply" : [ "$h", 60, 60, 1000 ] } ] } ] } }},
{$group: { _id: '$dt', count: { $sum: '$count' } } },
View lazymerge.ps1
# for when you're just too lazy to type out the merge command
# and change branches
function merge([string] $target, [string] $source) {
if ($source -eq "") {
$symbolicref = git symbolic-ref HEAD
$source = $symbolicref.substring($symbolicref.LastIndexOf("/") +1)
}
write-host "Merging $source into $target" -for white -ba red
git checkout $target; git merge $source; git checkout $source
View rift.ahk
#IfWinActive, RIFT
!Tab::
send {tab}
return
#Tab::
send {tab}
return
#IfWinActive
View deploy.xml
<?xml version="1.0" encoding="utf-8" ?>
<settings>
<common>
<release>.\release</release>
<web.config>
<appsettings>
</appsettings>
</web.config>
</common>
View DeployTo.ps1
param (
[string]$Deploy,
[switch]$SkipBackup,
[string]$Settings = "settings.xml"
)
$success = $false
function writeError($message) {
Write-Host $message -Foreground Red
break;
View SendTo-Campfire.ps1
param (
[string]$RoomNumber = (Read-Host "The room to post to (default: 123456) "),
[string]$Message = (Read-Host "The message to send ")
)
$defaultRoom = "123456"
if ($RoomNumber -eq "") {
$RoomNumber = $defaultRoom
}
$authToken = "YOUR AUTH TOKEN"
View OracleSQLAliasToBeanTransformer.cs
[Serializable]
public class OracleSQLAliasToBeanTransformer : IResultTransformer
{
const BindingFlags Flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
readonly System.Type _resultClass;
ISetter[] _setters;
readonly IPropertyAccessor _propertyAccessor;
readonly ConstructorInfo _constructor;
readonly PropertyInfo[] _fields;
public OracleSQLAliasToBeanTransformer(Type resultClass)
View Set-PrinterByLocation.ps1
$homeNet = "10.1.4.*", "OfficePrinter"
$remoteNet = "10.1.6.*", "W382_HP_Printer"
function Set-DefaultPrinter([string]$printerPath) {
$printers = gwmi -class Win32_Printer -computer .
Write-Host -fore cyan "Default Printer: $printerPath"
$dp = $printers | ? { $_.deviceID -match $printerPath }
$dp.SetDefaultPrinter() | Out-Null
}
View gist:1593302
gnome-desktop-item-edit ~/Desktop/ --create-new
#just so I don't forget... again.
View FindTODO.ps1
#full details now available: http://tiredblogger.wordpress.com/2011/12/28/finding-todos-and-reporting-in-powershell/
param(
#this is appalling; there has to be a better way to get the raw name of "this" directory.
[string]$DirectoryMask = (get-location),
[array]$Include =
@("*.spark","*.cs","*.js","*.coffee","*.rb"),
[array]$Exclude =
@("fubu-content","packages","build","release"),
[switch]$Html,