Skip to content

Instantly share code, notes, and snippets.

@ilman
ilman / gist:75341439308601b59227
Created June 29, 2015 16:52
jQuery Infinite Scroll
/* Load more
========================================================================== */
var loading = false;
// The number of the next page to load (/page/x/).
var pageNum = parseInt(jQuery('.load-more a').attr('data-page')) + 1;
// The maximum number of pages the current query can return.
var max = parseInt(jQuery('.load-more a').attr('data-pages'));
// The link of the next page of posts.
var nextLink = jQuery('.load-more a').attr('data-link');
/**
// ----------------------------------------------------------------------------------------------------
// - Display Errors
// ----------------------------------------------------------------------------------------------------
ini_set('display_errors', 'On');
ini_set('html_errors', 0);
// ----------------------------------------------------------------------------------------------------
// - Error Reporting
// ----------------------------------------------------------------------------------------------------
error_reporting(-1);
@ilman
ilman / api-design.txt
Created February 9, 2016 14:06
API Design
Design your API for developers first, they are the main users. In that respect, simplicity and intuitivity matter.
Use HTTP verbs instead of relying on parameters (e.g. ?action=create). HTTP verbs map nicely with CRUD:
POST for create,
GET for read,
DELETE for remove,
PUT for update (and PATCH too).
Use HTTP status codes, especially for errors (authentication required, error on the server side, incorrect parameters)... There are plenty to choose from, here are a few:
200: OK
201: Created
@ilman
ilman / pre-receive
Created December 2, 2017 19:17
Pre-receive command for git
#!/bin/bash
folder=($(basename ${PWD%/*/*}))
cdate=($(date +"%Y%m%d-%H%M%S"))
cd ../../../
zip -r "$folder"-"$cdate".zip $folder