Skip to content

Instantly share code, notes, and snippets.

@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@dun4n
dun4n / vcard.html
Last active April 26, 2024 04:32
#JavaScript vcard generator example
<!doctype html>
<html>
<head>
<script type="text/javascript" src="vcard2.js"></script>
</head>
<body>
<script type="text/javascript">
// With helper methods
var fooBar = vCard.create(vCard.Version.FOUR)
fooBar.addFormattedname("Mr Foo Bar")
@eyy
eyy / navigation.js
Created July 3, 2013 11:04
mongoose recursive schema
schema.statics.findRecursive = function(cb) {
this.find({ show: true, menu: true })
.select('order parent url title')
.sort({ parent: -1, order: 1 })
.lean()
.exec(function(err, items) {
if (err) cb(err);
var o = {},
arr = [];
@stevebourne
stevebourne / Gemfile
Created April 15, 2012 19:28
Add facebook auth to a Clearance app, using omniauth-facebook
gem 'omniauth'
gem 'omniauth-facebook'
gem 'clearance'