Skip to content

Instantly share code, notes, and snippets.

View stafot's full-sized avatar
🐧

Stavros Foteinopoulos stafot

🐧
View GitHub Profile
@superdaigo
superdaigo / zabbix-alert-smtp.sh
Created September 20, 2012 04:58
Zabbix SMTP Alert script for gmail
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Zabbix SMTP Alert script for gmail.
"""
import sys
import smtplib
from email.MIMEText import MIMEText
from email.Header import Header
@cuibonobo
cuibonobo / Large-app-how-to.md
Last active March 6, 2024 18:40
How to structure a large application in Flask. Taken from the Flask wiki: https://github.com/mitsuhiko/flask/wiki/Large-app-how-to

Here's an example application that uses the pattern detailed below: https://github.com/tantastik/talent-curator


This document is an attempt to describe the first step of a large project structure with flask and some basic modules:

  • SQLAlchemy
  • WTForms

Please feel free to fix and add your own tips.

@alexsapran
alexsapran / pre-commit
Last active December 22, 2016 11:08
Terraform client git hook
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
# check if there is a change in the tfstate file
TFSTATE=`git diff --cached --name-status | awk '$1 != "R" { print $2 }' |grep tfstate |wc -l`
if [ $TFSTATE -ne 0 ]
then
@skounis
skounis / cors-test.sh
Created February 12, 2016 13:38
Test CORS headers with curl
#!/bin/bash
curl -X GET -H "Origin: http://example.com" --verbose http://foo.com/bar
curl -X POST -H "Origin: http://example.com" --verbose http://foo.com/bar
curl -X PUT -H "Origin: http://example.com" --verbose http://foo.com/bar
@alexsapran
alexsapran / aws.zsh
Last active October 12, 2018 05:02
AWS CLI bash wrapper dot file
_warning(){
echo -e "\e[31m${@}\e[0m"
}
_info(){
echo -e $@
}
_success(){
echo -e "\e[32m${@}\e[0m"
}
@xigang
xigang / sort_time.go
Created May 4, 2017 04:04
Sorting by time.Time in Golang
package main
import (
"fmt"
"sort"
"time"
)
type reviews_data struct {
review_id string
@thisisshi
thisisshi / emojis.js
Last active April 8, 2019 07:39
Quick and Dirty Emoji Export from Slack
// Go to: https://<team>.slack.com/customize/emoji
// Open Developer Console
// Copy/Paste and Run this in the console:
var spans = document.getElementsByTagName('span');
var basharray = "( "
for (var i=0;i<spans.length;i++) {
var link = spans[i].getAttribute("data-original");
if(link != null){
basharray = basharray.concat(link, " ")
@iMilnb
iMilnb / README.md
Last active January 18, 2024 08:08
AWS Terraform configuration: Stream CloudWatch Logs to ElasticSearch

Rationale

This snippet is a sample showing how to implement CloudWatch Logs streaming to ElasticSearch using terraform. I wrote this gist because I didn't found a clear, end-to-end example on how to achieve this task. In particular, I understood the resource "aws_lambda_permission" "cloudwatch_allow" part by reading a couple of bug reports plus this stackoverflow post.

The js file is actually the Lambda function automatically created by AWS when creating this pipeline through the web console. I only added a endpoint variable handling so it is configurable from terraform.

@pmoust
pmoust / root.sh
Last active March 20, 2018 08:50
dockah
docker run -it --rm --security-opt=seccomp:unconfined \
--security-opt=apparmor:unconfined \
--privileged --pid=host --userns=host \
debian:jessie@sha256:51cd80bb935b76fbbf49640750736abc63ab7084d5331e198326b20063e7f13c \
nsenter -t 1 -m -u -n -i -F /bin/sh
@mhausenblas
mhausenblas / cli-fu.md
Created July 5, 2018 13:30
Michael's bash snippets