Skip to content

Instantly share code, notes, and snippets.

Yo ho ho

Pavel White pahaz

Yo ho ho
Block or report user

Report or block pahaz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Game.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game
class Program
class CheckDomainMiddleware(object):
If MULTISITE_WRONG_DOMAIN_REDIRECT_URL defined all wrong domain requests
will be redirected to this url. Otherwise Http 404 will be returned.
How-to use:
# 2. File:
pahaz / index.html
Last active Jan 9, 2016
socket-io chat example
View index.html
<!doctype html>
<html lang="en">
<title>Chat Example</title>
<script src="/"></script>
<script src=""></script>
var socket = io.connect();
pahaz /
Created Mar 11, 2016
EXAMPLE! How to understand the python metaclasses. Less1.
from functools import wraps
def debug(func):
print('debug(', func.__qualname__, ')')
name = func.__qualname__
def wrapper(*args, **kwargs):
print('CALL:', name, args, kwargs)
#!/usr/bin/env python3
class Matrix:
def __init__(self, m):
self.m = m
def __str__(self):
return "Matrix(%r)" % self.m
def __repr__(self):
def logg(func):
def logged_func(*args, **kwargs):
print(func.__name__ + '() ...',
args, kwargs)
return func(*args, **kwargs)
logged_func.__doc__ = func.__doc__
logged_func.__name__ = func.__name__
return logged_func
pahaz /
Created Jul 15, 2016
Python Google spreadsheets v4 API example. Google spreadsheet access management example. Use google drive v3 API for access management
"""Google spreadsheet related.
Packages required: oauth2client, google-api-python-client
from oauth2client.service_account import ServiceAccountCredentials
from apiclient import discovery
def get_credentials(scopes: list) -> ServiceAccountCredentials:
pahaz /
Last active Jul 17, 2016
Simple python v3 inline script for generating next version number!
echo 1.0.0 | python -c "v = input().strip().split('.'); v[-1] = str(int(v[-1]) + 1); print('.'.join(v))"
#!/usr/bin/env bash
set -o errexit # always exit on error
set -o pipefail # don't ignore exit codes when piping output
set -o nounset # fail on unset variables
set -o xtrace # print command traces before executing command
echo "PWD=$PWD"
# #
pahaz /
Created Aug 25, 2016
Short story about how metaclasses work
print('class Meta(type)')
class Meta(type):
def __prepare__(mcs, name, bases, **kwargs):
print(' Meta.__prepare__(mcs=%s, name=%r, bases=%s, **%s)' % (
mcs, name, bases, kwargs
You can’t perform that action at this time.