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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(100); |
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
cypreess@iMac ~ cat f.cc | |
#include <stdio.h> | |
int main(){ | |
unsigned char a = 255; | |
unsigned long int b = (a << 24); | |
unsigned long int c = ((unsigned long int) a << 24); | |
printf("b=%lu\n", b); | |
printf("c=%lu\n", 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
cypreess@wierzba:~$ . /usr/local/bin/virtualenvwrapper.sh | |
cypreess@wierzba:~$ mkvirtualenv test1 | |
New python executable in test1/bin/python2.7 | |
Also creating executable in test1/bin/python | |
Installing setuptools............done. | |
Installing pip...............done. | |
(test1)cypreess@wierzba:~$ pip install -e git+https://github.com/agh-glk/plp.git#egg=plp-dev | |
Obtaining plp from git+https://github.com/agh-glk/plp.git#egg=plp-dev | |
Cloning https://github.com/agh-glk/plp.git to ./.virtualenvs/test1/src/plp | |
Unpacking objects: 100% (19/19), done. |
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 | |
import threading | |
class PeriodicThread(object): | |
""" | |
Python periodic Thread using Timer with instant cancellation | |
""" | |
def __init__(self, callback=None, period=1, name=None, *args, **kwargs): |
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 ExtraValueMixin(object): | |
value = 1 | |
def get_value(self): | |
return self.value | |
def get_context_data(self, *args, **kwargs): | |
context = .... super ... get_context_data | |
context['extra_value'] = self.get_value() | |
return context | |
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 itertools import * | |
# First try is like that - OK it works | |
>>> count = 5 | |
>>> iterator = xrange(100) | |
>>> list(imap(None, *([iter(iterator)] * count))) | |
[(0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 11, 12, 13, 14), (15, 16, 17, 18, 19), (20, 21, 22, 23, 24), (25, 26, 27, 28, 29), (30, 31, 32, 33, 34), (35, 36, 37, 38, 39), (40, 41, 42, 43, 44), (45, 46, 47, 48, 49), (50, 51, 52, 53, 54), (55, 56, 57, 58, 59), (60, 61, 62, 63, 64), (65, 66, 67, 68, 69), (70, 71, 72, 73, 74), (75, 76, 77, 78, 79), (80, 81, 82, 83, 84), (85, 86, 87, 88, 89), (90, 91, 92, 93, 94), (95, 96, 97, 98, 99)] | |
# Apparently imap(None,...) is equivalent to izip() - so we can simplify it | |
>>> count = 5 |
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
Using worker: worker-linux-3-2.bb.travis-ci.org:travis-linux-9 | |
$ git clone --depth=50 --branch=master git://github.com/agh-glk/pydic.git agh-glk/pydic | |
Cloning into 'agh-glk/pydic'... | |
remote: Counting objects: 155, done. | |
remote: Compressing objects: 100% (87/87), done. | |
remote: Total 155 (delta 71), reused 144 (delta 66) | |
Receiving objects: 100% (155/155), 43.05 KiB | 0 bytes/s, done. | |
Resolving deltas: 100% (71/71), done. | |
$ cd agh-glk/pydic |
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
# coding=utf-8 | |
from pydic import PyDic | |
sjp = PyDic('../../data/sjp/sjp.pydic') | |
weights = {u'a': 1, u'ą': 5, u'b': 3, u'c': 2, u'ć': 6, u'd': 2, u'e': 1, u'ę': 5, u'f': 5, u'g': 3, u'h': 3, u'i': 1, | |
u'j': 3, u'k': 2, u'l': 2, u'ł': 3, u'm': 2, u'n': 1, u'ń': 7, u'o': 1, u'ó': 5, u'p': 2, u'r': 1, u's': 1, | |
u'ś': 5, u't': 2, u'u': 3, u'w': 1, u'y': 2, u'z': 1, u'ź': 9, u'ż': 5, } | |
def rank(word): |
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 | |
import threading | |
class PeriodicThread(object): | |
""" | |
Python periodic Thread using Timer with instant cancellation | |
""" | |
def __init__(self, callback=None, period=1, name=None, *args, **kwargs): |
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
During handling of the above exception, another exception occurred: | |
Traceback (most recent call last): | |
File "/Users/cypreess/dev/django/tests/forms_tests/tests/test_fields.py", line 92, in test_charfield_1 | |
self.assertRaisesMessage(ValidationError, "'This field is required.'", f.clean, None) | |
File "/Users/cypreess/dev/django/django/test/testcases.py", line 576, in assertRaisesMessage | |
re.escape(expected_message), callable_obj, *args, **kwargs) | |
File "/Users/cypreess/dev/django/django/utils/six.py", line 654, in assertRaisesRegex | |
return getattr(self, _assertRaisesRegex)(*args, **kwargs) |
OlderNewer