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
# This script creates two kinds of isometric cameras. | |
#The one, TrueIsocam called camera, is the mathematical correct isometric camera with the 54.736 rotation to get the 30 degrees angles at the sides of the rhombus. | |
#The other, GameIsocam called camera, is a camera with which you can render isometric tiles for a 2d game. Here we need a 60 degrees angle instedad of the 54.736 one to get a proper stairs effect and a ratio of 2:1 | |
# Then there is the special case with a 4:3 ratio, which is button 3. You can also make 2D games with that one. The view is more topdown though as with a 2:1 ratio of the traditional game iso view. | |
# The fourth button creates a simple groundplane where you can place your stuff at. | |
#You can of course set up everything by hand. This script is a convenient solution so that you don't have to setup it again and again. | |
# The script is under Apache license |
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 itertools | |
def prime(): | |
primes = [2] | |
yield 2 | |
for candidate in itertools.count(3): | |
if all(candidate % i != 0 for i in primes if i * i <= candidate): | |
primes.append(candidate) | |
yield candidate |
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 flat(content): | |
path = [] | |
flatten(content, path) | |
def flatten(content, path): | |
if type(content) is list or type(content) is tuple: | |
for index, node in enumerate(content): | |
cur_path = path[:] | |
cur_path.append(str(index)) | |
flatten(node, cur_path) |
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 logging | |
logger = logging.getLogger(__file__) | |
logging.basicConfig( | |
level=logging.DEBUG, | |
format='%(asctime)s - %(levelname)s - %(message)s', | |
datefmt='%Y-%m-%d %H:%M:%S') | |
logger.info('this is a test message') |
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 turtle | |
import math | |
from fibonacci import fibonacci_generator as number_generator | |
if __name__ == '__main__': | |
for i, v in enumerate(number_generator()): | |
if v in [0, 1]: | |
continue | |
if i > 200: |
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 unittest | |
class FibonacciTest(unittest.TestCase): | |
def test_sequence(self): | |
self.assertEqual(fibonacci_nth(0), 0) | |
self.assertEqual(fibonacci_nth(1), 1) | |
self.assertEqual(fibonacci_nth(2), 1) | |
self.assertEqual(fibonacci_nth(3), 2) | |
self.assertEqual(fibonacci_nth(4), 3) |
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 <iostream> | |
#include <locale> | |
#include <algorithm> | |
int main() | |
{ | |
wchar_t data[] = L"\u00b1\u03b1\U00024b62"; // { 0xb1 : 0x3b1 : 0xd852 : 0xdf62 : 0 } on windows, while { 0xb1, 0x3b1, 0x24b62, 0 } on linux | |
//char16_t data[] = u"\u00b1\u03b1\U00024b62"; // works! actually saved as { 0xb1, 0x3b1, 0xd852, 0xdf62, 0 } | |
//char32_t data[] = U"\u00b1\u03b1\U00024b62"; // works! as { 0xb1, 0x3b1, 0x24b62, 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
#define BOOST_TEST_MODULE Demo Boost Test & GMock | |
#include <boost/test/unit_test.hpp> | |
#include <gmock/gmock.h> | |
class HookupListner : public ::testing::EmptyTestEventListener | |
{ | |
public: | |
void OnTestPartResult(const ::testing::TestPartResult& result) | |
{ | |
boost::unit_test::unit_test_log |
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 <iostream> | |
struct one_bit_t | |
{ | |
signed value : 1; | |
}; | |
int main() | |
{ | |
one_bit_t a; |
NewerOlder