Skip to content

Instantly share code, notes, and snippets.

@wshihadeh
wshihadeh / Dockerfile
Created December 17, 2019 12:45
Clair Dockerfile
FROM quay.io/coreos/clair:v2.1.2
LABEL maintainer="AL-waleed Shihadeh <[email protected]>"
ENV BUILD_DEPS="gettext" \
RUNTIME_DEPS="libintl"
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
@wshihadeh
wshihadeh / docker-entrypoint.sh
Created December 17, 2019 12:47
Clair entrypoint
#!/bin/sh -e
/usr/local/bin/envsubst < /etc/clair/config.yaml.tpl > /etc/clair/config.yaml
case $1 in
clair)
/usr/bin/dumb-init -- /clair -config /etc/clair/config.yaml
;;
@wshihadeh
wshihadeh / priority_list.rb
Created December 21, 2019 11:43
PriorityList class
# frozen_string_literal: true
class PriorityList
def initialize(list)
@mode = ENV.fetch('APPLICATION_MODE', 'ascending')
@list = list
end
def priority_list
case @mode
@wshihadeh
wshihadeh / priority_list_spec.rb
Last active December 21, 2019 12:12
PriorityList Unit Tests
# frozen_string_literal: true
describe PriorityList do
let(:list) { [1, 4, 6, 3, 7, 3, 0, 20, 3] }
describe '#priority_list' do
context 'ascending mode' do
before do
ENV['APPLICATION_MODE'] = 'ascending'
end
@wshihadeh
wshihadeh / priority_list_spec.rb
Created December 21, 2019 12:20
PriorityList Rspec unit tests
# frozen_string_literal: true
describe PriorityList do
let(:list) { [1, 4, 6, 3, 7, 3, 0, 20, 3] }
describe '#priority_list' do
context 'ascending mode' do
before do
allow(ENV).to receive(:fetch).with('APPLICATION_MODE', 'ascending')
.and_return('ascending')
@wshihadeh
wshihadeh / ec2_lambda_handler.py
Last active February 20, 2024 06:07
Python script for Stopping and Starting EC2 instances
import boto3
region = 'eu-central-1'
ec2 = boto3.client('ec2', region_name=region)
response = ec2.describe_instances(Filters=[
{
'Name': 'tag:Auto-Start',
'Values': [
'true',
]
},
@wshihadeh
wshihadeh / main.tf
Last active February 5, 2024 09:36
Terraform script for defining stop and start functionality for EC2 instances
resource "aws_iam_policy" "stop_start_ec2_policy" {
name = "StopStartEC2Policy"
path = "/"
description = "IAM policy for stop and start EC2 from a lambda"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
@wshihadeh
wshihadeh / .overcommit.yml
Last active January 12, 2020 18:45
Overcommit Configurations
gemfile: false
# Where to store hook plugins specific to a repository. These are loaded in
# addition to the default hooks Overcommit comes with. The location is relative
# to the root of the repository.
plugin_directory: '.git-hooks'
# Whether to hide hook output by default. This results in completely silent hook
# runs except in the case of warning or failure.
quiet: false
@wshihadeh
wshihadeh / docker-compose.yml
Created January 17, 2020 14:41
Portainer Docker Compose file
version: '3.7'
networks:
portainer:
name: portainer
driver: overlay
attachable: true
services:
agent:
@wshihadeh
wshihadeh / bootstrap.ldif
Last active September 26, 2021 16:30
LDAP bootstrap file
dn: cn=developer,dc=shihadeh,dc=intern
changetype: add
objectclass: inetOrgPerson
cn: developer
givenname: developer
sn: Developer
displayname: Developer User
mail: [email protected]
userpassword: developer_pass