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 / resample_flac.bash
Created April 15, 2013 16:41
A script to resample your FLAC files *and* make sure they conform to the FLAC Subset specification so they will play in pretty much all hardware players - e.g. portable music players like those made by COWON) - all this while minimizing the file sizes.
#!/usr/bin/env bash
# A script to resample your FLAC files *and* make sure they conform to the FLAC Subset
# specification so they will play in pretty much all hardware players - e.g. portable
# music players like those made by COWON - all this while minimizing file sizes.
# Requirements:
# - Bash 4 or newer (for the globstar)
# - sox
# - flac
@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.
<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.
@ksze
ksze / pip_upgrade_all.sh
Created December 14, 2012 13:48
A simple Bash script to upgrade all pip packages in a virtualenv.
#!/usr/bin/env bash
# INSTALLATION
# ------------
# Put this script in the bin directory of your virtualenv and make it user executable:
# $ cp pip_upgrade_all.sh /path/to/your_virtualenv/bin/
# $ chmod u+x /path/to/your_virtualenv/bin/pip_upgrade_all.sh
# USAGE
# -----
import sys
def same_row(i,j): return (i/9 == j/9)
def same_col(i,j): return (i-j) % 9 == 0
def same_block(i,j): return (i/27 == j/27 and i%9/3 == j%9/3)
class InconsistentPositionError(Exception):
pass
def still_consistent(a):
@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