Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block greetingsj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
greetingsj / pretty-array.php
Last active Dec 5, 2016
PHP pretty-print array.
View pretty-array.php
print("<pre>".print_r($some_array_here, true)."</pre>");
greetingsj / logFormData.js
Created Dec 1, 2016
Log entries of a FormData object to the console as an object, preceded by a string.
View logFormData.js
// Log entries of a FormData object to the console as an object, preceded by a string.
export const logFormData = (formData, prefix = 'FormData entries as an object:') => {
if (typeof console !== 'object') {
throw new Error(`Expected console to be an object, but instead was: ${typeof console}`);
if (typeof console.log !== 'function') {
throw new Error(`Expected console.log to be a function, but instead was: ${typeof console.log}`);
if (!(formData instanceof FormData)) {
throw new Error('Expected input to be an instance of FormData, but instead was: ' +
View roundMomentToQuarterHour.js
const roundMomentToQuarterHour = (date) => {
if (!(date instanceof moment)) {
throw new Error('Cannot round non-MomentJS input.');
const secondsAsRoundMinute = Math.round(date.seconds() / 60);
const roundedMinutes = Math.round((date.minutes() + secondsAsRoundMinute) / 15) * 15;
return date.minutes(roundedMinutes).seconds(0);
greetingsj / try-catch-function.js
Last active Jul 7, 2016
Illustration of try–catch code.
View try-catch-function.js
var foo = function () {;
var tryFoo = function (count) {
count = count || 0;
count += 1;
if (count <= 5) {
try {
You can’t perform that action at this time.