Skip to content

Instantly share code, notes, and snippets.

View saidsef's full-sized avatar
👻
Building stuff

Said Sef saidsef

👻
Building stuff
View GitHub Profile
@saidsef
saidsef / extract.groovy
Last active August 23, 2017 21:27
Groovy! - Read pom.xml File
#!/usr/bin/env groovy
import java.util.*
import groovy.util.XmlParser
def pom = new File('pom.xml').getText('utf-8')
def doc = new XmlParser().parseText(pom)
def version = doc.version.text()
println(version)
import org.jsoup.Jsoup
def document = Jsoup.connect('https://api.github.com/repos/saidsef/alpine-jenkins-dockerfile-demo/releases/latest')ignoreContentType(true).execute().body()
def json = new groovy.json.JsonSlurper().parseText(document)
println(json.tag_name)
@saidsef
saidsef / magic_mouse.py
Last active January 15, 2018 03:43
Magic Mouse - Keep awake
#!/usr/bin/env python
# Copyright (c) 2018, Said Sef. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
##
# You'll need to install pynput
# pip install pynput
##
from pynput.mouse import Button, Controller, Listener
@saidsef
saidsef / hcl_tf_iam_role_policy.py
Last active January 15, 2018 03:43
Print IAM Role Policy as YAML
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Said Sef. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
__author__ = 'Said Sef'
import hcl
import json
import yaml
@saidsef
saidsef / app.py
Last active January 15, 2018 03:43
Flask API - Available Endpoints
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Said Sef. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
from flask import Flask, jsonify
app = Flask(__name__)
@saidsef
saidsef / polly.py
Last active January 15, 2018 03:44
AWS Polly - Read to me
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Said Sef. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
import boto3
import tempfile
import logging
from voices import Voices
@saidsef
saidsef / apigw_swagger.json
Last active March 7, 2018 21:24
AWS API Gateway VPC Link - Swagger
{
"swagger": "2.0",
"info": {
"version": "2017-11-17T04:40:23Z",
"title": "TestVPCLink"
},
"basePath": "/",
"schemes": [
"https"
],
# As a prerequisite you'll need to install Docker and pip install aws-sam-cli
# Also, remeber to build you package `npm install`
sam init --runtime nodejs8.10
sam local generate-event api -m GET -b "" | sam local invoke HelloWorldFunction
sam package \
--template-file teamplate.yaml \
--output-template-file package.yaml \
--s3-bucket <s3-bucket-name>
@saidsef
saidsef / swarm.service
Last active August 9, 2018 22:21
Swarm Service Manager
[Unit]
# Location: /usr/lib/systemd/system : systemctl enable swarm
Description=swarm service manager
Documentation=https://plugins.jenkins.io/swarm
Wants=network-online.target
After=network-online.target
StartLimitIntervalSec=0
[Service]
Type=simple