Skip to content

Instantly share code, notes, and snippets.

@actionjack
actionjack / README-oneshot-systemd-service.md
Created September 7, 2018 15:17 — forked from drmalex07/README-oneshot-systemd-service.md
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

@actionjack
actionjack / pd-event.sh
Created July 17, 2018 08:41 — forked from alperkokmen/pd-event.sh
Simple script to trigger, acknowledge, and resolve incidents via PagerDuty Integration API.
#!/bin/bash
CONTENT_TYPE="application/json"
DESCRIPTION="bad things™ are happening"
URL="https://events.pagerduty.com/generic/2010-04-15/create_event.json"
if [ $# -ne 3 ]; then
echo "Usage: pd-event.sh [TYPE] [SERVICE KEY] [INCIDENT KEY]"
echo " - TYPE: [t]rigger | [a]cknowledge | [r]esolve"
echo " - SERVICE KEY: unique identifier for service"
@actionjack
actionjack / cleanup.py
Created May 2, 2018 13:23 — forked from luhn/cleanup.py
An AWS Lambda function to delete old AMIs.
"""
Code adapted from and inspired by http://blog.ranman.org/cleaning-up-aws-with-boto3/.
"""
import os
import re
from datetime import datetime, timedelta
import boto3
1. Setup a project
2. Add groovy SDK support:
https://www.bonusbits.com/wiki/HowTo:Add_Groovy_SDK_to_IntelliJ_IDEA
3. Download http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/gdsl
- this will give you the .gdsl file - download this to the src folder of your project.
4. Finally follow this step - right click on the src folder -> Mark directory as -> Sources Root
import time
from boto.ec2.autoscale import AutoScaleConnection
def find_unused_launch_configs():
conn = AutoScaleConnection()
autoscale_groups = conn.get_all_groups(max_records=100)
launch_configs = conn.get_all_launch_configurations(max_records=100)
launch_config_names = {lc.name for lc in launch_configs}
var time = 60; var clock = 300; function TimeHack(){
setInterval(function Applytime() {
document.getElementsByClassName('timerLabel whiteTextWithShadow font-60 ng-binding')["0"].innerText = time; document.getElementsByClassName('timerLabel whiteTextWithShadow font-60 ng-binding')["0"].innerHtml = time;
document.getElementsByClassName('clockHand').rotate = clock;
}, 1);}; function TimeHackm() {
setInterval(function Addtime() {
time = time + 1;
clock = clock + 6;
}, 1000);}
var score = 1;
@actionjack
actionjack / aws-s3-policy-minimum-privs.txt
Created October 27, 2017 10:52 — forked from jackl0phty/aws-s3-policy-minimum-privs.txt
How to Create an AWS S3 Bucket, tag it, Specify Region, & Enable Versioning Using Ansible.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "statement1",
"Effect": "Allow",
"Action": [
"s3:Put*",
"s3:Get*",
"s3:List*",
@actionjack
actionjack / opt1_template.j2
Created October 20, 2017 15:11 — forked from halberom/opt1_template.j2
ansible - example of template if else
{% if filepath == /var/opt/tomcat_1 %}
{% set tomcat_value == tomcat_1_value %}
{% else %}
{% set tomcat_value == tomcat_2_value %}
{% endif %}
<Server port={{ tomcat_value }} shutdown="SHUTDOWN">
@actionjack
actionjack / Jenkinsfile
Created September 29, 2017 07:57 — forked from chinshr/Jenkinsfile
Best of Jenkinsfile, a collection of useful workflow scripts ready to be copied into your Jenkinsfile on a per use basis.
#!groovy
# Best of Jenkinsfile
# `Jenkinsfile` is a groovy script DSL for defining CI/CD workflows for Jenkins
node {
}
@actionjack
actionjack / sonar.md
Created June 23, 2017 15:17 — forked from sysboss/sonar.md
SonarQube on AWS EC2 - Installation and integration with Jenkins

This article will briefly describe how to install SonarQube as Docker container on Amazon EC2 and integrate it with Jenkins.

Create database instance and user

Go to RDS > Parameter Groups
Create a new Parameter Group with the following parameter:

max_allowed_packet = 268435456

We need to create a new RDS database for SonarQube (you may use an existing MySQL instance)

  1. Go to RDS Instances