Skip to content

Instantly share code, notes, and snippets.

View FlorinAsavoaie's full-sized avatar

Florin Asăvoaie FlorinAsavoaie

View GitHub Profile
#!/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 / cloudflare-ipset.sh
Created June 29, 2015 12:47
Bash script to update CloudFlare IPs in an ipset
#!/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"

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 June 2, 2018 12:17
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.
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 October 6, 2017 16:38
External Puppet fact listing running services on a SystemD machine. Depends on python-dbus.
#!/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 October 6, 2017 16:38
External Puppet fact listing leaf packages of Yum, without depending on yum-utils.
#!/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)
@FlorinAsavoaie
FlorinAsavoaie / function-working_days.sql
Created December 8, 2015 22:12
This function returns the number of working days (Monday to Friday) between 2 dates.
-- 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);
$$