Skip to content

Instantly share code, notes, and snippets.

View drlongnecker's full-sized avatar
🎯
Working on everything and anything.

David R. Longnecker drlongnecker

🎯
Working on everything and anything.
View GitHub Profile
@drlongnecker
drlongnecker / macrochanger.lua
Created March 23, 2018 16:49
macrochanger.lua
-- A quick rewrite of the Windower addon for Ashita v3 that swaps your macro pallette on job change.
-- Yes, I'm lazy.
_addon.name = 'MacroChanger'
_addon.author = 'Derahine'
_addon.version = '1.0.0.0'
require 'common'
jobs = {
@drlongnecker
drlongnecker / group_child_by_date.js
Last active August 29, 2015 13:56
Counting child documents by full date in MongoDB
// 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' } } },
@drlongnecker
drlongnecker / lazymerge.ps1
Created July 25, 2012 15:48
Lazy Git Merge
# 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
@drlongnecker
drlongnecker / rift.ahk
Created March 23, 2012 22:08
RIFT Melee Tab-Out Prevention!
#IfWinActive, RIFT
!Tab::
send {tab}
return
#Tab::
send {tab}
return
#IfWinActive
@drlongnecker
drlongnecker / deploy.xml
Created February 10, 2012 16:34
DeployTo PowerShell xml configuration file
<?xml version="1.0" encoding="utf-8" ?>
<settings>
<common>
<release>.\release</release>
<web.config>
<appsettings>
</appsettings>
</web.config>
</common>
@drlongnecker
drlongnecker / DeployTo.ps1
Created February 10, 2012 16:32
DeployTo PowerShell build backup and deployment script.
param (
[string]$Deploy,
[switch]$SkipBackup,
[string]$Settings = "settings.xml"
)
$success = $false
function writeError($message) {
Write-Host $message -Foreground Red
break;
@drlongnecker
drlongnecker / SendTo-Campfire.ps1
Created January 16, 2012 18:55
Posting to Campfire from PowerShell
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"
@drlongnecker
drlongnecker / OracleSQLAliasToBeanTransformer.cs
Created January 13, 2012 21:34
Addressing issues in Oracle.DataAccess and AliasToBeanTransformer
[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)
@drlongnecker
drlongnecker / Set-PrinterByLocation.ps1
Created January 13, 2012 14:58
Setting the default printer based on network subnet.
$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
}
@drlongnecker
drlongnecker / gist:1593302
Created January 11, 2012 06:05
Adding a Launcher icon in Ubuntu 11.10
gnome-desktop-item-edit ~/Desktop/ --create-new
#just so I don't forget... again.