Skip to content

Instantly share code, notes, and snippets.

@nolim1t
nolim1t / gist:271018
Created January 7, 2010 05:29
Sample HTTP Request in Powershell
Powershell HTTP Request
$r = [System.Net.WebRequest]::Create("http://url/")
$resp = $r.GetResponse()
$reqstream = $resp.GetResponseStream()
$sr = new-object System.IO.StreamReader $reqstream
$result = $sr.ReadToEnd()
write-host $result
Username and passwords
@hayashih
hayashih / RedirectNoTrailingSlashUrl.cs
Created November 29, 2010 11:29
ASP.NET MVC Grobal.asax.cs sample for redirect no trailing slash url.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
namespace MyMvcWebSite
{
@andreabalducci
andreabalducci / Global.asax.cs
Created January 10, 2011 22:36
Uppercase and Lowercase ModelBinder attributes for Asp.Net MVC2
...
protected void Application_Start()
{
...
// todo: add windsor + autodiscovery by convention
ModelMetadataProviders.Current = new LucillaMetadataProvider();
ModelBinders.Binders.DefaultBinder = new LucillaModelBinder();
...
}
...
@kn0ll
kn0ll / bookmarklet.js
Created June 11, 2011 04:31
advanced bookmarklet template
javascript:(function() {
if(!window.your_bookmarklet) {
var doc = document,
js = doc.createElement('script');
js.type = 'text/javascript';
js.src = 'loader.js';
js.async = true;
@rixth
rixth / gist:1088478
Created July 18, 2011 03:15
jquery bookmarklet
/**
* This is a template bookmarklet that loads jQuery. Also works
* if another library has defined $ itself.
*/
(function () {
var s = document.createElement('script');
s.setAttribute('src', 'http://jquery.com/src/jquery-latest.js');
s.onload = function () {
jQuery.noConflict();
@webxl
webxl / grid.js
Created September 21, 2011 17:04
CSS prototyping bookmarklet
javascript:(function(){s1=document.createTextNode('.guidesOn::before { content:""; position:fixed; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjVJivzgAAAAyUlEQVRoQ%2B2abQqAIBBEPW1X6CzdqTv1RUFIipi2o72gPyXV7uybKci5wDZM8xI6dz%2Buvs6pP2Dq81GI2qiiiJkiOzQ97EGHTXUF9XUwYsaI2o1LjyqjpaYwiqDI2YFs2HtI9Wjx2Z0R%2B1ADdmB%2FC7taB0uzCSNqCqOImSIkeyW7xLXMZvqjdzJcS01hFEGRSnbe3miR7JVGgWRXcxkUQRFgj%2F8Y8htGtkJHL%2FvGaGtKd6bU9Z4C%2FCiEZDeCPahIa%2FbbDSNX433mVkIrV5rTnhDyAAAAAElFTkSuQmCC) 50% 0; z-index:1; top:0; right:0; bottom:0; left:0; opacity:.3; pointer-events:none; } * { -webkit-user-modify: read-write; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; } a { -webkit-user-modify: initial; }');s2=document.createTextNode('#a1_z { background-color: #fff; background-color: rgba(255,255,255,.8); float: left; position: fixed; z-index:2; padding: 3px; bo
using System;
using System.Linq;
using System.Web.Mvc;
using Castle.DynamicProxy;
public abstract class ActionInterceptor : IInterceptor, IActionFilter, IResultFilter {
public void Intercept(IInvocation invocation) {
switch (invocation.Method.Name) {
case "OnActionExecuting":
@russ
russ / gist:1524858
Created December 27, 2011 19:21
Base62
class Base62
@@ranges = [
('0'..'9'),
('a'..'z'),
('A'..'Z')
]
@@base = nil
@@offsets = nil
def self.to_s(number)
@rafaelfelix
rafaelfelix / pear.rb
Created December 27, 2011 19:23 — forked from jakemcgraw/pear.rb
Puppet PHP Pear provider
# Puppet PHP PEAR Package support
# Taken from https://raw.github.com/gist/1524864/fdd8fd047aa702587c0b7cce7a77d55dbd781f01/pear.rb
require 'puppet/provider/package'
# PHP PEAR support.
Puppet::Type.type(:package).provide :pear, :parent => Puppet::Provider::Package do
desc "PHP PEAR support. By default uses the installed channels, but you
can specify the path to a pear package via ``source``."
@haacked
haacked / TestHelper.cs
Created January 14, 2012 07:25
String Comparison Unit Test Helper
public static class TestHelpers
{
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue)
{
ShouldEqualWithDiff(actualValue, expectedValue, DiffStyle.Full, Console.Out);
}
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue, DiffStyle diffStyle)
{
ShouldEqualWithDiff(actualValue, expectedValue, diffStyle, Console.Out);