Skip to content

Instantly share code, notes, and snippets.

pages = [x.strip() for x in texts.get('register.start_welcome').split('--break--')]
if page_id < 0:
page_id = 0
if page_id >= len(pages):
page_id = len(pages) - 1
if page_id == 0 or from_scratch:
if page_id != len(pages) - 1:
class ButtonFilter(BaseFilter):
def __init__(self, __texts, __button_name):
super().__init__()
self._texts = __texts
self._button_name = __button_name
def filter(self, message):
try:
<?php
// (c) CertaiN, http://php.net/manual/en/features.file-upload.php
header('Content-Type: text/plain; charset=utf-8');
$path_to_folder = "./uploads/";
$max_file_size = 5000000; // ~ 5 mb
try {
// Undefined | Multiple Files | $_FILES Corruption Attack
@agasiev
agasiev / textdetection.cpp
Created April 7, 2014 14:38
OpenCV text detection example.
/*
* textdetection.cpp
*
* A demo program of the Extremal Region Filter algorithm described in
* Neumann L., Matas J.: Real-Time Scene Text Localization and Recognition, CVPR 2012
*
* Created on: Sep 23, 2013
* Author: Lluis Gomez i Bigorda <lgomez AT cvc.uab.es>
*/
@agasiev
agasiev / aHash.py
Created April 7, 2014 11:17
Python PIL aHash implementation.
import Image
img = Image.open("lenna.png")
img = img.resize((8, 8))
img = img.convert('L')
pixels = img.load()
avg = 0
result = 0
@agasiev
agasiev / hunspell.c
Last active December 27, 2015 01:59
Hunspell spelling test.
#include <stdlib.h>
#include <stdio.h>
#include <hunspell/hunspell.h>
int main() {
Hunhandle *spellObj = Hunspell_create("/home/artem/rude/ru_RU.aff", "/home/artem/rude/ru_RU.dic");
char str[60];
scanf("%s", str);
@agasiev
agasiev / stars.py
Last active December 26, 2015 05:19
Simple HYG (http://astronexus.com/node/34) database parser and drawer.
import Image, random
import csv, sys
h = 512
w = 512
img = Image.new( 'RGB', (w,h), "black") # create a new black image
pixels = img.load() # create the pixel map
xyz = []
@agasiev
agasiev / genetic.cpp
Last active December 20, 2015 07:49
String generation with genetic algorithm.
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <string>
using namespace std;
string result = "hello world!";
@agasiev
agasiev / bloom.cpp
Created July 27, 2013 15:34
Simple Bloom filter implementation.
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
int get_array_len(int n, float p) {
return round(-n*log(p)/(log(2)*log(2)));
}
@agasiev
agasiev / problem11_rabbit.cpp
Last active December 12, 2015 00:18
Rabbit problem
/*
В нашем зоопарке появился заяц. Его поместили в клетку, и чтобы ему не было скучно,
директор зоопарка распорядился поставить в его клетке лесенку.
Теперь наш зайчик может прыгать по лесенке вверх, перепрыгивая через ступеньки.
Лестница имеет определенное количество ступенек N.
Заяц может одним прыжком преодолеть не более К ступенек.
Для разнообразия зайчик пытается каждый раз найти новый путь к вершине лестницы.
Директору любопытно, сколько различных способов есть у зайца добраться до
вершины лестницы при заданных значениях K и N. Помогите директору написать программу,
которая поможет вычислить это количество. Например, если K=3 и N=4, то существуют