Skip to content

Instantly share code, notes, and snippets.

View qawemlilo's full-sized avatar

Qawelesizwe Mlilo qawemlilo

View GitHub Profile
@qawemlilo
qawemlilo / logger.js
Created October 19, 2016 06:29 — forked from prantlf/logger.js
Logger Library with winston - Fixed for additional log arguments
var app = require(process.cwd() + '/app');
var winston = require('winston');
var _ = require('lodash');
// Set up logger
var customColors = {
trace: 'white',
debug: 'green',
info: 'green',
warn: 'yellow',
@qawemlilo
qawemlilo / pagination.md
Created February 2, 2016 06:58 — forked from mislav/pagination.md
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

Verifying I am +qawemlilo on my passcard. https://onename.com/qawemlilo
@qawemlilo
qawemlilo / paginate.js
Last active December 7, 2015 20:42
HBS helper for pagination
hbs.registerHelper('paginate', function(pagination, context) {
var lists = '';
if (pagination.isFirstPage) {
lists += '<li class="disabled"><a href="#">&laquo; Prev</a></li>';
}
else {
lists += '<li><a href="' + pagination.base + '?';
lists += 'p=' + pagination.prev + '">' + '&laquo; Prev</a></li>';
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
#!/usr/bin/env node
var util = require('util'),
fs = require('fs'),
path = require('path'),
http = require('http'),
_ = require('lodash'),
url = require('url');
var DEBUG = false,
@qawemlilo
qawemlilo / Makefile
Last active August 29, 2015 14:18 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@qawemlilo
qawemlilo / seed.js
Last active August 29, 2015 14:16
Seeding
var sequence = require('when/sequence');
// requires you to save your model in a seperate file
var PostModel = require('./models/post');
var posts = [
{title: 'Title 1', html: '<p>Lorem ipsum dolor sit amet, graeco efficiendi ne nec, no cibo possit vix</p>'},
{title: 'Title 2', html: '<p>Lorem ipsum dolor sit amet, graeco efficiendi ne nec, no cibo possit vix</p>'},
{title: 'Title 3', html: '<p>Lorem ipsum dolor sit amet, graeco efficiendi ne nec, no cibo possit vix</p>'},
@qawemlilo
qawemlilo / count.js
Last active August 29, 2015 14:15 — forked from jordaaash/count.js
var Promise = require('bluebird'),
User = require('./user'),
knex, query;
knex = User.prototype._builder(User.prototype.tableName);
query = function (q) {
q.distinct()
.innerJoin('orders', function () {
this.on('users.id', '=', 'orders.user_id')
@qawemlilo
qawemlilo / CORS
Created July 9, 2014 11:41 — forked from Unitech/CORS
app.all('*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", req.headers.origin);
res.header("Access-Control-Allow-Credentials", true);
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization, Content-Length");
if (req.method == 'OPTIONS') {
return res.send(200);
}