Skip to content

Instantly share code, notes, and snippets.

View jordotech's full-sized avatar
🎯
Focusing

jordotech jordotech

🎯
Focusing
  • Austin, TX
  • 15:16 (UTC -05:00)
View GitHub Profile
@jordotech
jordotech / settings.php
Last active September 28, 2019 14:34
Drupal 8 starter settings.php for https://github.com/jordotech/d8-docker
<?php
// @codingStandardsIgnoreFile
$databases['default']['default'] = [
'database' => 'drupal',
'username' => 'drupal',
'password' => 'drupal',
'host' => 'db',
'port' => '3306',
@jordotech
jordotech / docker-compose.yml
Created September 26, 2019 14:38
docker-compose.yml
version: "3"
services:
mariadb:
image: wodby/mariadb:$MARIADB_TAG
container_name: "${PROJECT_NAME}_mariadb"
stop_grace_period: 30s
environment:
MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
MYSQL_DATABASE: $DB_NAME
@jordotech
jordotech / periodic_table.html
Created June 12, 2019 17:51
AWS Periodic table with checkboxes
<html lang="en" xml:lang="en" xmlns= "https://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
@jordotech
jordotech / form.py
Created May 2, 2019 16:31
Django form db hits, move to __init__
# Bad
class ShipForm(forms.Form):
printer_station = forms.CharField(
label=_('Print Station'),
widget=forms.Select(choices=get_printer_station_choices()), # Bad, this method hits the db during reload
required=False)
# Good
class ShipForm(forms.Form):
def __init__(self, *args, **kwargs):
@jordotech
jordotech / kwargs.py
Created February 25, 2019 19:58
how to use kwargs
"""
You can attach **kwargs as a param to any function, it will allow passing aritrary key=value pairs to the function as parameters.
Its up to you to intercept the kwarg in your receiving function to make use of it, or else it's just ignored
"""
def no_kw_function(id=None, price_over=None, length=None, width=None):
print(id)
print(price_over)
print(length)
print(width)
@jordotech
jordotech / slide.js
Created January 28, 2019 18:48
related
$('.related-slides').slick({
lazyLoad: 'ondemand',
slidesToShow: 4,
slidesToScroll: 4,
infinite: true,
dots: true,
responsive: [
{
breakpoint: 1024,
settings: {
@jordotech
jordotech / dashboard_section.html
Created December 23, 2018 19:23
Django Jet dashboard sections
<div class="dashboard-container columns_2 cf">
<div class="dashboard-column-wrapper">
<div class="dashboard-column ui-droppable ui-sortable">
<div class="dashboard-item collapsible ">
<div class="dashboard-item-header ui-sortable-handle">
<span class="dashboard-item-header-buttons"></span>
<span class="dashboard-item-header-title">test</span>
<div class="cf"></div>
</div>
<div class="dashboard-item-content" style="height: auto;">
@jordotech
jordotech / kitpart orderitem ids.txt
Created August 31, 2018 14:29
which orderitems are kitparts in the queryset
order_item_ids = [q.get('id') for q in queryset]
kitpart_orderitem_ids = [oid.get('item') for oid in OrderItemDetail.objects.values('item').filter(name='kitparent', id__in=order_item_ids)]
@jordotech
jordotech / test_script.txt
Created July 29, 2018 23:49
Dev must pass these verbal tests
1. Entity value belonging to multiple entities. caesar = food_dressing, food_salad_special.
App should recognizes that we want the salad
Expected flow:
user: "large caesar"
alexa: "Ok, I added one large caesar"
2. "ambiguous" entity asks for clarification
Expected flow:
@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)