Skip to content

Instantly share code, notes, and snippets.

View ksze's full-sized avatar
💭
Permanently poikilothermic

Kal Sze ksze

💭
Permanently poikilothermic
View GitHub Profile
@ksze
ksze / hook-dns-01-lets-encrypt-route53.py
Last active February 8, 2018 06:58 — forked from ahnooie/hook-dns-01-lets-encrypt-route53.py
Python 3 script to use as a hook for the letsencrypt.sh client
#!/usr/bin/env python3
# How to use:
#
# LE_HOSTED_ZONE=XXXXXX ./letsencrypt.sh --cron --domain example.org --challenge dns-01 --hook /tmp/hook-dns-01-lets-encrypt-route53.py
#
# More info about letsencrypt.sh: https://github.com/lukas2511/letsencrypt.sh/wiki/Examples-for-DNS-01-hooks
# Using AWS Profiles: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles
# Obtaining your Hosted Zone ID from Route 53: http://docs.aws.amazon.com/cli/latest/reference/route53/list-hosted-zones-by-name.html
@ksze
ksze / Matplotlib_datetime_rounding_bug.ipynb
Last active August 26, 2016 09:51
matplotlib datetime rounding bug
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ksze
ksze / keybase.md
Created August 17, 2014 05:25
keybase.md

Keybase proof

I hereby claim:

  • I am ksze on github.
  • I am k_sze (https://keybase.io/k_sze) on keybase.
  • I have a public key whose fingerprint is 3D4A 38D5 0A26 75CF 1589 0092 F5CE EF85 C5CC 4D95

To claim this, I am signing this object:

# -*- coding: utf-8 -*-
# pywin32
from win32api import GetLastError
from win32event import CreateEvent, WaitForSingleObject
from win32file import ReadFile, WriteFile
from win32pipe import CreateNamedPipe, ConnectNamedPipe, DisconnectNamedPipe
from win32pipe import PIPE_ACCESS_DUPLEX, PIPE_READMODE_MESSAGE, PIPE_TYPE_MESSAGE, PIPE_UNLIMITED_INSTANCES, PIPE_WAIT
from winerror import ERROR_IO_PENDING, ERROR_PIPE_CONNECTED
$ set -x
++ ps1date
++ local d dow day date time col
++ printf -v d '%(%u_%Y-%m-%d_%a_%H:%M:%S %Z)T' -1
++ dow=6
++ d='2014-06-07_Sat_09:34:57 HKT'
++ date=2014-06-07
++ d='Sat_09:34:57 HKT'
++ day=Sat
++ time='09:34:57 HKT'
def add_employees(request):
# Some preparation... (skipped)
success_msg = ''
roles = get_roles()
if request.method == 'POST':
form = EmployeeForm(request.POST, roles=roles)
if form.is_valid():
# add the employees... (details omitted)
success_msg = 'yay'
<VirtualHost *:80>
ServerName www.my-site.com
RewriteEngine On
RewriteOptions inherit
# Hide the admin interface from the public internet. Make it only accessible from the company office
RewriteCond ${REMOTE_ADDR} !=153.64.172.11
RewriteRule ^/admin(/.*)? - [L,R=404]
RewriteRule ^/(.*)$ http://172.20.11.13/$1 [L,P]
<table cellspacing=0 cellpadding=0>
<tr><td bgcolor="#000000">
</td></tr>olor="#ffffff" face="Arial,Helvetica">SSL/TLS Session Cache Status:</font></b>
<tr><td bgcolor="#ffffff">
cache type: <b>SHMCB</b>, shared memory: <b>512000</b> bytes, current sessions: <b>5</b><br>subcaches: <b>32</b>, indexes per subcache: <b>133</b><br>time left on oldest entries' SSL sessions: avg: <b>160</b> seconds, (range: 40...280)<br>index usage: <b>0%</b>, cache usage: <b>0%</b><br>total sessions stored since starting: <b>1749</b><br>total sessions expired since starting: <b>1744</b><br>total (pre-expiry) sessions scrolled out of the cache: <b>0</b><br>total retrieves since starting: <b>456</b> hit, <b>104</b> miss<br>total removes since starting: <b>0</b> hit, <b>0</b> miss<br></td></tr>
</table>
@ksze
ksze / gist:6279871
Created August 20, 2013 10:37
rabbitmq interface and ports??
$ sudo netstat -anp | grep beam
tcp 0 0 0.0.0.0:33793 0.0.0.0:* LISTEN 2157/beam
tcp 0 0 127.0.0.1:33813 127.0.0.1:4369 ESTABLISHED 2157/beam
tcp6 0 0 :::5672 :::* LISTEN 2157/beam
@ksze
ksze / gist:6278498
Created August 20, 2013 08:07
rabbitmqctl
#!/bin/sh
## The contents of this file are subject to the Mozilla Public License
## Version 1.1 (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License
## at http://www.mozilla.org/MPL/
##
## Software distributed under the License is distributed on an "AS IS"
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
## the License for the specific language governing rights and
## limitations under the License.