Skip to content

Instantly share code, notes, and snippets.

View mllrjb's full-sized avatar

Jason Miller mllrjb

View GitHub Profile
@mllrjb
mllrjb / readme.md
Last active May 29, 2019 21:03
JavaScript interview question (banana)

What does the following output?

# what will the following code output?

const arr = [5, 9, 4, 12];
for (var i = 0; i < arr.length; i++) {
  setTimeout(function() {
    console.log('Index: ' + i + ', element: ' + arr[i]);
 }, 3000);
@mllrjb
mllrjb / _utility.border.scss
Created January 7, 2017 21:10
Sass border utility
/*
Borders
- - - - - - - - - - - - - - - - - - - - - - - - -
Helper classes for adding borders to elements
Class names follow this convention:
.[type][direction][size]
@mllrjb
mllrjb / _utility.spacing.scss
Created January 7, 2017 21:10
Sass padding and margin utilities
/*
Spacing
- - - - - - - - - - - - - - - - - - - - - - - - -
Helper classes for spacing like margin and padding.
Class names follow this convention:
.[type][direction][size]
@mllrjb
mllrjb / pipe.js
Created December 5, 2016 18:10
Piping Expressjs to another API via requestjs
'use strict';
const request = require('request');
module.exports = function forward(req, res, next) {
var myRequest = request({
url: req.url,
headers: req.headers
});
req.pipe(myRequest)
@mllrjb
mllrjb / migrate.js
Created December 5, 2016 18:03
Umzug Migration
const path = require('path')
, Umzug = require('umzug')
, Bluebird = require('bluebird')
const db = {
// sequelize instance
sequelize: null,
// Sequelize constructor
Sequelize: null
};
@mllrjb
mllrjb / Jenkinsfile
Created October 20, 2016 20:48
Jenkinsfile-kitchen-sink
#!groovy
/**
* Requires tool definitions for nodejs, jdk, maven, and ant
* Requires config files .npmrc and maven-settings.xml
*/
node() {
// checkout clean code
stage("checkout") {
checkout scm
@mllrjb
mllrjb / Jenkinsfile
Created October 20, 2016 20:46
Jenkinsfile-gitUrl
#!groovy
node() {
// checkout clean code
stage("checkout") {
checkout scm
sh "git clean -fdx"
}
stage("gitUrl" ) {
@mllrjb
mllrjb / Jenkinsfile-GitHubCommitStatusSetter
Created October 13, 2016 18:42
Jenkinsfile Github Commit Status Example
#!groovy
step([$class: 'GitHubCommitStatusSetter',
contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: 'preflight-build'],
statusResultSource: [$class: 'ConditionalStatusResultSource',
results: [[$class: 'AnyBuildResult', message: 'Preflight build successful', state: 'SUCCESS']]]])
@mllrjb
mllrjb / nodejs-installers.groovy
Last active November 29, 2017 08:51
Jenkins init.groovy.d Nodejs installer script
import jenkins.model.*
import hudson.model.*
import jenkins.plugins.nodejs.tools.*
import hudson.tools.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("jenkins.plugins.nodejs.tools.NodeJSInstallation")
def versions = [
@mllrjb
mllrjb / README.md
Last active April 10, 2024 17:30
Jenkins init.groovy.d role-based authorization strategy

Usage

Set a system environment variable AUTHZ_JSON_URL that points to a JSON file with the following structure:

{
  "admins": [
    "groupA", 
    "userA"
 ],