This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| // Crear una funcion que dado un array, que puede contener strings o arrays, | |
| // concatene todos los strings y los separe por comas. Ej. Si el array que | |
| // entra es: | |
| // ["hola", ["soy", ["juan", "fernandez"]], "y", ["no", "tengo", ["dinero"]]] | |
| // Devolvera la cadena "hola,soy,juan,fernandez,y,no,tengo,dinero" | |
| function concatenator(initialArray, separator){ | |
| separator = separator || ","; | |
| var elem, | |
| i, |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| #!/usr/bin/python | |
| import sys | |
| import imp | |
| import os.path | |
| def import_pythonfile_as_module(python_file_path): | |
| file_name = os.path.basename(python_file_path) | |
| module_name = os.path.splitext(file_name)[0] | |
| new_module = imp.load_source(module_name, |
| #!/usr/bin/python | |
| import sys | |
| import inspect | |
| import os.path | |
| import os | |
| def get_symbols_from_module(python_module, filter_func): | |
| members = inspect.getmembers(python_module) |
| # Install minimal development tools | |
| apt-get install build-essential | |
| # Get python from official python ftp | |
| cd /tmp | |
| wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 | |
| tar jxvf Python-2.7.3.tar.bz2 | |
| cd Python-2.7.3/ | |
| # Configure, compile and install python to /opt/py2.7 |
| # python installed at /opt/py2.7 | |
| # Install setuptools | |
| cd /tmp | |
| wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz | |
| tar zxvf setuptools-0.6c11.tar.gz | |
| cd setuptools-0.6c11/ | |
| /opt/py2.7/bin/python setup.py install | |
| # Install pip | |
| cd /tmp |
| import importlib | |
| class Importer(object): | |
| @staticmethod | |
| def import_module(module_name): | |
| return importlib.import_module(module_name) | |
| @staticmethod | |
| def get_symbol(symbol_name): | |
| module_name = Importer._extract_module_name(symbol_name) |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import inspect | |
| def func1(arg1, arg2, arg3): | |
| pass | |
| def func2(arg1, arg2, arg3='arg3_default'): | |
| pass |
| # -*- coding: utf-8 -*- | |
| import unittest | |
| from doublex import * | |
| class Proxy(object): | |
| class Method(object): | |
| def __init__(self, target, method_name, *aditional_args, **aditional_kwargs): | |
| self.target = target |
| with description('CPE status'): | |
| with before.each: | |
| self.ppg_service = Stub(ppg_services.ProductPackageGroupService) | |
| self.sip_credentials = Stub(sip_credentials_module.SipCredentials) | |
| self.cpe_status_repository = InMemoryCPEStatusRepository() | |
| self.cpe_status_event_history_repository = InMemoryCPEStatusEventHistoryRepository() | |
| self.clock = Stub(clock.Clock) | |
| self.cpe_status_service = cpe_status_service(self.cpe_status_repository, | |
| self.ppg_service, |