Skip to content

Instantly share code, notes, and snippets.

@cabrel
cabrel / netica-likelihoods.cs
Last active December 14, 2015 03:59
Programatically Entering Netica Likelihoods
// We will assume you have a netica network
// assigned to the private variable: NeticaNetwork
// and that you will properly assign the two variables
// listed below in the correct locations.
//
// place in relative locations within your code
//
Application App = new Application();
BNet NeticaNetwork = App.ReadBNet(pathToNeta);
@cabrel
cabrel / drag-drop-wpf.cs
Last active May 23, 2023 06:14
Drag & Drop in C# w/ WPF
// WPF Canvas Object
// Canvas LayoutCanvas;
//
// Events Required
//
// Canvas_PreviewMouseLeftButtonDown
// Canvas_PreviewMouseMove
// Canvas_PreviewMouseLeftButtonUp
// Parent_PreviewKeyDown
//
@cabrel
cabrel / query-wmi.cs
Created February 24, 2013 20:47
Querying WMI for local users
/// <summary>
/// Returns a list of users on a target machine or machines which could
/// include an additional domain to search in.
/// </summary>
/// <param name="connection"></param>
/// <param name="domain"></param>
/// <param name="hosts"></param>
/// <returns></returns>
public List<string> GetLocalUsers(ConnectionOptions connection, string domain, ConcurrentBag<string> hosts)
{
@cabrel
cabrel / query-ad.cs
Created February 24, 2013 20:49
Retrieving objects from Active Directory (Originally posted on 09/14/2010)
/// <summary>
/// Retrieves all objects from the given DN and returns their given properties
///
/// If we are told to search recursively then if we find any OU's we iterate through those
/// as well
/// </summary>
/// <param name="DN"></param>
/// <param name="properties"></param>
/// <param name="useRecursion"></param>
/// <returns></returns>
@cabrel
cabrel / cpu-whine.cs
Created February 24, 2013 21:45
Some cheese to go with that (CPU) W(h)ine?
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace CpuWhiner
{
class Program
@cabrel
cabrel / wpf-content-alignment.xaml
Created February 24, 2013 21:49
WPF ToolBar Content Alignment
<ToolBar>
<ToolBar.Resources>
<Style TargetType="{x:Type ToolBarPanel}">
<Setter Property="Orientation" Value="Vertical"/>
</Style>
</ToolBar.Resources>
<!-- This is the downside of this solution:
You have to set the height at some level (once)
or you will end up with controls forcing
@cabrel
cabrel / authenticate.js
Last active December 15, 2015 06:09
Small auth check extension for Hapi + Travelogue
// `server` is the Hapi instance;
// boilerplate omitted for brevity sake
// prereq handler
function getSecret(request, next) {
return next(42);
}
// auth not required here, so we
// don't decorate it with any tags
@cabrel
cabrel / yeoman_generator.patch
Created March 29, 2013 16:15
yeoman generator patch
--- /usr/lib/node_modules/yo/node_modules/yeoman-generator/lib/actions/file.js 2013-01-26 18:40:49.000000000 -0500
+++ node_modules/generator-angular/node_modules/yeoman-generator/lib/actions/file.js 2013-03-29 12:09:00.289071681 -0400
@@ -29,7 +29,11 @@
file.expandFiles = function expandFiles(pattern, options) {
var cwd = options.cwd || process.cwd();
return this.expand(pattern, options).filter(function (filepath) {
- return fs.statSync(path.join(cwd, filepath)).isFile();
+ if (file.isPathAbsolute(filepath)) {
+ return fs.statSync(filepath).isFile();
+ } else {
@cabrel
cabrel / prefix.vbs
Last active December 21, 2015 18:39
prefix directory name to each file
'
' Usage: `cscript prefix.vbs C:\path\to\folder\root`
'
Dim folderList, fileList, rootPath
rootPath = WScript.Arguments.Item(0)
folderList = Split(ShowFolderList(rootPath), ",")