Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
ryanflorence / static_server.js
Last active July 21, 2024 12:43
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@cybermaxs
cybermaxs / NinjectWebCommon.cs
Created September 24, 2013 12:00
Measure and report performance of asp.net MVC Action Filters using asp.net MiniProfiler. Warning : default namespace is MyApp
[assembly: WebActivator.PreApplicationStartMethod(typeof(MyApp.App_Start.NinjectWebCommon), "Start")]
[assembly: WebActivator.ApplicationShutdownMethodAttribute(typeof(MyApp.App_Start.NinjectWebCommon), "Stop")]
// please add a reference to NInject.MVC3
namespace MyApp.App_Start
{
using System;
using System.Web;
using System.Web.Mvc;
@sloria
sloria / bobp-python.md
Last active July 21, 2024 04:44
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@esfand
esfand / typescript_angular.adoc
Last active September 30, 2022 12:37
AngularJS with TypeScript
@staltz
staltz / introrx.md
Last active July 19, 2024 22:21
The introduction to Reactive Programming you've been missing
@cybermaxs
cybermaxs / loadspeedv2.js
Created September 8, 2014 11:29
Compares page load time between HTML5 Navigation timings and basic computation using Date.now() (examples/loadspeed.js). Requires PhantomJS 2.0
var page = require('webpage').create(),
system = require('system'),
t, address;
if (system.args.length === 1) {
console.log('Usage: loadspeedv2.js <some URL>');
phantom.exit(1);
} else {
t = Date.now();
address = system.args[1];
using NodaTime;
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace JITterOptimisations
{
public static class Extensions
@cybermaxs
cybermaxs / Benckmark.cs
Last active August 29, 2015 14:07
Yet another fast Enum.ToString() Implementation. Read explanations http://cybermaxs.wordpress.com/2014/10/03/the-importance-of-useless-micro-optimization/
using Ideafixxxer.Generics;
using System;
using System.Diagnostics;
using System.Text;
namespace EnumBenchmarks
{
public enum MyEnum
{
Undefined = 0,
using System;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
namespace RegexOptims
{
public static class RegexComparer
{
private const string REGEX_PATTERN = @"^[\w\d]+$";