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
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
def require(package): | |
with settings(hide('stdout'), warn_only=True): | |
out = run('dpkg -s %s' %package) | |
if not out.succeeded: | |
print "The package is not installed. Installing \n" | |
sudo("apt-get install %s" %package) | |
else: | |
print "The package is installed.\n" | |
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 truncate = function(msg, len, suffix) { | |
var truncated = msg.substring(0, len); | |
if (msg.length > len) { | |
truncated += suffix; | |
} | |
return truncated; | |
} |
OlderNewer