Skip to content

Instantly share code, notes, and snippets.

View djom202's full-sized avatar

Jonathan Olier djom202

View GitHub Profile
@djom202
djom202 / gist:c190a1668a11c14d0328dcdc79a42da0
Created October 27, 2020 01:33 — forked from timonweb/gist:3165322
Code to catch all PHP errors which result in 500 Error Code. Include this snippet at the beginning of index.php file
<?php
define('E_FATAL', E_ERROR | E_USER_ERROR | E_PARSE | E_CORE_ERROR |
E_COMPILE_ERROR | E_RECOVERABLE_ERROR);
define('ENV', 'dev');
//Custom error handling vars
define('DISPLAY_ERRORS', TRUE);
define('ERROR_REPORTING', E_ALL | E_STRICT);
@djom202
djom202 / jenkins-set-number-of-executors.groovy
Created October 31, 2019 20:27 — forked from ivan-pinatti/jenkins-set-number-of-executors.groovy
Jenkins - Set number of executors via groovy script - #jenkins #groovy
#!groovy
// imports
import jenkins.model.Jenkins
// parameter
Integer numberOfExecutors = 2
// get Jenkins instance
Jenkins jenkins = Jenkins.getInstance()
@djom202
djom202 / dijkstra.js
Created July 29, 2019 21:17 — forked from nybblr/dijkstra.js
Dijkstra's Algorithm in JavaScript.
var graph = [
'AB6',
'AC3',
'BD6',
'CD5',
'CE9',
'DF8',
'DE3',
'EG8',
'FG2'
@djom202
djom202 / Nested-Routers-Express.md
Created May 13, 2019 14:21 — forked from zcaceres/Nested-Routers-Express.md
Child Routers in Express

Nested Routers in Express.js

Express makes it easy to nest routes in your routers. But I always had trouble accessing the request object's .params when you had a long URI with multiple parameters and nested routes.

Let's say you're building routes for a website www.music.com. Music is organized into albums with multiple tracks. Users can click to see a track list. Then they can select a single track and see a sub-page about that specific track.

At our application level, we could first have a Router to handle any requests to our albums.

const express = require('express');
@djom202
djom202 / bitbucket-pipelines.yml
Created February 18, 2019 13:58 — forked from thesabbir/bitbucket-pipelines.yml
Bitbucket pipeline example for JS projects
image: node:7.0 #node v7
clone: # the 'clone' section
depth: 1 # latest commit only
pipelines:
default:
- step:
script:
- npm i -g yarn
- yarn
@djom202
djom202 / index.js
Created November 17, 2017 19:53 — forked from max-mapper/index.js
requirebin sketch
var observer = require('continuous-observer')
var cave = require('cave-automata-2d')
var fill = require('ndarray-fill')
var zero = require('zeros')
var raf = require('raf')
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d')
// Set up the controls, so that we can control
@djom202
djom202 / run-test-build-and-deploy.sh
Created October 31, 2017 16:28 — forked from EstebanMDQ/run-test-build-and-deploy.sh
run gulp build in codeship and deploy that to heroku
gulp test
gulp build
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git add build
git commit -am "app built"
export CI_COMMIT_ID=$(git rev-parse HEAD)
@djom202
djom202 / base64.js
Created May 25, 2017 02:46 — forked from inadarei/base64.js
base64 encode/decode in Node.js
var url = "http://cdn1.giltcdn.com/images/share/uploads/0000/0001/7250/172502872/420x560.jpg";
var encoded = new Buffer(url).toString('base64');
var decoded = new Buffer(encoded, 'base64').toString('ascii')
console.log(encoded);
console.log(decoded);
@djom202
djom202 / Gulpfile.js
Created May 2, 2017 14:12 — forked from webdesserts/Gulpfile.js
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@djom202
djom202 / Food.js
Created April 4, 2017 19:08 — forked from ryanlanciaux/Food.js
Files for AngularJS blog post.
/*---------------------
:: Food
-> model
---------------------*/
module.exports = {
attributes : {
name: 'STRING',
type: 'STRING',
expiration: 'DATE',
quantity: 'STRING',