Skip to content

Instantly share code, notes, and snippets.

View frg's full-sized avatar
:shipit:

Jean Farrugia frg

:shipit:
View GitHub Profile
@frg
frg / README.md
Last active August 9, 2023 11:50
View README.md

Automated Backup to SMB

This script provides an automated solution for backing up data to an SMB share, with features like pruning old backups, bandwidth limiting, and notifications via Discord.

Features:

  • Backup to SMB: Backs up specified directory to an SMB share.
  • Pruning: Automatically deletes backups older than a specified number of days.
  • Bandwidth Limiting: Limits the bandwidth used during backup.
  • Notifications: Sends notifications to Discord on start, completion, and on errors.
  • Scheduled Backups: Allows scheduling of the backup operation using crontab.
@frg
frg / README.md
Created May 1, 2023 22:28
Get Octopus Deployment Details from Project and Release inc. from git commit
View README.md

Octopus Deploy Details

This script fetches deployment details for a specific release version of a project in Octopus Deploy.

Usage

./octopus_deploy_details.sh \
    --octopus-url <octopus_url> \
 --api-key  \
@frg
frg / README.md
Last active April 30, 2023 08:19
View README.md

Find which version(s) a commit is in (GitFlow)

A Bash script that helps you find branches containing a specific commit in a Git repository. The script filters branches based on the GitFlow naming conventions. The output lists the versions in which the commit exists, sorted according to SemVer.

Usage

./find_commit_versions.sh -c <commit-hash> [-r <repository-path>]
@frg
frg / README.md
Created April 29, 2023 07:35
Clone (or Pull) Bitbucket Cloud Repositories
View README.md

Clone (or Pull) Bitbucket Cloud Repositories

This bash script is designed to synchronize repositories from Bitbucket Cloud to a local machine in an organized manner. Its primary purpose is to ensure that repositories are readily available locally when needed, rather than serving as a backup solution for the repositories. By cloning and updating repositories efficiently, the script streamlines access to the respositories in a workspace.

Usage

./sync_bitbucket_repos.sh \
    -u <username> \
 -p  \
@frg
frg / uncle_bob_scribe_oath.md
Created July 3, 2017 20:58 — forked from ebramanti/uncle_bob_scribe_oath.md
Uncle Bob Scribe's Oath
View uncle_bob_scribe_oath.md

Uncle Bob - Scribe's Oath

  1. I will not produce harmful code.
    • I will not intentionally write code with bugs.
    • This means: Do your best.
  2. I will not produce code that's not my best.
  3. I will provide with each release a quick, testable & repeatable proof that the code works.
  4. I will not avoid release that will impede progress.
    • Short term rapid releases
  5. I will fearlessly and relentlessly improve the quality of code.
  • I will never make the code worse.
@frg
frg / tocamelcase.js
Created January 15, 2016 10:23
JS - To Camel Case
View tocamelcase.js
String.prototype.toCamelCase = function() {
return this.replace(/(?:[^a-zA-Z\d\s\w:]|[A-Z]|\b\w|\s+)/g, function(match, index) {
if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
return index == 0 ? match.toLowerCase() : match.toUpperCase();
}).replace(/[^a-zA-Z\d\s:]/g, '');
};
@frg
frg / totitlecase.js
Created January 15, 2016 10:23
JS - To Title Case
View totitlecase.js
String.prototype.toTitleCase = function () {
return this
.replace(/\w\S*/g, function(txt){
return txt
.charAt(0)
.toUpperCase() + txt.substr(1).toLowerCase();
});
;
};
@frg
frg / toslug.js
Last active January 15, 2016 10:21
JS - To Slug
View toslug.js
String.prototype.toSlug = function (replaceWith) {
replaceWith = replaceWith || '-';
var str = this.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;";
var to = "aaaaaeeeeeiiiiooooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
@frg
frg / PalindromeCheck.java
Created December 17, 2011 14:17
Debugging chris's PalindromeCheck code.
View PalindromeCheck.java
import javax.swing.JOptionPane;
import java.lang.String;
public class PalindromeCheck
{
public static void main(String[]args)
{
String terminate = "exit";
String wordOne = "";
@frg
frg / ShapeCalculator.java
Created December 16, 2011 12:20
Using JOptionPane, design a Shape Calculator which is able to carry out an Area and a Perimeter calculation on a Square, Rectangle and a Circlel. You should provide a Main Menu where the User can select a particular Task to perform.
View ShapeCalculator.java
import javax.swing.*;
import java.lang.Math;
public class ShapeCalculator
{
boolean quit = false;
public static void main (String args[]) throws Exception
{
ShapeCalculator clas = new ShapeCalculator();