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 sets the background color of the master UIView (when there are no windows/tab groups on it) | |
Titanium.UI.setBackgroundColor('#000'); | |
// create tab group | |
var tabGroup = Titanium.UI.createTabGroup(); | |
// | |
// create base UI tab and root window | |
// |
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
var isAndroid = Ti.Platform.osname == 'android'; | |
// create tab group | |
var tabGroup = Titanium.UI.createTabGroup(); | |
var indicator = Titanium.UI.createActivityIndicator({ | |
bottom:10, | |
height:50, | |
width:10, | |
message:"Cargando..." | |
}); |
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
players = ('0','X') | |
turn = 0 | |
exit = False | |
board = {0:'-', 1:'-',2:'-', 3:'-', 4:'-',5:'-',6:'-', 7:'-',8:'-'} | |
win_combinatios= [[0,1,2], \ | |
[3,4,5], \ | |
[6,7,8], \ | |
[0,3,6], \ | |
[1,4,7], \ | |
[2,5,8], \ |
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
var function_after_ajax = []; | |
function fetchData() { | |
$.ajax({ | |
url: url, | |
method: 'GET/POST', | |
dataType: 'json', | |
data:params, | |
success: onDataReceived | |
}); | |
function onDataReceived() { |
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
/* | |
* Simple hash map using javascript objects and an ordered array. | |
* Repeated elements are not allowed. | |
* | |
* @param sort_method By default is ASC order, but you can specified whatever you want. | |
* | |
* The public methods are: | |
* -set | |
* -get | |
* -del |
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 django import template | |
register = template.Library() | |
@register.filter | |
def get_parameters(request): | |
""" | |
Returns the list of get paremeter | |
""" | |
parameters = "?" |
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 heapq import heappush, heappop | |
def heapsort(iterable, priorities={}): | |
""" | |
Sorted the secuence according to the priorities | |
the biggest number is the less prioritary | |
>>> priorities ={'Como': 1} | |
>>> sec = ['camino', 'Como', 'test'] | |
>>> heapsort(sec, priorities) |
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 imap, groupby | |
def get_duplicates(sec): | |
return [x for x in sec if sec.count(x) > 1] | |
class SumEquals(object): | |
""" | |
Ones, Twos, Threes, Fours, Fives, Sixes: | |
""" |
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 DictAsMember(dict): | |
def __getattr__(self, name): | |
""" | |
From : http://docs.python.org/reference/datamodel.html#object.__getattr__ | |
Called when an attribute lookup has not found the attribute in the usual places | |
(i.e. it is not an instance attribute nor is it found in the class tree for self). | |
name is the attribute name | |
http://stackoverflow.com/questions/8709975/overwrite-in-python | |
""" | |
value = self[name] |
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
#modification of http://stackoverflow.com/questions/5983265/pythonic-way-of-determining-if-the-current-element-is-the-first-or-last-element | |
def annotate_last_item(gen): | |
prev_val = gen.next() | |
for val in gen: | |
yield False, prev_val | |
prev_val = val | |
yield True, prev_val |
OlderNewer