Skip to content

Instantly share code, notes, and snippets.

View pahaz's full-sized avatar
🛠️
Yo ho ho

Pavel White pahaz

🛠️
Yo ho ho
View GitHub Profile
@pahaz
pahaz / metaclassexample.py
Created March 11, 2016 13:15
EXAMPLE! How to understand the python metaclasses. Less1.
from functools import wraps
def debug(func):
print('debug(', func.__qualname__, ')')
name = func.__qualname__
@wraps(func)
def wrapper(*args, **kwargs):
print('CALL:', name, args, kwargs)
@pahaz
pahaz / index.html
Last active January 9, 2016 12:25
socket-io chat example
<!doctype html>
<html lang="en">
<head>
<title>Chat Example</title>
</head>
<body>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
var socket = io.connect();
@pahaz
pahaz / CheckDomainMiddleware.py
Created November 11, 2015 11:19
CheckDomainMiddleware
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:
# 1. add to MIDDLEWARE_CLASSES
# 2. File: settings.py
MULTISITE_WRONG_DOMAIN_REDIRECT_URL = "http://example.com/"
"""
@pahaz
pahaz / Game.cs
Last active August 29, 2015 14:16 — forked from LevShab/Game.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game
{
class Program
{
@pahaz
pahaz / transliterate.py
Created February 22, 2015 19:28
Python safe transliterate print (kill UnicodeEncodeError)
#!/usr/bin/env python3
# encoding=utf-8
from __future__ import print_function
from __future__ import unicode_literals
import string
ru_lang_translit_map = {
"Я": "Ja", "Ю": "Ju", 'Э': 'E', 'Ь': '\'', 'Ы': 'Y', 'Ъ': '\'', "Щ": "Sch",
"Ш": "Sh", "Ч": "Ch", "Ц": "Ts", 'Х': 'H', 'Ф': 'F', 'У': 'U', 'Т': 'T',
'С': 'S', 'Р': 'R', 'П': 'P', 'О': 'O', 'Н': 'N', 'М': 'M', 'Л': 'L',
@pahaz
pahaz / dz1.cs
Created February 21, 2015 15:51
awdadawda
using System.IO;
using System;
class Program
{
static void Main()
{
int z;
// afawfawfawfawf
@pahaz
pahaz / HTTPServer.cs
Last active August 29, 2015 14:11
Simple HTTP Server
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
class HTTPServer
{
public static void Main()
{
@pahaz
pahaz / ClickerGame.cs
Last active August 29, 2015 14:11
Simple clicker game
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ClickerGame
{
class Program
@pahaz
pahaz / hangmanpics.txt
Last active August 29, 2015 14:11
Виселица
HANGMANPICS
+---+
| |
|
|
|
|
=========
@pahaz
pahaz / Redactor.cs
Last active August 29, 2015 14:10
Simple image redactor
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Redactor
{
static void Main(string[] args)
{