Skip to content

Instantly share code, notes, and snippets.

Avatar

Florin Asăvoaie FlorinAsavoaie

  • Hindawi Limited
  • Iasi, Romania
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am florinasavoaie on github.
  • I am florinasavoaie (https://keybase.io/florinasavoaie) on keybase.
  • I have a public key ASDHzbcUhziPjeXerU-1JQ_TnBm8653MpymqC9M6hSxTqAo

To claim this, I am signing this object:

@FlorinAsavoaie
FlorinAsavoaie / lambda-codecommit-trigger-codebuild.py
Last active Jun 2, 2018
AWS Lambda functions that you can set to be triggered by Codecommit push triggers and it will trigger builds on any CodeBuild Project that has this repository as source.
View lambda-codecommit-trigger-codebuild.py
import boto3
codecommit = boto3.client('codecommit')
codebuild = boto3.client('codebuild')
def trigger_build(project, commit, branch):
codebuild.start_build(projectName=project, sourceVersion=commit,
environmentVariablesOverride=[
{ 'name': 'ENVIRONMENT', 'value': branch, 'type': 'PLAINTEXT' }
])
@FlorinAsavoaie
FlorinAsavoaie / systemd_running_services.py
Last active Oct 6, 2017
External Puppet fact listing running services on a SystemD machine. Depends on python-dbus.
View systemd_running_services.py
#!/usr/bin/env python
# This is to be used as an external Puppet fact that can tell you what are the
# currently running services (not all units!) on a SystemD machine.
from dbus import SystemBus, Interface
import re
manager = Interface(
SystemBus().get_object('org.freedesktop.systemd1', '/org/freedesktop/systemd1'),
'org.freedesktop.systemd1.Manager')
@FlorinAsavoaie
FlorinAsavoaie / yum_leaf_packages.py
Last active Oct 6, 2017
External Puppet fact listing leaf packages of Yum, without depending on yum-utils.
View yum_leaf_packages.py
#!/usr/bin/env python
# This is to be used as an external Puppet fact that can tell you what are the
# leaf packages (the ones that no other package has a dependency on) installed
# on RHEL based a machine.
import logging
from yum import YumBase
logging.getLogger('yum.verbose.YumPlugins').setLevel(logging.CRITICAL)
View msysgit2unix-socket.py
#!/usr/bin/python
"""
msysGit to Unix socket proxy
============================
This small script is intended to help use msysGit sockets with the new Windows Linux Subsystem (aka Bash for Windows).
It was specifically designed to pass SSH keys from the KeeAgent module of KeePass secret management application to the
ssh utility running in the WSL (it only works with Linux sockets). However, my guess is that it will have uses for other
@FlorinAsavoaie
FlorinAsavoaie / function-working_days.sql
Created Dec 8, 2015
This function returns the number of working days (Monday to Friday) between 2 dates.
View function-working_days.sql
-- This function returns the number of working days (Monday to Friday) between 2 dates.
-- Tested on PostGreSQL 9.4.
-- Usage: SELECT working_days('2016-01-01'::date, '2016-01-31'::date);
CREATE OR REPLACE FUNCTION working_days(date, date) RETURNS INT AS
$$
SELECT COUNT(days)::INT
FROM generate_series($1, $2, '1 day') AS days
WHERE EXTRACT(DOW FROM days) NOT IN(0, 6);
$$
@FlorinAsavoaie
FlorinAsavoaie / cloudflare-ipset.sh
Created Jun 29, 2015
Bash script to update CloudFlare IPs in an ipset
View cloudflare-ipset.sh
#!/bin/bash
IPSET="/usr/sbin/ipset"
CURL="/usr/bin/curl"
DATE="/bin/date"
for VER in 4 6; do
URL="https://www.cloudflare.com/ips-v$VER"
SET_NAME="CloudFlare.IPv$VER"