Skip to content

Instantly share code, notes, and snippets.

View tenken's full-sized avatar

David Gurba tenken

View GitHub Profile
@tenken
tenken / markdown-to-email
Created April 20, 2019 06:44 — forked from cleverdevil/markdown-to-email
markdown-to-email A simple script to send beautifully formatted emails that you write in Markdown. The email will have an HTML payload and a plain-text alternative, so you'll make everyone happy, including yourself.
#!/usr/bin/env python
'''
Send an multipart email with HTML and plain text alternatives. The message
should be constructed as a plain-text file of the following format:
From: Your Name <your@email.com>
To: Recipient One <recipient@to.com>
Subject: Your subject line
---
<?php
// ... adding order items to cart ...
// Protect order from adding new products.
$cartOrder->lock();
$cartOrder->save();
$cartOrder = $this->entityTypeManager->getStorage('commerce_order')->load($cartOrder->id());
$this->redirectToCheckout($cartOrder);
<?php
class OrderController extends ControllerBase implements ContainerInjectionInterface {
...
/**
* Checkout an order.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The request.
@tenken
tenken / multiple-push-urls.md
Created September 14, 2018 16:00 — forked from bjmiller121/multiple-push-urls.md
Add multiple push URLs to a single git remote

Sometimes you need to keep two upstreams in sync with eachother. For example, you might need to both push to your testing environment and your GitHub repo at the same time. In order to do this simultaneously in one git command, here's a little trick to add multiple push URLs to a single remote.

Once you have a remote set up for one of your upstreams, run these commands with:

git remote set-url --add --push [remote] [original repo URL]
git remote set-url --add --push [remote] [second repo URL]

Once set up, git remote -v should show two (push) URLs and one (fetch) URL. Something like this:

# A portion of my lando file
#
name: webextract2
recipe: lemp
config:
webroot: public
database: mariadb
# For flex update error on 08-17-2018
php: '7.2'
@tenken
tenken / install-sentry.md
Created July 13, 2018 17:33 — forked from dgoguerra/install-sentry.md
Install Sentry on-premise in Ubuntu 16.04 with Docker CE (Community Edition)

Install Docker

See: https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-from-a-package

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
@tenken
tenken / sqlmd.sh
Created June 22, 2018 14:50 — forked from dannguyen/sqlmd.sh
A command-line function that runs a SQLite query and gets a Markdown-ready table; See console demo at https://asciinema.org/a/89573
### sqlmd
# Bash function for outputting SQLite results in Markdown-friendly table
### Dependency:
# csvlook can be found here: http://csvkit.readthedocs.io/en/540/scripts/csvlook.html
### USAGE
# $ sqlmd "SELECT name, age FROM people;" optional_db_name_argument.sqlite
### OUTPUT
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
This is a little script to download every song from every playlist
if your Google Play Music account. Songs are organized as follows:
<playlist>/<artist>/<album>/<song>.mp3
I Highly recomend putting this file in your %USER%\Music folder
before running.
@tenken
tenken / nginx_logs.py
Created March 2, 2018 22:20 — forked from SegFaultAX/nginx_logs.py
Parse nginx logs to sqlite3
#!/usr/bin/env python
# The MIT License (MIT)
# Copyright (c) 2016 Michael-Keith Bernard
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@tenken
tenken / wp-config.php
Created February 21, 2018 18:57 — forked from ryanjbonnell/wp-config.php
WordPress Config: Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
// Use X-Forwarded-For HTTP Header to Get Visitor's Real IP Address
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$http_x_headers = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
$_SERVER['REMOTE_ADDR'] = $http_x_headers[0];
}