Skip to content

Instantly share code, notes, and snippets.

const fs = require('fs');
/**
* This script transfers bash history to zsh history
* Change bash and zsh history files, if you don't use defaults
*
* Usage: node bash_to_zsh_history.js
*
* Author: Matteo Gaggiano
*/
#!/usr/bin/env bash
DATABASE_URL="postgres://MyPostgresUser:MyPostgresPassword@192.168.0.1:5432/MyPostgresDB"
# `cut` is used to cut out the separators (:, @, /) that come matched with the groups.
DATABASE_USER=$(echo $DATABASE_URL | grep -oP "postgres://\K(.+?):" | cut -d: -f1)
DATABASE_PASSWORD=$(echo $DATABASE_URL | grep -oP "postgres://.*:\K(.+?)@" | cut -d@ -f1)
DATABASE_HOST=$(echo $DATABASE_URL | grep -oP "postgres://.*@\K(.+?):" | cut -d: -f1)
DATABASE_PORT=$(echo $DATABASE_URL | grep -oP "postgres://.*@.*:\K(\d+)/" | cut -d/ -f1)
@marchrius
marchrius / keybase.md
Created December 9, 2020 09:03
Keybase proof

Keybase proof

I hereby claim:

  • I am marchrius on github.
  • I am marchrius (https://keybase.io/marchrius) on keybase.
  • I have a public key whose fingerprint is 4D58 6729 4E67 8AC7 B0C5 CA9C BC90 5688 7987 1E01

To claim this, I am signing this object:

@marchrius
marchrius / Example.java
Last active July 28, 2020 09:55
Maps builder utility
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.marchirus.utils.Maps;
public class Example { public static void main(String[] args) {
Maps.Builder<String, String> builder = Maps.builder();
builder.pair("Key1", "Value1")
.key("Key2").value("Value2")
{
"name": "load-google-maps",
"version": "1.0.0",
"authors": ["Glenn Baker", "Gavin Foley", "Matteo Gaggiano"],
"description": "Load Google Maps API using jQuery Deferred.",
"main": "load-google-maps.js",
"keywords": ["Google Maps", "Async"],
"license": ["MIT", "GPL"],
"dependencies": {
"jquery": ">=1.5"
import * as ion from 'ionicons/icons';
import {NbIcons} from "@nebular/theme/components/icon/icon-pack";
function map(icon: string) {
return icon.replace('data:image/svg+xml;utf8,', '');
}
export const NbIonIcons: NbIcons = {
'add': map(ion.add),
'add-circle': map(ion.addCircle),
body { background: #222; color: #e6e6e6; }
a { color: #949494; }
a:link, a:visited { color: #949494; }
a:hover, a:active, a:focus { color: #c7c7c7; }
hr { border-bottom: 1px solid #424242; border-top: 1px solid #222; }
@marchrius
marchrius / example.php
Created October 12, 2017 08:45
Visit object with a path (object and array)
<?php
include_once __DIR__ . '/helpers.php';
$data = ((object)[
"name" => "Matteo",
"surname" => "Gaggiano",
"age" => 25,
"github" => ((object)[
"username" => "Marchrius",
@marchrius
marchrius / checkport.sh
Last active April 22, 2017 10:45
checkport - check if one or more TCP ports are opened
#!/bin/bash
#
# Created by: Matteo Gaggiano on 22/04/2017
# Base script by: stojg at https://gist.github.com/stojg/70a15a84900da72ff2b5
#
# Changelog 22/04/2017 :
# - Added support for multi-port check
#
function usage() {