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
// Determine support properties | |
(function( xhr ) { | |
jQuery.extend( jQuery.support, { | |
ajax: !!xhr, | |
cors: !!xhr && ( "withCredentials" in xhr ) | |
}); | |
})( jQuery.ajaxSettings.xhr() ); |
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
#ifndef MAY_BE_HEADER | |
#define MAY_BE_HEADER | |
#include <string.h> | |
#include <memory> | |
#include <assert.h> | |
///для того, что бы удобней было вернуть из функции пустое или дефолтное значение, например | |
/** \code | |
MayBe<Point> f() { |
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
#ifndef MAY_BE_HEADER | |
#define MAY_BE_HEADER | |
#include <string.h> | |
#include <memory> | |
#include <assert.h> | |
///для того, что бы удобней было вернуть из функции пустое или дефолтное значение, например | |
/** \code | |
MayBe<Point> f() { |
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
#include "may_be.hpp" | |
#include <iostream> | |
struct Point { //тип, над которым мы будем эксперементировать. | |
float x, y; | |
Point(float x, float y): x(x), y(y) {} | |
Point(): x(0), y(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
#include "may_be.hpp" | |
#include <iostream> | |
struct Point { //тип, над которым мы будем эксперементировать. | |
float x, y; | |
Point(float x, float y): x(x), y(y) {} | |
Point(): x(0), y(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
#include <boost/shared_ptr.hpp> | |
#include <iostream> | |
struct T { | |
boost::shared_ptr<MayBe<T> > next; | |
int i; | |
T() { i = 10; } | |
}; |
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
import re | |
def f1(c): | |
return c in ''' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!"\\'()*-.:<>[]^`{|}~''' | |
ALLOWED = re.compile('''[ a-zA-Z0-9!"'()*.:<>^`{|}~\\\[\]-]''') | |
def f2(c): | |
return bool(re.match(ALLOWED, 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
# Ivan Dobrokotov, dobrokot 'at' gmail.com | |
def calc_moves(x, y): | |
result = [] | |
for dx, dy in [(1, 2), (2, 1), (-1, 2), (-2, 1), (-1, -2), (-2, -1), (1, -2), (2, -1)]: | |
nx, ny = (x + dx, y+dy) | |
if 0 <= nx < 8 and 0 <= ny < 8: | |
result.append((nx, ny)) | |
return result | |
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
# minimal tree cost built from list, problem from http://antilamer.livejournal.com/431230.html | |
# cost of tree is sum(depth(i)*value(i)) | |
list = [1,2,3,4,5,7,6,5,4,3,2,10000] | |
n = len(list) | |
#table from (start, length) to (cost, x-sum, root) for best tree on segment (start, length) | |
table_start_l = [[(0,0,-1000)]*(n-start+1) for start in xrange(n+1)] |
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
#include <stdio.h> | |
struct Point2f { | |
float x, y; | |
Point2f(float _x, float _y): x(_x), y(_y) {} | |
Point2f(): x(0), y(0) {} | |
}; | |
Point2f operator -(Point2f p1, Point2f p2) { |
OlderNewer