This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
VERSION=$1 | |
PACKAGE_NAME=love-game | |
if [ -z "$VERSION" ] | |
then | |
echo "Need setup version" | |
exit 0 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def none_if_except(f, e=Exception): | |
try: | |
return f() | |
except e: | |
pass | |
def list_anyway(f, iterable): | |
values = [] | |
for i in iterable: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
OlderNewer