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 / 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
@a3linux
a3linux / gist:29ea91ce8f5cb40b1265882f8ac6374a
Created June 18, 2018 04:33 — forked from eternnoir/gist:7701964
pandoc markdown to pdf chinese template
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
\usepackage{titlesec}
\titleformat{\section}{\LARGE\filcenter}{}{1em}{}
\titleformat{\subsection}{\Large\filcenter}{}{1em}{}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
@a3linux
a3linux / role_arn_to_session.py
Created April 11, 2018 08:09 — forked from gene1wood/role_arn_to_session.py
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""
@a3linux
a3linux / ec2-ami-region-map.py
Created January 31, 2018 06:13 — forked from pacohope/ec2-ami-region-map.py
Given a starting public AWS AMI, generate a YAML list of AMI IDs for that AMI in all AWS regions.
#
# Given the ID of an Amazon public AMI in one region, figure out what the
# equivalent AMI IDs are for that same AMI in all other regions known.
# If that AMI isn't defined in a region, it prints the region's name, but
# comments it out.
#
from __future__ import print_function
import boto3
@a3linux
a3linux / .jsbeautifyrc
Created March 23, 2017 08:36 — forked from softwarespot/.jsbeautifyrc
JS Beautifier configuration
// Documentation: https://github.com/beautify-web/js-beautify
// Example URL: https://github.com/victorporof/Sublime-HTMLPrettify/blob/master/.jsbeautifyrc
// Based on Airbnb's JavaScript Style Guide, URL: https://github.com/airbnb/javascript
{
// Collapse curly brackets
"brace_style": "collapse",
// Break chained method calls across subsequent lines
"break_chained_methods": true,
@a3linux
a3linux / gist:4d0ab1cf13d11fcf0f96281a47692e8f
Created November 3, 2016 01:35 — forked from rhelmer/gist:d3d99bd60e81be10f759
quick sync setup runner for symbols
#!/bin/bash
set -e
. /home/socorro/.virtualenvs/aws/bin/activate
PRIVATE_BUCKET="org.mozilla.crash-stats.symbols-private/v1"
PUBLIC_BUCKET="org.mozilla.crash-stats.symbols-public/v1"
TOP_DIR="/mnt/socorro/symbols"
PRIVATE_DIRS="symbols_adobe"
@a3linux
a3linux / gist:602ea54fc8ab771459332039425dc46e
Created November 3, 2016 01:35 — forked from rhelmer/gist:a053aedb863ef3d7d317
quick sync script for symbols
#!/usr/bin/env python
"""
A quick sync script for symbols from NFS->S3
We can't simply record the time our sync script ran and find all newer files
since files with timestamps in the past may appear. So, keep track of all .txt
index files that we encounter, and only sync files when there are additions
to that set.
"""
@a3linux
a3linux / curl-ttfb.sh
Created March 1, 2016 03:11 — forked from acdha/curl-ttfb.sh
Use curl to measure and report HTTP response times (pre-, start- and total transfer)
#!/bin/bash
#
# Report time to first byte for the provided URL using a cache buster to ensure
# that we're measuring full cold-cache performance
while (($#)); do
echo $1
curl -so /dev/null -H "Pragma: no-cache" -H "Cache-Control: no-cache" \
-w "%{http_code}\tPre-Transfer: %{time_pretransfer}\tStart Transfer: %{time_starttransfer}\tTotal: %{time_total}\tSize: %{size_download}\n" \
"$1?`date +%s`"