Skip to content

Instantly share code, notes, and snippets.

View josephdicdican's full-sized avatar

josephdicdican

View GitHub Profile
@josephdicdican
josephdicdican / js_array_reduce.js
Last active January 12, 2017 02:13
JS array reduce
"use strict";
const arr = [ 1, 2, 3, 4, 5];
let max = arr.reduce((a, b) => {
return a > b ? a : b;
}, 0);
console.log(max);
@josephdicdican
josephdicdican / php_date_compare.php
Created January 12, 2017 01:51
PHP Date Compare
<?php
$dt = strtotime("2017-01-09 08:59:35");
$format = 'Y-m-d'; // format 'j/n/Y' gives wrong output if used for comparing two dates ('Y-m-d' is working)
$date_limit = date($format, strtotime('+0 months', $dt));
$dt_now = date($format);
if($date_limit > $dt_now) {
echo $date_limit . " is greater than " . $dt_now;
} else {
echo $date_limit . " is less than " . $dt_now;
@josephdicdican
josephdicdican / js_array_filter.js
Last active January 24, 2017 09:54
JS array filter
var dogs = ['Shuggy', 'Bobo', 'Whity', 'Moby', 'Molly', 'Charlie', 'Bolly', 'Chappie', 'Bella'];
var b_dogs = dogs.filter(function(dog) {
return startsWithB(dog);
});
function startsWithB(dog) {
return dog.startsWith("B");
}
@josephdicdican
josephdicdican / js_calculate_progress_percentage.js
Created January 18, 2017 09:15
JS Calculate Progress Percentage
var completed = 30;
var target = 30;
var progress = Math.ceil(completed / target * 100);
console.log(progress);
@josephdicdican
josephdicdican / laravel_queue.conf
Last active October 18, 2020 21:59 — forked from azimidev/_Laravel_Queue_Supervisor_Instruction.md
Laravel Queue Supervisor - reference
[program:laravel_queue]
command=/usr/local/bin/run_queue.sh
autostart=true
autorestart=true
stderr_logfile=/var/log/laraqueue.err.log
stdout_logfile=/var/log/laraqueue.out.log
@josephdicdican
josephdicdican / redis_setup_unix.md
Last active February 9, 2017 09:18
Redis Setup Unix

Redis Setup (unix)

Download and install redis

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
@josephdicdican
josephdicdican / supervisor_setup_unix.md
Last active February 10, 2017 06:45
Supervisor Setup (unix) - with Laravel Queuing

Supervisor Setup (unix) - with Laravel Queueing

Install

sudo apt-get install supervisor

Getting started

sudo service supervisor restart
@josephdicdican
josephdicdican / jquery_keydown_arrow_keys.js
Created February 2, 2017 08:28
jQuery Keydown - Arrow Keys
var goLeft = function() {
console.log('to left');
};
var goRight = function() {
console.log('to right');
};
var goUp = function() {
console.log('to up');
@josephdicdican
josephdicdican / redis_upstart.md
Last active February 3, 2017 02:11 — forked from bdotdub/redis.markdown
Running redis using upstart on Ubuntu

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db