Skip to content

Instantly share code, notes, and snippets.

View MaurizioCasciano's full-sized avatar
👨‍💻
Turning Bits ON & OFF

Maurizio Casciano MaurizioCasciano

👨‍💻
Turning Bits ON & OFF
View GitHub Profile
@MaurizioCasciano
MaurizioCasciano / nexus-repo-manager-privilege-example.groovy
Created December 20, 2021 23:36 — forked from nblair/nexus-repo-manager-privilege-example.groovy
A groovy script to create Content Selectors, privileges, and roles programmatically via the Nexus Repository Manager 3 Scripting API.
import org.sonatype.nexus.common.entity.*
import org.sonatype.nexus.security.*
import org.sonatype.nexus.security.authz.*
import org.sonatype.nexus.selector.*
import com.google.common.collect.ImmutableMap
// use container.lookup to fetch internal APIs we need to use
def selectorManager = container.lookup(SelectorManager.class.name)
def securitySystem = container.lookup(SecuritySystem.class.name)
@MaurizioCasciano
MaurizioCasciano / SpringBoot15Application.java
Created July 7, 2020 09:33 — forked from dogeared/SpringBoot15Application.java
spring boot 1.5.x with spring security 4 vs. spring boot 2.1.3 with spring security 5
@EnableOAuth2Sso
@RestController
@SpringBootApplication
public class OAuth2DemoApplication_1_5 {
@Value("#{ @environment['security.oauth2.resource.server'] }")
private String resourceServerUrl;
private OAuth2ProtectedResourceDetails resource;

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

@MaurizioCasciano
MaurizioCasciano / create-docker-tls.sh
Created May 19, 2020 15:47 — forked from Stono/create-docker-tls.sh
Creating and setting up Docker for TLS
#!/bin/bash
# This script will help you setup Docker for TLS authentication.
# Run it passing in the arguement for the FQDN of your docker server
#
# For example:
# ./create-docker-tls.sh myhost.docker.com
#
# The script will also create a profile.d (if it exists) entry
# which configures your docker client to use TLS
#
@MaurizioCasciano
MaurizioCasciano / reconnect.diff
Created April 30, 2020 03:28 — forked from mikeyk/reconnect.diff
Automatically retry on AutoReconnect exception in pymongo
diff --git a/pymongo/connection.py b/pymongo/connection.py
index b444f50..7635c78 100644
--- a/pymongo/connection.py
+++ b/pymongo/connection.py
@@ -46,6 +46,7 @@ from pymongo import (database,
helpers,
message)
from pymongo.cursor_manager import CursorManager
+from pymongo.decorators import reconnect
from pymongo.errors import (AutoReconnect,
#!/bin/bash
KC_REALM=<insert realm name here>
KC_USERNAME=<username here>
KC_PASSWORD=<password here>
KC_CLIENT=<client name here>
KC_CLIENT_SECRET=<client secret here>
KC_SERVER=<server address and port here>
KC_CONTEXT=auth
@MaurizioCasciano
MaurizioCasciano / LICENCE SUBLIME TEXT
Created September 22, 2018 22:55
Sublime Text 3 Serial key build is 3176
## Sublime Text 3 Serial key build is 3176
> * Added these lines into /etc/hosts
127.0.0.1 www.sublimetext.com
127.0.0.1 license.sublimehq.com
> * Used the license key
----- BEGIN LICENSE -----

install nodejs & npm

sudo apt-get install nodejs
sudo apt-get install npm

fix naming issue of node to ubuntu

ln -s /usr/bin/nodejs /usr/bin/node
@MaurizioCasciano
MaurizioCasciano / docker_kill.sh
Created March 22, 2018 07:41 — forked from evanscottgray/docker_kill.sh
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt
public class AnnotationHelper {
private static final String ANNOTATIONS = "annotations";
public static final String ANNOTATION_DATA = "annotationData";
public static boolean isJDK7OrLower() {
boolean jdk7OrLower = true;
try {
Class.class.getDeclaredField(ANNOTATIONS);
} catch (NoSuchFieldException e) {
//Willfully ignore all exceptions