Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hugoware
hugoware / roc.js
Last active August 29, 2015 14:03
Lightweight HTTP server for Node for front end development
var $ = module.exports
, $fs = require('fs')
, $path = require('path')
, $http = require('http')
, $query = require('querystring')
, $run = require('child_process').spawn
// optional jade templates
, $jade
# Sublime Plugin that will take the selected text(s)
# and replace it with a variable name you provide. The name and
# values are then prepended to the top of the file
import sublime, sublime_plugin, re
# handles asking for what to replace the selection with
class PromoteCssCommand( sublime_plugin.WindowCommand ):
def run( self ):
@hugoware
hugoware / WindowColor.py
Created January 22, 2015 19:29
Theme via File Path in Sublime Text 3
# checks settings and changes the theme depending on the file location
# default_folder_theme: string of the theme to use normally
# folder_themes: object with key/value of find/theme
# ex: {
# "trunk": "Packages/User/trunk.tmTheme",
# "alt/folder": "Packages/User/darkUi.tmTheme"
# }
import sublime
import sublime_plugin
@hugoware
hugoware / UserControlScanner.cs
Created April 5, 2010 02:04
Scans an ASP.NET WebApplication project to find UserControls and adds them to the web.config file
/*
* Hugo Bonacci
* http://hugoware.net
*
* UserControls in Web Application projects do not appear unless
* you use the Register tag at the top of the page or add them and
* their virtual path to the web.config file.
*
* This code allows you to add the namespace of your UserControls
* to the web.config file and it will automatically scan for any
@hugoware
hugoware / ImpersonationContext.cs
Created April 6, 2010 16:59
Uses anonymous methods to wrap impersonation with .NET
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text.RegularExpressions;
namespace Security {
/// <summary>
/// Allows you to execute code with an alternate set of credentials
/// </summary>
@hugoware
hugoware / MVC_ContentArea_ContentDisplayArea.cs
Created April 7, 2010 03:01
Uses WebControls to allow content to be written to multiple areas on the same view using ASP.NET MVC
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
namespace MvcWebControls {
/// <summary>
@hugoware
hugoware / WorkSequence.cs
Created April 20, 2010 03:29
Use lambdas to set a series of methods to perform and then rollback if an exception takes place
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
//Requires ImpersonationContext that can be found
//at http://gist.github.com/357819
using Hugoware.Security;
namespace Hugoware {
/*
* Series of extension methods to make working with
* enumerated types and bitwise operations easier.
*
* //create the typical object
* RegexOptions options = RegexOptions.None;
*
* //Assign a value
* options = options.Include(RegexOptions.IgnoreCase); //IgnoreCase
*
/// <summary>
/// Attempts to identify an anonymous value using the type name and a variety of common traits
/// (Unlikely this is the best way to determine)
/// </summary>
public static bool IsAnonymousType(object value) {
//make sure this has a value
if (value == null) { return false; }
//check if this is anonymous type using the name and
@hugoware
hugoware / Dynamic.cs
Created July 15, 2010 05:06
Semi-dynamic object for .NET code
//More information about this code
//http://somewebguy.wordpress.com/2010/07/15/almost-sorta-real-dynamic-in-net/
//
// Usage:
//
// var item = new Dynamic();
//
// Assign single values
// item.value = "something";
//