Skip to content

Instantly share code, notes, and snippets.

View Meligy's full-sized avatar

Meligy Meligy

View GitHub Profile
@shanestillwell
shanestillwell / directive.js
Created December 24, 2012 20:46
AngularJS update model upon input blur
function Main() {}
// override the default input to update on blur
angular.module('app', []).directive('ngModelOnblur', function() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elm, attr, ngModelCtrl) {
if (attr.type === 'radio' || attr.type === 'checkbox') return;
@biggyspender
biggyspender / MobyLinux.ps1
Last active September 28, 2020 23:36
Set DockerNAT switch to be a private network
# See comment lines prefixed with ADDED
# It might be necessary to delete the existing DockerNAT switch in hyper-v manager
<#
.SYNOPSIS
Manages a MobyLinux VM to run Linux Docker on Hyper-V
.DESCRIPTION
Creates/Destroys/Starts/Stops A MobyLinux VM to run Docker on Hyper-V
.PARAMETER VmName
(function($){
$.widget("ui.mywidget", {
options: {
autoOpen: true
},
_create: function(){
// by default, consider this thing closed.
@DamianEdwards
DamianEdwards / Program.cs
Created March 19, 2013 05:54
Demonstrates that SqlDependency notifications can occur concurrently with the command that set them up. This might cause issues in certain cases if the application isn't expecting multiple commands to be executed at the same time.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
namespace SqlDependencyConcurrency
{
class Program
{
private static readonly string _connectionString = "Data Source=(local);Initial Catalog=Sample;Integrated Security=SSPI;";
@aaronpowell
aaronpowell / PreExecutingResult.cs
Created April 18, 2013 04:45
Execute a Razor view server side in a MVC project. I'm returning the HTML in a JSON blob for this example
public class PreExecutingResult : JsonResult {
private ViewResult viewResult;
private object model;
public PreExecutingResult(string viewName, object model) {
viewResult = new ViewResult {
ViewName = viewName
};
viewResult.ViewData.Model = model;
@brendankowitz
brendankowitz / gist:4071660
Created November 14, 2012 11:36
Umbraco IHttpModule to switch to an optional [TemplateAlias]Mobile template when mobile devices are detected
using System;
using System.Linq;
using System.Web;
using Kowitz.Core.Module;
using Microsoft.Web.Infrastructure.DynamicModuleHelper;
using ZeroProximity.DeviceDetection;
using umbraco;
using umbraco.cms.businesslogic.template;
[assembly: PreApplicationStartMethod(typeof(MobileRewriteModule), "Start")]
@jakcharlton
jakcharlton / .gitignore
Created September 12, 2011 11:48
Git ignore for VS
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
@ducas
ducas / MongoApiController.cs
Created April 10, 2014 23:53
Generic WebAPI controller to provide a REST interface for MongoDB collections
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
namespace Web.Core
{
public abstract class MongoApiController<T> : ApiController
@pntrivedy
pntrivedy / Get query string using fastest javascript method
Created March 12, 2014 00:21
I was searching for a way in javascript by which I can get url query parameters and found this here : http://jsperf.com/querystring-with-javascript probably the best solution.
<script>
window.getParameterByName = function(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null) return "";
else return decodeURIComponent(results[1].replace(/\+/g, " "));
}
</script>