Skip to content

Instantly share code, notes, and snippets.

View tony-brewerio's full-sized avatar

Anton Ustyuzhanin tony-brewerio

View GitHub Profile
@tony-brewerio
tony-brewerio / my_module.module
Created September 28, 2012 13:06
Random drupal code | Alternating views query
<?php
/**
* Принимает айди места, находит айди страны ( если есть ) и айди регионов,
* куда входит это место
* @return string
*/
function my_module_expand_location($location_tid = null) {
// кэш
➜ benchmark python -m cProfile product.py
802 function calls in 0.817 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.001 0.001 0.817 0.817 product.py:1(<module>)
100 0.812 0.008 0.816 0.008 product.py:5(table)
100 0.001 0.000 0.001 0.000 {len}
300 0.002 0.000 0.002 0.000 {map}
@tony-brewerio
tony-brewerio / actions.py
Created January 10, 2012 17:22
Example actions for Garena bot
from gbot.action import Action
from gbot.exceptions import BotError
from gbot import param
from gbot.models import Group, Player, Membership
class PlayerInfo(Action):
# Query the bot about info on a certain player, giving back rank and groups player is member of
# command users needs to enter to execute this action
@tony-brewerio
tony-brewerio / README.md
Created July 3, 2011 06:52
ChunkyImagePixelizer

ChunkyImagePixelizer

A very blunt attempt - slice the image in blocks, determine normalized color as a mean of all pixels colors ( pixels that are closer to the block center have more "weight" in result ), then paint entire rectangle with new color. Supports arbitrary shape of blocks.

ChunkyImagePixelizer.pixelize_image("input.png", "output.png", :width => 10, :height => 10)