Skip to content

Instantly share code, notes, and snippets.

@akhawaja
akhawaja / server.js
Created November 15, 2015 22:58
Express.js CORS OPTIONS Endpoint
var express = require('express'),
app = express();
// More variables initialized...
// More routes, settings, etc.
// This is the OPTIONS endpoint
app.options('*', function (req, res, next) {
origin = req.headers.origin;
if (origin == undefined) {
@akhawaja
akhawaja / uninstall_npm_globally.sh
Created November 1, 2015 22:13
Uninstall NPM modules globally including NPM itself
#!/usr/bin/env bash
npm ls -gp | awk -F/ '/node_modules/ && !/node_modules.*node_modules/ {print $NF}' | xargs npm -g rm
@akhawaja
akhawaja / uninstall_homebrew.sh
Created September 27, 2015 23:21
Completely uninstall Homebrew from a Mac OS X system.
#!/bin/sh
function abort {
echo "$1"
exit 1
}
set -e
/usr/bin/which -s git || abort "brew install git first!"
test -d /usr/local/.git || abort "brew update first!"

Install Node.js and NPM separately on OS X Yosemite

Install XCode

You can install XCode from the AppStore. Once done, install the XCode Command Line tools.

xcode-select --install

Install Homebrew

@akhawaja
akhawaja / gist:33b8770840ce3d296923
Created February 17, 2015 22:02
Maven pom.xml dependencies for OrientDB Graph Database
<dependencies>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
<version>${blueprints.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
@akhawaja
akhawaja / Pagination.php
Last active December 10, 2015 02:49
Pagination class for PHP that outputs HTML compatible with Twitter Bootstrap. It uses a sliding scale when displaying the pagination links.
<?php
/**
* Pagination class that outputs HTML compatible with Twitter Bootstrap.
* It uses a sliding scale when displaying the pagination links.
*
* @author Amir Khawaja <[email protected]>
*/
class Pagination
{
@akhawaja
akhawaja / Application.java
Created December 29, 2011 19:59
Play! Framework 1.2.x Pagination (this is a variation and modification of the version found on https://gist.github.com/1379217)
package controllers;
import controllers.Constants;
import play.mvc.Controller;
import utils.PaginationInfo;
import java.util.List;
/**
* Sample controller.
*/