Skip to content

Instantly share code, notes, and snippets.

View johnymachine's full-sized avatar

Jan Gabriel johnymachine

View GitHub Profile
@johnymachine
johnymachine / gist:29932f12815996c5fae5fdfbeea00e56
Last active September 22, 2023 16:08
Get unused AWS Security Groups
#!/bin/bash
SECURITY_GROUPS=$(aws ec2 describe-security-groups --query "SecurityGroups[?GroupName!='default'].{Name: GroupName, Id: GroupId}" --output json)
# Iterate over each security group
echo "$SECURITY_GROUPS" | jq -c -r '.[]' | while read -r line; do
# Extract the security group ID, name, and association count
groupId=$(echo "$line" | jq -r '.Id')
groupName=$(echo "$line" | jq -r '.Name')
#!/bin/bash
# ssm_helper.sh - AWS Systems Manager Parameter Store Helper Script
echo -e "\e[1mAWS Systems Manager Parameter Store Helper Script\e[0m"
# Check if AWS CLI is installed
command -v aws >/dev/null 2>&1 || { echo >&2 "AWS CLI is required but not installed. Aborting."; exit 1; }
# Check if jq is installed
command -v jq >/dev/null 2>&1 || { echo >&2 "JQ is required but not installed. Aborting."; exit 1; }
param (
[Parameter(
Mandatory = $true,
HelpMessage = "Source directory for backup."
)]
[string]$sourceDirectory,
[Parameter(
Mandatory = $true,
HelpMessage = "Destination directory for archive."
)]
@johnymachine
johnymachine / HeaderAuth.java
Created August 7, 2017 11:31
Thingworx custom header Authentificator with optional blacklist or whitelists.
package cz.foxon.auth.headerauthentificator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import com.thingworx.logging.LogUtilities;
import com.thingworx.metadata.annotations.ThingworxConfigurationTableDefinition;
import com.thingworx.metadata.annotations.ThingworxConfigurationTableDefinitions;
@johnymachine
johnymachine / widget-barletta-alert.php
Created August 1, 2017 19:49
WP - Bootstrap alert
<?php
/**
* Custom Alert Text Widget
*
* @package Barletta
*/
class barletta_alert_text extends WP_Widget {
public function __construct(){
$widget_ops = array('classname' => 'barletta-alert-text','description' => esc_html__( "Barletta Alert Text Widget", 'barletta') );
@johnymachine
johnymachine / widget-barletta-latest-post.php
Created August 1, 2017 19:48
WP - Latest post from category
<?php
/**
* Custom Latest Post By Category Widget
*
* @package Barletta
*/
class barletta_latest_post extends WP_Widget {
public function __construct(){
$widget_ops = array('classname' => 'barletta-latest-post','description' => esc_html__( "Barletta Latest Post Widget", 'barletta') );
@johnymachine
johnymachine / node-red.service
Created November 23, 2016 12:44
systemd file
[Unit]
Description=Node-RED
After=syslog.target network.target
[Service]
ExecStart=/usr/bin/node /home/node-red/node_modules/node-red/red
Restart=on-failure
KillSignal=SIGINT
User=node-red
# ThingWorx CentOs installation guide
Installation guide for ThingWorx 7.2 on CentoOs 7, which OS similiar to RedHat Enterprise Linux. For details, see [this post](http://unix.stackexchange.com/questions/27323/is-centos-exactly-the-same-as-rhel).
For ThingWorx official documentation reffer to:
- [ThingWorx_Core_7.2_System_Requirements_1.pdf](http://support.ptc.com/WCMS/files/171020/en/ThingWorx_Core_7.2_System_Requirements_1.pdf)
- [Installing_ThingWorx_7.2_1.pdf](http://support.ptc.com/WCMS/files/171019/en/Installing_ThingWorx_7.2_1.pdf)
Essentialy minimal required software version are:
/**
*
*/
package cz.foxon.auth;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
package foxon.auth;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.thingworx.resources.entities.EntityServices;
import com.thingworx.security.authentication.AuthenticatorException;
import com.thingworx.security.authentication.CustomAuthenticator;