Skip to content

Instantly share code, notes, and snippets.

Oliver Nightingale olivernn

  • Cape Town
Block or report user

Report or block olivernn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@olivernn
olivernn / package.json
Created Apr 1, 2014
lunr package.json
View 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 Apr 1, 2014
more npm debug logs.
View gist:9919662
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
View gist:9919281
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
View colors.html
<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
View duration.rb
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 Dec 20, 2015
Benchmarking map and compact vs each_with_object vs inject
View bench.rb
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 Dec 20, 2015
Configuration for truncating dev logs using newsyslog
View dev_logs.conf
# 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 Jun 8, 2013
Getting started with lunr
View Readme.md

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 Dec 13, 2015
Using Davis.hash extensions
View index.html
<!DOCTYPE HTML>
<html>
<head>
<title>Davis tests</title>
<!-- dependencies -->
<script src="/tests/javascripts/jquery.js"></script>
<!-- davis -->
<script src="/davis.js"></script>
@olivernn
olivernn / projlog
Created Jan 11, 2013
Display some graphs based on git log output.
View projlog
#!/usr/bin/env ruby
require 'date'
class Commit
attr_reader :sha, :author, :date
def initialize(attributes = {})
@sha = attributes[:sha]
You can’t perform that action at this time.