Skip to content

Instantly share code, notes, and snippets.

@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.
*/
@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 / 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>

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 / 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!"
@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 / 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 / us_states.osql
Created November 25, 2015 02:50
Create US States SQL for OrientDB
CREATE CLASS USState EXTENDS V;
CREATE PROPERTY USState.name string;
CREATE INDEX USState.generalSearch ON USState (name COLLATE ci) FULLTEXT;
CREATE VERTEX USState SET name = "Alabama";
CREATE VERTEX USState SET name = "Alaska";
CREATE VERTEX USState SET name = "Arizona";
CREATE VERTEX USState SET name = "Arkansas";
CREATE VERTEX USState SET name = "California";
@akhawaja
akhawaja / cookieManager.js
Created October 23, 2016 20:16
JavaScript Cookie Manager class.
/**
* Cookie manager.
* @author Amir Khawaja <[email protected]>
* @license MIT
* @constructor
*/
var CookieStore = function () {
/**
* Indicate if value is of type integer.
* @param {*} value - The value to test.
@akhawaja
akhawaja / loadScripts.js
Created October 23, 2016 20:23
Load JavaScripts from a URL.
if (!window.loadScripts) {
/**
* Load scripts given an array of URLs.
* @author Amir Khawaja <[email protected]>
* @license MIT
* @param {array} scripts - An array of URLs of scripts.
* @param {function} done - The function to call once the scripts are loaded.
*/
window.loadScripts = function (scripts, done) {
var loader = function (src, handler) {