Skip to content

Instantly share code, notes, and snippets.

View olivernn's full-sized avatar

Oliver Nightingale olivernn

View GitHub Profile
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/0.8.20/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli 'lunr' ]
2 info using npm@1.2.11
3 info using node@v0.8.20
4 verbose read json /Users/olivernightingale/package.json
5 verbose read json /Users/olivernightingale/node_modules/lunr/package.json
6 verbose read json /Users/olivernightingale/package.json
@olivernn
olivernn / package.json
Created April 1, 2014 18:10
lunr package.json
{
"name": "lunr",
"description": "Simple full-text search in your browser.",
"version": "0.5.0",
"author": "Oliver Nightingale",
"keywords": ["search"],
"homepage": "http://lunrjs.com",
"bugs": "http://github.com/olivernn/lunr.js/issues",
"main": "lunr.js",
"license": "MIT",
@olivernn
olivernn / gist:9919662
Created April 1, 2014 18:07
more npm debug logs.
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/0.8.20/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'publish',
1 verbose cli '--force' ]
2 info using npm@1.2.11
3 info using node@v0.8.20
4 warn using --force I sure hope you know what you are doing.
5 verbose publish [ '.' ]
6 verbose read json /Users/olivernightingale/code/lunr.js/package.json
@olivernn
olivernn / gist:9919281
Created April 1, 2014 17:47
npm install log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/0.8.20/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli 'lunr' ]
2 info using npm@1.2.11
3 info using node@v0.8.20
4 verbose read json /Users/olivernightingale/package.json
5 verbose read json /Users/olivernightingale/node_modules/lunr/package.json
6 verbose read json /Users/olivernightingale/package.json
<body>
<script>
var randInRange = function (min, max) {
var range = max - min
return min + (Math.random() * range)
}
var HSL = function (h, s, l) {
this.h = h, this.s = s, this.l = l
class Duration
include Comparable
attr_reader :milliseconds
def initialize(value = 0)
case value
when Fixnum
@milliseconds = value
when String
@olivernn
olivernn / bench.rb
Last active December 20, 2015 11:09
Benchmarking map and compact vs each_with_object vs inject
require 'benchmark'
words = File.open('/usr/share/dict/words', 'r') do |file|
file.each_line.take(100_000).map(&:chomp)
end
Benchmark.bmbm(20) do |x|
GC.start
x.report("map") do
words.map do |word|
@olivernn
olivernn / dev_logs.conf
Last active December 20, 2015 06:48
Configuration for truncating dev logs using newsyslog
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/path/to/log/*.log 644 0 5120 * GN
@olivernn
olivernn / Readme.md
Created June 8, 2013 13:49
Getting started with lunr

Getting Started with Lunr

There are two ways to use lunr to index some documents, The simplest way is to just build the index client side each time the page is loaded. search.js shows an example of this.

If your data is relatively static it might be more efficient to generate the index server side and then load this on each page load, your can see an example of generating the index in node in builder.js.

You can load a serialised index like this:

var idx = lunr.Index.load(JSON.parse(json_string))
@olivernn
olivernn / index.html
Last active December 13, 2015 21:19
Using Davis.hash extensions
<!DOCTYPE HTML>
<html>
<head>
<title>Davis tests</title>
<!-- dependencies -->
<script src="/tests/javascripts/jquery.js"></script>
<!-- davis -->
<script src="/davis.js"></script>