Skip to content

Instantly share code, notes, and snippets.

@neall
neall / Object.create.js
Created October 28, 2010 13:33
implement ES5-style Object.create
(function(){
if (typeof Object.create != 'function') {
Object.create = function(proto, propertiesObject) {
var pType = typeof propertiesObject;
if (pType == 'string' || pType == 'boolean' || pType == 'number') {
throw new TypeError('The second parameter to Object.create must be undefined or an object.');
}
var Constructor = function() {};
Constrcutor.prototype = proto;
var myMultiplierMaker = function(factor) {
var returnFunction = function(otherFactor) {
return factor * otherFactor;
}
return returnFunction;
}
var timesFive = myMultiplierMaker(5);
var timesSeven = myMultiplierMaker(7);
;;; This was installed by package-install.el.
;;; This provides support for the package system and
;;; interfacing with ELPA, the package archive.
;;; Move this code earlier if you want to reference
;;; packages in your .emacs.
(when
(load
(expand-file-name "~/.emacs.d/elpa/package.el"))
(package-initialize))
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::HTML.parse(open('input.html'), nil, 'utf-8')
meta_content_type = Nokogiri::XML::Node.new 'meta', doc
meta_content_type['http-equiv'] = 'Content-Type'
meta_content_type['content'] = 'text/html; charset=utf-8'
# To enable files to be served from "./public/", the :static
# and :app_file options have to be set.
require 'rubygems'
require 'sinatra/base'
class App < Sinatra::Base
set :static, true
set :app_file, __FILE__