Skip to content

Instantly share code, notes, and snippets.

Avatar

Sviatoslav Abakumov Perlence

View GitHub Profile
@Perlence
Perlence / vpnbook.py
Created Feb 17, 2014
Update VPNBook password
View vpnbook.py
#!/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)
View fancyconfig.py
"""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 Apr 25, 2014
Parse positional and keyword arguments from command line
View simple_argparse.py
"""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 Apr 26, 2014
Mouse bindings and helpers for Dark Souls II
View darksouls2-freepie.py
"""
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 Aug 29, 2015
Custom flake8-passing cb-exit
View cb-exit.py
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import subprocess
import getpass
class CBExit(object):
def __init__(self):
View semaphore.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 Aug 29, 2015
Solarized Light and Dark themes for Pocket
View pocket-solarized.css
@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 Oct 22, 2015
Browserify, watchify, exit with status 1 on uglify
View gulpfile.js
'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 Dec 3, 2015
A subclass of asyncio.Queue with close() method
View closingqueue.py
"""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 Dec 8, 2015
Solarized color scheme for mintty
View .mintty-solarized-dark
# 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