This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
require 'ostruct' | |
class << ERB | |
def compile(template, locals) | |
renderer = ERB.new(template) | |
struct = OpenStruct.new(locals) | |
class << struct | |
def get_binding | |
binding() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flash = require('express-flash')(); | |
module.exports = function() { | |
return function(req, res, next) { | |
flash(req, res, function() { | |
req.jsonFlash = function() { | |
if (arguments.length === 1) { | |
var data = req.flash(arguments[0]); | |
if (data.length) { | |
return JSON.parse(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################################### | |
APM | |
####################################### | |
public partial class APMVersion : Form | |
{ | |
private const int BUFFER_SIZE = 1024; | |
public Form1() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//app.js | |
var express = require('express') | |
, http = require('http') | |
, fs = require('fs'); | |
var app = express(); | |
app.configure(function(){ | |
app.set('port', process.env.PORT || 3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var random = new Random(); | |
RandomStreamGenerator.GenerateIndefinitley(() => (Keys)(random.Next(1,150), k => /* do something with the key */); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class RandomStreamGenerator | |
{ | |
private static Random _random = new Random(); | |
public static void GenerateIndefinitley<T>(Func<T> func, Action<T> onNext) | |
{ | |
GenerateIndefinitley(func, 100, 1000, onNext); | |
} | |
public static void GenerateIndefinitley<T>(Func<T> func, int minMilliseconds, int maxMilliseconds, Action<T> onNext) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript">window.ngon={};ngon.Person={"FirstName":"John","LastName":"Doe","Age":30};</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class HtmlHelperExtensions | |
{ | |
public static IHtmlString IncludeNGon(this HtmlHelper helper, string @namespace = "ngon") | |
{ | |
var viewData = helper.ViewContext.ViewData; | |
if (viewData == null) | |
{ | |
return MvcHtmlString.Empty; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NGonActionFilterAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
filterContext.Controller.ViewBag.NGon = new ExpandoObject(); | |
base.OnActionExecuting(filterContext); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(function () { | |
$("#button").click(function () { | |
var person = ngon.Person; | |
var div = $("#output"); | |
div.html(''); | |
div.append("FirstName: " + person.FirstName); | |
div.append(", LastName: " + person.LastName); | |
div.append(", Age: " + person.Age); | |
}); |
NewerOlder