Skip to content

Instantly share code, notes, and snippets.

View jordotech's full-sized avatar
🎯
Focusing

jordotech jordotech

🎯
Focusing
  • Austin, TX
  • 17:29 (UTC -05:00)
View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://test.bfanyc.com/home/my_cart" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://test.bfanyc.com/home/my_cart" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://test.bfanyc.com/home/my_cart" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
@jordotech
jordotech / views.py
Last active September 26, 2017 20:38
pending_orderitem_options view
from product.modules.configurable.models import ConfigurableProduct, ProductVariation
from satchmo_store.shop.models import OrderItem
def pending_orderitem_options(request, product_id):
cp = ConfigurableProduct.objects.get(pk=product_id) # this is the url argument
child_ids = [v.product_id for v in cp.productvariation_set.all()] # find the cp's child product ids
orderitems = OrderItem.objects.filter(product_id__in=child_ids) # find the order items that match any of the children product ids
data = {} # The table in the view will be built from this dictionary
for oi in orderitems: # we step through the order items and build the needed data broken down by variation
v = ProductVariation.objects.get(pk=oi.product_id)
@jordotech
jordotech / g.py
Created October 6, 2017 22:59
geocoder.google()
import geocoder
def get_shop_coordinates(shop):
if len(shop.postalcode) and len(shop.street) > 1:
address_to_check = '%s %s' % (shop.street, shop.postalcode)
g = geocoder.google(address_to_check)
ret = {}
if g.lat <> 0 and g.lng <> 0:
ret['latitude'] = g.lat
ret['longitude'] = g.lng
return ret
from django.db.models.signals import post_save
import mailchimp3
@receiver(post_save, sender=Cart)
def send_cart_data_to_mailchimp(sender, instance, raw, created, using, **kwargs):
# https://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/
if not created:
return
data = {
'id':instance.id,
def mc():
from mailchimp3 import MailChimp
api_key = settings.MAILCHIMP_API_KEY
data = {
"id": "store_001",
"list_id": "3dae751fe9",
"name": "Jordan Local",
"domain": "larue.ngrok.io",
"email_address": "jordotech@gmail.com",
@jordotech
jordotech / query.txt
Created April 24, 2018 14:09
ER export psql query
SELECT 'postgresql' AS dbms,t.table_catalog,t.table_schema,t.table_name,c.column_name,c.ordinal_position,c.data_type,c.character_maximum_length,n.constraint_type,k2.table_schema,k2.table_name,k2.column_name FROM information_schema.tables t NATURAL LEFT JOIN information_schema.columns c LEFT JOIN(information_schema.key_column_usage k NATURAL JOIN information_schema.table_constraints n NATURAL LEFT JOIN information_schema.referential_constraints r)ON c.table_catalog=k.table_catalog AND c.table_schema=k.table_schema AND c.table_name=k.table_name AND c.column_name=k.column_name LEFT JOIN information_schema.key_column_usage k2 ON k.position_in_unique_constraint=k2.ordinal_position AND r.unique_constraint_catalog=k2.constraint_catalog AND r.unique_constraint_schema=k2.constraint_schema AND r.unique_constraint_name=k2.constraint_name WHERE t.TABLE_TYPE='BASE TABLE' AND t.table_schema NOT IN('information_schema','pg_catalog') \g /tmp/er.txt;
@jordotech
jordotech / fix_permissions.py
Created July 16, 2018 23:15
Fix proxy permissions management command Django 1.9
import sys
from django.contrib.auth.management import _get_all_permissions
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.core.management.base import BaseCommand
from django.apps import apps
from django.utils.encoding import smart_unicode
class Command(BaseCommand):
help = "Fix permissions for proxy models."
@jordotech
jordotech / upload_s3.py
Created July 25, 2018 20:48
use boto3 to upload to s3
import boto3
client = boto3.client(
's3',
aws_access_key_id = settings.AWS_ACCESS_KEY_ID,
aws_secret_access_key = settings.AWS_SECRET_ACCESS_KEY,
)
dst = 'media/temp_pdf/somefile.jpg' # This is the destination path inside the bucket
client.upload_file('/my/local/somefile.jpg', 'mybucketname', dst)