Skip to content

Instantly share code, notes, and snippets.

@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
# 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 / 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
@hugoware
hugoware / mappath.node.js
Created December 24, 2011 15:55
Node.JS MapPath function
module.exports = {
//resolves the root of the site
map_path: function(path) {
return path.replace(/^~/, global.process.env.PWD);
},
//resolves the path and performs a require
require: function(path) {
//
// wires up an object of selectors
//
// var ui = {
// menu: "#main-menu",
// list: "#list .item",
// options: {
// yes: "#option-yes",
// no: "#option-no"
// }
@hugoware
hugoware / gist:1370779
Created November 16, 2011 17:43
IMPORTANT SCRIPT
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.body.appendChild(script);
var start_typing = function(jquery, timeout) {
var input = jquery(".txtInput");
var do_next_phrase = function() {
@hugoware
hugoware / convert.cshtml
Created July 27, 2011 21:45
Using Json.Encode/Decode To Convert Anonymous Types
//using an anonymous type directly (even being passed in as a Dynamic)
//will result in an exception message. Using this converts the Anonymous
//type to a dynamic that can be used as expected
//this doesn't include any validation of properties but it can be done
@helper something_that_renders_lists(params dynamic[] links) {
links = Json.Decode(Json.Encode(links));
<ul>
@foreach(var link in links) {
@hugoware
hugoware / NestedViewModel.cs
Created June 19, 2011 22:42
Nested View Models in a Controller
public class HomeController : Controller {
public ActionResult Index() {
var view = new ViewFor.Index { Name = "Hugo" };
return this.View(view);
}
public static class ViewFor {
public class Index {
@hugoware
hugoware / CaseInsensitiveViewEngine.cs
Created May 13, 2011 14:06
Handles finding views for ASP.NET MVC on case-sensitive file systems
// Call CaseInsensitiveViewEngine.Register(...) from Global.asax
using System;
using System.Web;
using System.Web.Mvc;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.Routing;
@hugoware
hugoware / ProcessVS.vb
Created May 11, 2011 13:47
Attach To Process Visual Studio Macros
'requests a name and attaches to that process
Public Sub AttachToNamedProcess()
Dim process As String = InputBox("What process name", "Process Name", "w3wp.exe")
'make sure something was provided
If process Is Nothing Then process = ""
process = process.Trim()
If String.IsNullOrEmpty(process) Then Return
_AttachToProcess(process, False)
End Sub