Skip to content

Instantly share code, notes, and snippets.

@Perlence
Perlence / vpnbook.py
Created February 17, 2014 12:57
Update VPNBook password
#!/usr/bin/python
import os
import re
import urllib2
AUTH_FILE = '~/vpnbook-openvpn-auth'
resp = urllib2.urlopen('http://www.vpnbook.com/freevpn')
content = resp.read()
match = re.search(r'(?:<\w+>)?Password(?:</\w+>)?: (?:<\w+>)?([a-zA-Z0-9]{8})(?:</\w+>)?', content)
@Perlence
Perlence / fancyconfig.py
Last active August 29, 2015 14:00
Fancy config
"""Fancy config.
This module reads data from ``default.cfg`` and ``config.cfg`` using
:class:`RawConfigParser` and stores sections in the module's namespace.
Let's take the following ``config.cfg`` for example::
[section1]
key1 = 1
key2 = 2
@Perlence
Perlence / simple_argparse.py
Created April 25, 2014 10:17
Parse positional and keyword arguments from command line
"""Parse positional and keyword arguments from `sys.argv`.
We all like :class:`argparser.ArgumentParser`. It is a great tool to build
command-line interfaces with many nice features and automatic coercing.
But sometimes it's just too verbose. At times all we need is to pass arguments
to a function from CLI. And I will help you.
Consider this ``square.py`` program::
@Perlence
Perlence / darksouls2-freepie.py
Created April 26, 2014 21:16
Mouse bindings and helpers for Dark Souls II
"""
Mouse bindings and helpers for Dark Souls II
============================================
Features
--------
- Attack with left and right mouse buttons with no delay.
- Execute combos in one key press.
- Close dialogs with Escape.
@Perlence
Perlence / cb-exit.py
Last active August 29, 2015 14:12
Custom flake8-passing cb-exit
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import subprocess
import getpass
class CBExit(object):
def __init__(self):
@Perlence
Perlence / semaphore.go
Created January 31, 2015 21:11
Semaphore in Go
package semaphore
type Semaphore chan bool
func (self Semaphore) Acquire() {
self <- true
}
func (self Semaphore) Release() {
<-self
@Perlence
Perlence / pocket-solarized.css
Last active August 29, 2015 14:22
Solarized Light and Dark themes for Pocket
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix("https://getpocket.com/a/read") {
/* Common */
.page-readerdark .reading_progress_bar,
.page-readersepia .reading_progress_bar {
background-color: #2aa198; /* cyan */
}
code, pre {
font-size: 19px;
@Perlence
Perlence / gulpfile.js
Created October 22, 2015 21:12
Browserify, watchify, exit with status 1 on uglify
'use strict'
var browserify = require('browserify')
var gulp = require('gulp')
var plumber = require('gulp-plumber')
var gutil = require('gulp-util')
var uglify = require('gulp-uglify')
var buffer = require('vinyl-buffer')
var source = require('vinyl-source-stream')
var watchify = require('watchify')
@Perlence
Perlence / closingqueue.py
Created December 3, 2015 20:37
A subclass of asyncio.Queue with close() method
"""closingqueue.py
Inspired by `pychan <https://github.com/stuglaser/pychan>`_.
"""
import asyncio
class ClosingQueue(asyncio.Queue):
"""A subclass of Queue with close() method.
@Perlence
Perlence / .mintty-solarized-dark
Last active December 8, 2015 16:51
Solarized color scheme for mintty
# Based on dark mode of Solarized color scheme http://ethanschoonover.com/solarized
ForegroundColour=131,148,150
BackgroundColour=0,43,54
CursorColour=131,148,150
Black=7,54,66
BoldBlack=0,43,54
Red=220,50,47
BoldRed=203,75,22
Green=133,153,0
BoldGreen=88,110,117