Skip to content

Instantly share code, notes, and snippets.

View a3linux's full-sized avatar

Allen Chen Jinlong a3linux

View GitHub Profile
@a3linux
a3linux / README.md
Created August 2, 2022 13:16 — forked from mosquito/README.md
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/docker-compose@.service. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
from botocore.credentials import RefreshableCredentials
from botocore.session import get_session
from boto3 import Session
def assumed_session(role_arn, session_name, session=None):
"""STS Role assume a boto3.Session
With automatic credential renewal.
@a3linux
a3linux / Jenkins Pretty Log
Last active March 24, 2022 06:50
A Groovy class for Pretty Log / Output from Jenkins pipeline
/**
* PrettyLog class used for pretty and clean log
*/
class PrettyLog implements Serializable {
def steps
def env
/**
* COnstructor
* @param steps Jenkins pipeline stpes
#!/bin/bash
function usage()
{
echo "Usage: $0 [options] [--]
Options:
-h|help Display this message
-r|region AWS Region
-n|loadbalancername Load balancer name
-p|pathpattern Path pattern"
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
output_file=""
verbose=0
while getopts "h?vf:" opt; do
case "$opt" in
h|\?)
@a3linux
a3linux / install-pulse.sh
Created July 3, 2018 03:34 — forked from tafarij/install-pulse.sh
Install Pulse Secure on Ubuntu 16.04
# https://vt4help.service-now.com/kb_view_customer.do?sysparm_article=KB0010740#linux
wget https://secure.nis.vt.edu/resources/downloads/pulse-8.2R5.i386.deb
sudo dpkg –i pulse-8.2R5.i386.deb
/usr/local/pulse/PulseClient.sh install_dependency_packages
#!/usr/bin/env python
# This module provides support for HP ServiceManager Web Services (WSDL)
# $Id: smcli.py 850 2013-07-24 01:14:07Z gregb $
# The following constants are the tested modules.
INCIDENT = "Incident"
SERVICE_DESK = "Interaction"
CONFIGURATION = "Configuration"
one line fib
fib = lambda n: n if n <= 2 else fib(n-1) + fib(n-2)
super_fib = lambda n: 1 if n < 2 else 2 * super_fib(n-1)
swipe-step search Yang triangle
def stopwise(l, x, m, n):
row = 0
import heapq
class Heap(object):
""" A neat min-heap wrapper which allows storing items by priority
and get the lowest item out first (pop()).
Also implements the iterator-methods, so can be used in a for
loop, which will loop through all items in increasing priority order.
Remember that accessing the items like this will iteratively call
pop(), and hence empties the heap! """
def __init__(self):
# Collections module user cases
* Counter() a dict with counter for example,
cnt = Counter()
cnt[key1] += 1
* namedtuple e.g. Point = namedtuple('Point', ['x', 'y'])
p = Point(1,2)
p.x
p.y