Skip to content

Instantly share code, notes, and snippets.

View gdm's full-sized avatar

Dmytro Gorbunov gdm

View GitHub Profile
@gdm
gdm / nginx.conf
Created September 13, 2016 14:40 — forked from jrom/nginx.conf
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@gdm
gdm / prettyjson
Last active May 19, 2019 21:25 — forked from expandrive/prettyjson
Take JSON from stdin and dump it to stdout in a more readable form
#!/usr/bin/python
# or jq '.' - don't re-invent the wheel :)
# From http://stackoverflow.com/questions/352098/how-to-pretty-print-json-script
# To install paste this into a file named prettyjson that lives in your PATH
# e.g.
# sudo touch /usr/bin/prettyjson
# sudo open -t /usr/bin/prettyjson
# paste this file and save
# sudo chmod +x /usr/bin/prettyjson
@gdm
gdm / sendmail-multiple-recipients
Created March 21, 2016 11:13
Send mail to multiple recipients
import smtplib
import sys, os
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
msg = MIMEMultipart()
msg['From'] = 'my.mail@mail.com'
recipients = os.environ['MAILTO'].split(',')
@gdm
gdm / send_mail.py
Created March 1, 2016 13:50 — forked from vjo/send_mail.py
[Python] Send email with embedded image and application attachment
#! /usr/bin/python
import smtplib
from optparse import OptionParser
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
SELECT ID, user_login, user_pass FROM wp_users;
UPDATE wp_users SET user_pass = MD5(‘WPEXPLORER’) WHERE ID=1 LIMIT 1;
@gdm
gdm / 30-income-calculon.pl
Created January 13, 2016 14:14 — forked from avar/30-income-calculon.pl
Calculate your income in The Netherlands with and without a 30% ruling.
# To check if this is up-to-date with the tax rates go to
# http://www.expatax.nl/tax-rates-2015.php and see if there's anything
# newer there.
#
# I make no guarantees that any of this is correct. I calculated this
# at the time and have been updating it when new tax rates come along
# because people keep finding this useful.
#
# There's also an interactive JS version of this created by
# @stevermeister at
@gdm
gdm / gist:56af64936e4e8d306ea4
Created November 10, 2015 12:35
get provisioned write capacity units
public int getWriteCapacity(final String tableName) {
DescribeTableResult td = client.describeTable(tableName);
if (td.getTable() != null ) {
return td.getTable().getProvisionedThroughput().getWriteCapacityUnits().intValue();
}
// Indicates error.
return 0;
}