Skip to content

Instantly share code, notes, and snippets.

@codyc4321
codyc4321 / love_yo_mommy.py
Created March 23, 2016 16:17
test all your models with model_mommy, see which ones need special self referencing FK support or which one can't find the db table
#!/usr/bin/env python
# coding: utf-8
import os, sys, subprocess, time, re, ast
HOMEPATH = os.path.expanduser("~")
PROJECT_PATH = "{}/path/".format(HOMEPATH)
MOMMY_PATH = os.path.join(PROJECT_PATH, "yourpath/model_mommy")
@codyc4321
codyc4321 / bucketdrive.py
Last active February 18, 2016 19:28
bitbucket webdriver
import os, time, subprocess, random
from functools import wraps
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
from pyvirtualdisplay import Display
@codyc4321
codyc4321 / badheader.xsl
Created January 28, 2016 16:45
trying to remove "Estimated" and the black line underneath
<!DOCTYPE xsl:stylesheet [
<!ENTITY nl "&#10;">
<!ENTITY nbsp "&#160;">
]>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" indent="yes" />
<xsl:template match="reportdata">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" >
<fo:layout-master-set>
@codyc4321
codyc4321 / fo_fail.fo
Last active January 12, 2016 16:26
"fo:table-row" is missing child elements. Required content model: (table-cell+) (See position 37:16)
<?xml version="1.0" encoding="UTF-8"?><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="letter-landscape" page-height="21.59cm" page-width="27.94cm" margin-top="1.0cm" margin-bottom="0.5cm" margin-left="0.97cm" margin-right="0.97cm">
<fo:region-body margin-top="3.5cm" margin-bottom="1.0cm"/>
<fo:region-before extent="4.0cm"/>
<fo:region-after extent="1.0cm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="DistributionPage">
<fo:repeatable-page-master-reference master-reference="letter-landscape"/>
</fo:page-sequence-master>
def activate_hidden_element(html_id=None, html_name=None, driver=None):
action = webdriver.ActionChains(driver)
if html_id:
element = driver.find_element_by_id(html_id)
elif html_name:
element = driver.find_element_by_name(html_name)
action.move_to_element(element).click().perform()
return element
@codyc4321
codyc4321 / loginfiddle.py
Last active December 24, 2015 18:24
paste me into ipython terminal
import time, subprocess
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
def gather(msg=None, default=None):
while True:
import time, subprocess
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
def call_sp(command, *args, **kwargs):
sp = subprocess.Popen(command, shell=True, *args, **kwargs)
sp.communicate()
@codyc4321
codyc4321 / jqueryproblem.html
Created August 10, 2015 15:04
jqueryproblem for stackO
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sitename</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.css" rel="stylesheet">
@codyc4321
codyc4321 / class_view_issues.py
Created August 9, 2015 00:17
can't add data to UpdateView django
print Category.objects.all()
class RangeUpdateView(UpdateView):
model = Range
template_name = 'dashboard/ranges/range_form.html'
form_class = RangeForm
x = "b"
# context = self.get_context_data()
categories = Category.objects.all()
@codyc4321
codyc4321 / factories.py
Created July 27, 2015 15:50
fake factory models
""".../patient.py"""
import factory
from factory import DjangoModelFactory, lazy_attribute
from faker import Faker
__all__ = (
'Patient',
)