Skip to content

Instantly share code, notes, and snippets.

View galarant's full-sized avatar

Jeff Revesz galarant

View GitHub Profile
- https://github.com/LeafLink/leaflink/pull/4864
-
@galarant
galarant / gist:ee11c9c564cc64222597f751485bf05a
Last active September 12, 2017 22:33
Reserve Inventory Conflicts

We have written a query on our pro_soda order, product, and line_item tables to find potential scheduling conflicts for booked line items. This first pass should be considered a proof of concept for the purposes of validating the result set. To keep this initial result set small, we have temporarily introduced the following limitations:

  • conflicts were defined as two booked line items with identical product_ids on the same day
  • only products 676, 677 and 1403 were used at the moment
  • we only looked at media plans with 100% probability
  • we only looked at line_items created after 8/1/2017

With those limitations in mind, we wrote the following query:

WITH line_item_run_dates AS (
router.register(
r'bunnies/(?P<parent_id>\d+)/carrots',
BunnyCarrotEdgeViewSet)
businesses = []
inspections = []
for row in reader():
# Find business in my list if it exists, else default to None
# The technique is not obvious or simple, but see here for explanation:
# http://stackoverflow.com/a/8653568/765103
camis = row[0]
business = next((b for b in businesses if b.camis == camis), None)
@coroutine
def increment_a_key(my_dict, key):
my_dict[key] += 1
def main():
example_dict = {'a': 1, 'b': 2, 'c': 3}
yield [increment_a_key(example_dict, k) for (k, v) in example_dict.items()]
print example_dict
@galarant
galarant / web_dev.md
Last active August 29, 2015 14:27
localhost web development in OSX
  1. open a terminal:
    Command-Spacebar to bring up Spotlight, then search for "terminal" and hit Enter
    When terminal opens, click the maximize button to fullscreen it (I will call this Terminal 1 from now on)

  2. in your first terminal tab, start your local web server and leave it running:
    cd ~/pixi_sandbox
    ./manage.py runserver

  3. open a new terminal tab and leave it open on the frontend package root:
    Command-T to create a new terminal tab (I will call this Terminal 2 from now on)

@galarant
galarant / gist:e8e667ee7b3442a4f8aa
Last active August 29, 2015 14:19
basic loom workflow

Workflow for Tickets:

  1. in JIRA, move your ticket to "In Progress"
  2. make sure your current branch is clean: git status
  3. checkout the latest release: git checkout [release_branch_name]
  4. pull the upstream changes on the latest release branch: git pull origin [release_branch_name]
  5. create and checkout a working branch off of the release: git checkout -b [working_branch_name]
  6. do your work on the branch
  7. when work is finished, stage your changes: git add .
  8. commit the staged changes: git commit -m 'descriptive commit message'
  9. make sure your branch is clean: git status

##Intermediate Bootcamp

The goal of this bootcamp is to create a simple MVC web application in Django from scratch.

The app should be built on your local machine and then pushed to a public repo when it is finished, for review.

###App: The Forum

The "Forum" is a single-page application with the following functionality:

{
"link_url": "http:\/\/www.buzzfeed.com\/alisonvingiano\/this-terrifying-clown-has-been-roaming-the-streets-of-staten",
"title": "This Terrifying Clown Has Been Roaming The Streets Of Staten Island And Scaring The Crap Out Of Everyone",
"social_ad_campaign": {
"title": "1.1.1 Deployment Test"
}
}
project_root/
...
pro_soda/
...
admin/
frontend/
app/
components/
some_global_component.js
modules/