Skip to content

Instantly share code, notes, and snippets.

View MyGodIsHe's full-sized avatar
🥰

Ilya Chistyakov MyGodIsHe

🥰
View GitHub Profile
from sorl.thumbnail import default
def sort_images_by_col(object_list, col_count, width, margin, key):
"""
return [[col width, objects], ...]
"""
def get_col():
min = cols[0]
min_col = 0
"""
Predicting the collision of two cubes.
"""
def find_terms(a, b, c):
if not a:
return [(None, None)] if abs(b) <= c else None
down, up = sorted(((c - b) / a, (-c - b) / a))
if abs(a * (down - 1) + b) <= c:
@MyGodIsHe
MyGodIsHe / deploy.sh
Created August 28, 2013 08:41
Deploy script for love2d
#! /bin/sh
VERSION=$1
PACKAGE_NAME=love-game
if [ -z "$VERSION" ]
then
echo "Need setup version"
exit 0
fi
@MyGodIsHe
MyGodIsHe / wrap.py
Last active August 29, 2015 14:18
Django wrap tag
from django.template.base import Node, Library, TemplateSyntaxError, Context
from django.template.loader import get_template
register = Library()
class WrapControlNode(Node):
"""Implements the actions of the wrap tag."""
def __init__(self, filepath, nodelist):
self.filepath, self.nodelist = filepath, nodelist
@MyGodIsHe
MyGodIsHe / ExtendProceduralMeshLibrary.cpp
Created January 2, 2016 21:14
UE4 procedural transformation from cube to sphere
void UExtendProceduralMeshLibrary::GenerateBoxMesh(FVector BoxSize, FIntVector BoxSegments, TArray<FVector>& Vertices, TArray<int32>& Triangles, TArray<FVector>& Normals, TArray<FVector2D>& UVs, TArray<FProcMeshTangent>& Tangents)
{
BoxSize.X = abs(BoxSize.X); // width
BoxSize.Y = abs(BoxSize.Y); // height
BoxSize.Z = abs(BoxSize.Z); // depth
BoxSegments.X = BoxSegments.X < 1 ? 1 : BoxSegments.X;
BoxSegments.Y = BoxSegments.Y < 1 ? 1 : BoxSegments.Y;
BoxSegments.Z = BoxSegments.Z < 1 ? 1 : BoxSegments.Z;
@MyGodIsHe
MyGodIsHe / fmerge.py
Last active January 20, 2016 10:33
Merging sorted lists in a functional style
def none_if_except(f, e=Exception):
try:
return f()
except e:
pass
def list_anyway(f, iterable):
values = []
for i in iterable:
@MyGodIsHe
MyGodIsHe / log.py
Created January 19, 2016 19:02
Processing generators
def log(f):
def wrap(*args, **kwargs):
total = 0
t = time.time()
r = f(*args, **kwargs)
total += time.time() - t
if isinstance(r, types.GeneratorType):
try:
while 1:
t = time.time()
@MyGodIsHe
MyGodIsHe / vk.com.ads.blocker.user.js
Last active September 14, 2016 07:42
Hide advertising on new.vk.com!
// ==UserScript==
// @name vk ads blocker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hide advertising on vk.com!
// @author Ilya Chistyakov
// @match *://vk.com/*
// @grant none
// ==/UserScript==
@MyGodIsHe
MyGodIsHe / list.py
Created August 2, 2016 10:27
Doubly linked list on python
class Item(object):
def __init__(self, data):
self.prev = None
self.next = None
self.data = data
def delete(self):
if self.prev != None:
self.prev.next = self.next
@MyGodIsHe
MyGodIsHe / habr_tm.py
Last active September 5, 2016 11:23
pip install BeautifulSoup
#!/usr/bin/python
import SocketServer
import SimpleHTTPServer
import urllib
import re
from BeautifulSoup import BeautifulSoup, NavigableString, Tag, PageElement
TARGET = 'habrahabr.ru'
HOST = '127.0.0.1'