Skip to content

Instantly share code, notes, and snippets.

@railroadman
railroadman / slack_webhook_post.py
Last active January 19, 2020 16:56 — forked from devStepsize/slack_webhook_post.py
POST a JSON payload to a Slack Incoming Webhook using Python requests
'''
This is an example of how to send data to Slack webhooks in Python with the
requests module.
Detailed documentation of Slack Incoming Webhooks:
https://api.slack.com/incoming-webhooks
'''
import json
import requests
@railroadman
railroadman / bem.less
Created May 25, 2018 13:16 — forked from apertureless/bem.less
BEM Helper (SCSS, SASS, LESS, Stylus)
// Mixins
.has(@element; @content) {
&__@{element} {
@content();
}
}
.variant(@modifier; @content) {
&--@{modifier} {
@content();
@railroadman
railroadman / gist:c0a8c5d7d56b14b4c78d284accf61043
Created May 17, 2018 01:19 — forked from jessedearing/gist:2351836
Create self-signed SSL certificate for Nginx
#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
@railroadman
railroadman / debug_stuff.py
Created July 15, 2017 19:24 — forked from dhrrgn/debug_stuff.py
A handy SQL debug function for Flask-SQLAlchemy
from . import app
from flask.ext.sqlalchemy import get_debug_queries
if app.debug:
app.after_request(sql_debug)
def sql_debug(response):
queries = list(get_debug_queries())
query_str = ''
@railroadman
railroadman / debug_stuff.py
Created July 15, 2017 19:24 — forked from dhrrgn/debug_stuff.py
A handy SQL debug function for Flask-SQLAlchemy
from . import app
from flask.ext.sqlalchemy import get_debug_queries
if app.debug:
app.after_request(sql_debug)
def sql_debug(response):
queries = list(get_debug_queries())
query_str = ''
@railroadman
railroadman / pixelate.py
Created July 6, 2017 21:28 — forked from scottrogowski/pixelate.py
Pixelate image in python
#!/usr/bin/env python
# This script will pixelate most jpg and png images
# It will both show you the result and save it
import sys
import matplotlib.pyplot as plt
import numpy as np
import PIL.Image as Image
import os
from PIL import Image
NEW_SIZE = (240, 240)
for root, dirnames, filenames in os.walk(os.getcwd()):
for filename in filenames:
name, ext = os.path.splitext(filename)
if not ext == '.jpg':
continue
import re
from ssp.db import *
import CommandDirector as cd
from MySQLdb import OperationalError
def match_hostname(host):
try:
return InvHost.get(InvHost.name == host)
except InvHost.DoesNotExist:
@railroadman
railroadman / atom.md
Created July 6, 2017 21:07 — forked from vinicius73/atom.md
My default Atom packages and theme
@railroadman
railroadman / PHP Image resize
Created October 21, 2012 10:38 — forked from abronte/PHP Image resize
PHP image resize
$image_w = imagesx($image);
$image_h = imagesy($image);
//figure out if we are going to resize by the width or the height
//if the original image is wider than the new dimension, resize by the width
// or else resize by the height
if (($image_w / $image_h) >= ($new_w / $new_h)) {
$h = $image_h * $new_w / $image_w;
$w = $new_w;
} else {