Skip to content

Instantly share code, notes, and snippets.

View brianmarete's full-sized avatar

Brian Marete brianmarete

View GitHub Profile
@brianmarete
brianmarete / Jenkinsfile
Created June 20, 2024 13:48
Example Jenkinsfile
pipeline{
agent any
tools{
nodejs 'Node-18'
}
environment {
MONGODB_URI = credentials('mongo-db')
DOCKER_IMAGE_NAME = 'app-gallery'
DOCKER_IMAGE_TAG = '1.0.0'
}
/**
You are given a JSON object representing a part of your musical album collection.
Each album has several properties and a unique id number as its key. Not all albums have complete information.
Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"),
and a value (like "Addicted to Love") to modify the data in this collection.
If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.
Your function must always return the entire collection object.
@brianmarete
brianmarete / rangeOfNumbers.js
Created August 21, 2020 09:05
JavaScript function to generate a range of numbers recursively, given a start and end number
function rangeOfNumbers(startNum, endNum) {
if (endNum < startNum) {
return [];
} else {
var range = rangeOfNumbers(startNum, endNum - 1);
range.push(endNum);
return range;
}
};
public class App {
public static void main(String[] args) {
ProcessBuilder process = new ProcessBuilder();
Integer port;
// This tells our app that if Heroku sets a port for us, we need to use that port.
// Otherwise, if they do not, continue using port 4567.
if (process.environment().get("PORT") != null) {
port = Integer.parseInt(process.environment().get("PORT"));
import org.sql2o.*;
import java.net.URI;
import java.net.URISyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DB {
private static URI dbUri;
public static Sql2o sql2o;
Logger logger = LoggerFactory.getLogger(DB.class);
static {
apply plugin: 'java'
apply plugin: 'application'
repositories {
jcenter()
}
dependencies {
compile 'com.sparkjava:spark-core:2.5.5'
compile 'org.slf4j:slf4j-simple:1.7.21'
@brianmarete
brianmarete / index.html
Last active December 21, 2018 07:58
Simple quiz
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<title>Document</title>
@brianmarete
brianmarete / index.html
Last active December 26, 2018 15:43
Simple jQuery Form example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<title>Document</title>
@brianmarete
brianmarete / gulpfile.js
Last active March 16, 2017 09:06
A starter gulpfile
// Calling in our dependencies
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
// Browserify helps to bring node modules to browser.
browserify = require('browserify'),
/*
gulp uses a format called vinyl streams (https://github.com/gulpjs/vinyl) but browserify outputs text streams. We require vinyl-source-stream to convert text streams to vinyl streams.
*/
@brianmarete
brianmarete / removeVowels.js
Created February 28, 2017 18:22
JavaScript function that removes all the vowels in a string
function removeVowels(sentence) {
var vowels = ['a', 'e', 'i', 'o', 'u'];
var newSentence = [];
for (var i = 0; i < sentence.length; i++) {
if (vowels.includes(sentence[i])) {
newSentence.push('-');
} else {
newSentence.push(sentence[i]);
}
}