Skip to content

Instantly share code, notes, and snippets.

from subprocess import Popen, PIPE, STDOUT
from sys import stdout
p = Popen(['echo', 'test'], stdout=PIPE, stderr=STDOUT)
q = Popen('(while read line; do echo "\033[31m$line\033[0m"; done)', shell=True, stdin=p.stdout)
from subprocess import Popen
from sys import stdout
class Log(file):
def set_color(self, color):
self.color = color
def write(self, msg):
stdout.write(self.color)
stdout.write(msg)
from requests import post
api_key = ''
headers = {'Authorization': 'Basic {}'.format(api_key)}
r = post('https://api.cloudpassage.com/oauth/access_token?grant_type=client_credentials', headers=headers)
print r.json()
Example Database:
table: users
username email_address password
ksoviero ksoviero@gmail.com Pa$$w0rd
jdoe jdoe@onelogin.com JD0esPa$$wd
Customer's API request to us:
(Return all users with an email address that ends with @onelogin.com)
/etc/postfix/main.cf:
file:
- comment:
- regex: ^alias_maps = hash:/etc/aliases$
- append:
- text:
- "alias_maps = hash:/etc/aliases, regexp:/etc/aliases.regexp"