Skip to content

Instantly share code, notes, and snippets.

View chefren's full-sized avatar
🏠
Working from home

Efrén chefren

🏠
Working from home
View GitHub Profile
@chefren
chefren / pre-commit
Last active November 23, 2018 10:46 — forked from jeekl/gist:5083519
git pre-commit hook to validate json objects so you don't commit broken json.
#!/usr/bin/env bash
# Runs all .json files through pythons json lint tool before commiting,
# to make sure that you don't commit broken json objects.
git_dir=$(git rev-parse --show-toplevel)
for file in $(git diff-index --name-only --diff-filter=ACM --cached HEAD -- \
| grep -P '\.(json)$'); do
python -mjson.tool $file 2> /dev/null
if [ $? -ne 0 ] ; then
@chefren
chefren / GPSExif.swift
Created October 11, 2017 23:33 — forked from nitrag/GPSExif.swift
Generate Metadata Exif for GPS
//
// Generate EXIF GPS metadata
// Swift 3
// Exif Version 2.2.0.0 supports decimal degrees
import Foundation
import CoreLocation
import ImageIO
extension CLLocation {

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@chefren
chefren / jenkins-plugins-batch-install.md
Created February 4, 2020 05:57 — forked from hgomez/jenkins-plugins-batch-install.md
Mass install/update of Jenkins Plugins

Scripted Jenkins Plugins install

Jenkins has a very rich catalog of plugins and it's quite easy to install and update them via UI. BTW, when you want to add tons of plugin via UI, it's a fairly long and boring procedure.

Hopefully, mass installation (or update) could be easy using a simple bash script (curl/python required) :

Create a file containing plugins to be installed (or updated), ie iplugins :

@chefren
chefren / install_jenkins_plugin.sh
Created February 4, 2020 05:57 — forked from micw/install_jenkins_plugin.sh
Script to install one or more jenkins plugins including dependencies while jenkins is offline
#!/bin/bash
set -e
if [ $# -eq 0 ]; then
echo "USAGE: $0 plugin1 plugin2 ..."
exit 1
fi
plugin_dir=/var/lib/jenkins/plugins
@chefren
chefren / ACG AWS Challenges.md
Last active February 4, 2022 06:07
ACG AWS Challenges

Linkedin challenge from ACG on AWS

Hello there, I tried the challenges and found it a good way to jump onto serverless and ML services.

So here's a summary blog as some pros and cons tables anyone may find on the challenges.

Challenges

Launch a static website on S3

Comparison of Terraform vs CDK frameworks to use for AWS

Property Value/Behaviour TF Value/Behaviour CDK Opinion
Basic task Define and end state for the system and apply it when appropriate Generate AWS Cloudformation template to work with stack resources CDK benefits from AWS internal service. TF depends on AWS API
Language Terraform Config language Support for Typescrypt, Java, .Net, Go, Python CDK advantage for training with known languages
Backend TF state file (json) AWS Cloudformation TF requires a backend to be setup and hosted (can use S3 and DynamoDB), CDK may require CDK bootstrapping (deploys S3 and IAM through a stack via the tool)
Setup Docker containers available from Hashicorp Requires Node.js to run CDK, then the language platform of choice In both changes different envs with different versions may cause breaking changes if not car
@chefren
chefren / ipset.sh
Created June 16, 2022 00:33 — forked from paulgear/ipset.sh
Stupid ipset hack #1: Count & log unique NTP sources addresses
#!/bin/sh
set -eu
PROTO='udp'
PORT='123'
LOG='NTP'
CHAIN=ntplog
SET=ntplog
MAXELEM=33554432
HASHSIZE=65535