Skip to content

Instantly share code, notes, and snippets.

View mattmusc's full-sized avatar

Matteo mattmusc

View GitHub Profile
@mattmusc
mattmusc / DbConfigLoaderPostProcessor.java
Created August 26, 2022 08:03
Load properties from a db table and inject them in the Spring Context
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
@mattmusc
mattmusc / word_squares.py
Last active December 12, 2020 16:04
Google Coding Interview
#!/usr/bin/env python3
# Google Former Coding Interview
# https://techdevguide.withgoogle.com/resources/former-coding-interview-question-word-squares/
from itertools import product
import re
import sys
@mattmusc
mattmusc / git_stats.js
Last active October 2, 2020 16:05
Executes git shortlog in a directory specified and creates an array of objects with the # of commits per author - starting point for a repo monitoring app
const { exec } = require("child_process");
const { existsSync } = require("fs");
// -- main -- //
console.log("pid:", process.pid);
getCommits("<dir>")
.then((commits) => console.log(commits))
.catch(({ stderr }) => console.log(stderr));
@mattmusc
mattmusc / jira_sum_my_point_estimates.py
Created April 1, 2020 08:14
Sum Jira Csv Story Point Estimates for all my issues
import csv
import functools
import math
import operator
import sys
def get_estimate(row):
return float(row["Custom field (Story point estimate)"])
def get_issues():
@mattmusc
mattmusc / pom.xml
Created December 1, 2019 15:54
Example of Maven plugin to list all the properties
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<!-- useful to list all the properties specified -->
<execution>
<phase>validate</phase>
@mattmusc
mattmusc / exec_stmt_tables.sql
Created October 24, 2019 13:35
PL/SQL: Execute a statement for all tables starting with 'Prefix'
BEGIN
FOR c IN ( select owner as schema_name, table_name from sys.all_tables where table_name like '--PREFIX--' )
LOOP
EXECUTE IMMEDIATE ' SELECT * FROM ' || c.table_name;
END LOOP;
END;
@mattmusc
mattmusc / docker_compose.yml
Created August 14, 2019 10:11
Set up Gitlab in docker
version: 3
services:
gitlab-ce:
ports:
- '8443:443'
- '8000:80'
- '2222:22'
volumes:
- '/srv/gitlab/config:/etc/gitlab'
- '/srv/gitlab/logs:/var/log/gitlab'
@mattmusc
mattmusc / app.js
Last active June 28, 2019 15:25
Socket.io test
var app = require("express")();
var http = require("http").Server(app);
var io = require("socket.io")(http);
var data = require("./data.js");
var latestData;
data.getData().then(result => {
latestData = result;
});
@mattmusc
mattmusc / promises.js
Last active May 25, 2019 16:35
Udemy - Advanced Web Developer Bootcamp - ES2015 Promises Exercises
import $ from "jquery";
/**
* Using the github developer API, returns the username
* among the list of usernames passed
* with the highest num of followers.
*
* @param {...string} names Array of Github usernames
*/
function getMostFollowers(...names) {
@mattmusc
mattmusc / .eslintrc.js
Created March 6, 2019 11:00
Eslint config
const OFF = 0, WARN = 1, ERROR = 2;
module.exports = exports = {
"env": {
"browser": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",