Skip to content

Instantly share code, notes, and snippets.

View cowgill's full-sized avatar

David Cowgill cowgill

View GitHub Profile
@devhero
devhero / flask_tips
Last active August 16, 2021 09:50
flask tips
# from http://flask.pocoo.org/docs/1.0/cli/
# Setting Command Options
# Click is configured to load default values for command options from environment variables. The variables use the pattern FLASK_COMMAND_OPTION. For example, to set the port for the run command, instead of flask run --port 8000:
export FLASK_RUN_PORT=8000
flask run
* Running on http://127.0.0.1:8000/
@truth3
truth3 / SlackOpportunityPublisher.cls
Created June 4, 2018 00:45
Publishing financial data to Slack from Salesforce
public with sharing class SlackOpportunityPublisher {
// Production business channel
// private static final String slackURL = 'https://hooks.slack.com/services/######';
// Private channel for testing
// private static final String slackURL = 'https://hooks.slack.com/services/#####';
public class Oppty {
@VirtuBox
VirtuBox / nginx-geoip-module.md
Last active January 24, 2024 08:44
How to configure GeoIP module for Nginx

Create a folder to store the databases :

mkdir -p /usr/share/GeoIP

Download Country IP database

wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
// Pass Tracking Parameters to a Form on Another Page Using GTM
// https://zackphilipps.dev/posts/store-gclid-cookie-send-to-hubspot/
/**
* Assigns the supplied URL parameter to a cookie and each form field with a name that matches.
* You can keep calling this function multiple times for each URL parameter you want to pass along, e.g.
*
* window.onload = function () {
* assignTrackingParameterToCookie("gclid", "hubspot");
* assignTrackingParameterToCookie("utm_source", "gform");
@yefim
yefim / Dockerrun.aws.json
Last active April 7, 2023 16:11
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "443"
}
@devStepsize
devStepsize / slack_slash_cmd.py
Created April 21, 2016 23:12
Server-side logic to handle a Slack slash command using Python and Flask
'''
This is an example of the server-side logic to handle slash commands in
Python with Flask.
Detailed documentation of Slack slash commands:
https://api.slack.com/slash-commands
Slash commands style guide:
https://medium.com/slack-developer-blog/slash-commands-style-guide-4e91272aa43a#.6zmti394c
'''
@zmwangx
zmwangx / Postfix: sender-dependent SASL authentication.md
Last active April 15, 2024 06:34
Postfix: sender-dependent SASL authentication — relay to multiple SMTP hosts, or relay to the same host but authenticate as different users (e.g., two Gmail accounts)

This is a sequel to "Postfix: relay to authenticated SMTP".

I would like to send mail from two different Gmail accounts using Postfix. Here is the relevant section in the Postfix documentation: Configuring Sender-Dependent SASL authentication.

As a concrete example, here's how to set up two Gmail accounts (only relevant sections of the config files are listed below):

/etc/postfix/main.cf:
    # sender-dependent sasl authentication
    smtp_sender_dependent_authentication = yes

sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay

@takeshixx
takeshixx / hb-test.py
Last active March 9, 2024 13:37
OpenSSL heartbeat PoC with STARTTLS support.
#!/usr/bin/env python2
"""
Author: takeshix <takeshix@adversec.com>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford (jspenguin@jspenguin.org).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser
@kirang89
kirang89 / model_relation_ex.py
Created April 7, 2014 18:59
Example for many-to-many relationship with extra columns in SQLAlchemy
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import sessionmaker, relationship
engine = sqlalchemy.create_engine('sqlite:///:memory:')
Base = declarative_base()
@lukenm
lukenm / update_geoip_databases.sh
Last active December 13, 2020 12:03
Shell script to update global Maxmind GeoIP databases. This script can be run via cron.
#!/bin/bash
DAT_DIR=/usr/share/GeoIP
DAT_URLS="http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz"
for FILE in $DAT_DIR/*.dat; do
cp $FILE $FILE.bak
done;
for URL in $DAT_URLS; do