Skip to content

Instantly share code, notes, and snippets.

# 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__
#!/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'
;;; 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))
var myMultiplierMaker = function(factor) {
var returnFunction = function(otherFactor) {
return factor * otherFactor;
}
return returnFunction;
}
var timesFive = myMultiplierMaker(5);
var timesSeven = myMultiplierMaker(7);
@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;
@neall
neall / compiled.css
Created July 5, 2011 20:25
My SCSS mixin to give me a radial gradient over a linear gradient
.selector {
background: #f8ab2f;
background: -webkit-gradient(radial, 40% 0, 0, 100% 100%, 100,
color-stop(0, rgba(251, 215, 57, 0.5)),
color-stop(1, rgba(246, 128, 38, 0.5))),
-webkit-gradient(linear, 0 0, 0 100%,
color-stop(0, #fbd739),
color-stop(1, #f68026));
background: -webkit-linear-gradient(top, rgba(251, 215, 57, 0.5), rgba(246, 128, 38, 0.5)),
-webkit-radial-gradient(40% 0, farthest-corner, #fbd739, #f68026);
<!DOCTYPE html>
<html>
<head>
<title>test filtering</title>
</head>
<body>
<input name=filter>
<ul>
<li>Cat</li>
<li>Dog</li>
$ bundle exec rake test
Loaded suite /Users/neal/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader
Started
...........................................................................................................................................................................................................................................................................................................................................................EEF..........................................................................................................................................................................................................................................................
Finished in 11.928274 seconds.
1) Error:
test_call_import_on_VirtualBox_with_proper_base(ImportVMActionTest):
NoMethodError: undefined method `clear_line' for #<Vagrant::UI:0x00000100f43958>
/Users/neal/source/vagrant/lib/vagrant/action/vm/import.rb:20:in `call'
@neall
neall / app.css
Last active January 4, 2016 07:39
#previous {
background: blue;
height: 10px;
}
#next {
background: green;
height: 10px;
}
#timeline-container {
position: relative;
@neall
neall / methToFunc.js
Last active August 29, 2015 13:59
Take a method that depends on "this" and wrap it in a function call you can pass around. Also includes optional currying.
Object.defineProperty(Object.prototype, 'methToFunc', {
value: function(methodName) {
var method = this[methodName];
if (typeof method === 'function') {
var curryArgs = [].slice.call(arguments, 1);
var that = this;
return function() {
return method.apply(that, curryArgs.concat(arguments));
};
} else {