Skip to content

Instantly share code, notes, and snippets.

View makmac213's full-sized avatar

Mark Allan B. Meriales makmac213

View GitHub Profile
@makmac213
makmac213 / routine.py
Created March 8, 2013 08:26
For Selenium routine actions
# -*- coding: utf-8 -*-
__author__ = 'Mark Allan B. Meriales'
from selenium.common.exceptions import NoSuchElementException
# Routine for finding, clicking, clearing and sending keys
# to an element
def click_clear_send_keys(elem, keys, **kwargs):
if kwargs.get('click', False):
@makmac213
makmac213 / dummy_emails.sql
Created February 11, 2013 02:35
Change email addresses to test emails.
UPDATE users
SET username = Substring(username, 1, Charindex('@', username))
+ 'mailcatch.com'
@makmac213
makmac213 / basic_client_tests.py
Last active December 12, 2015 04:09
Just some few basics for me on learning tests.
# Mark Allan B. Meriales
# Client testing basic
# If you want to generate fixtures out of your
# existing models and database contents you may
# try my manage.py command below
# https://gist.github.com/makmac213/4671624
import unittest
import threading
import re
from django.conf import settings
from django.http import HttpResponseRedirect
from django.contrib import messages
from django.utils.translation import ugettext as _
# prevent python threading issue, use threading.local to instead of global var
@makmac213
makmac213 / get_random_hex_by_length.py
Last active December 11, 2015 22:48 — forked from markmeriales/gist:4058523
Return a random hex code
import random
def get_random_hex_by_length(length=4):
"""Returns a random hex code according to length"""
return hex(random.randint((16**((length)-1)),(16**length)))[2:]
def get_max_combination(length, base=16):
current = base**(length-1)
next = base**(length)
return next-current
@makmac213
makmac213 / model_to_fixture.py
Last active December 11, 2015 22:48
A command tool that generates fixture data (json) based from existing Models. This can be helpful when doing testing.
"""
Mark Allan B. Meriales
A command tool that generates fixture data (json)
based from existing Models. This can be helpful when
doing testing.
"""
from django.core.management.base import BaseCommand
from django.db import models