Docker Command Line Cheatsheet
# Build image
# -t : tag
# . : current dir
docker build -t username/image_name:tag_name .
# start image in bash| ### Docker Commands ### | |
| FROM ubuntu:trusty | |
| RUN apt-get update | |
| RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python libpq-dev python-dev python-setuptools nginx supervisor | |
| RUN DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql postgresql-contrib | |
| RUN easy_install pip | |
| RUN pip install django==1.7.7 pyscopg2 uwsgi |
| def get_weather(url="http://weather.yahooapis.com/forecastrss?w=12795483&u=f"): | |
| try: | |
| r = requests.get(url) | |
| # parse bytes into a text string | |
| text = r.content.decode("utf-8") | |
| #convert xml text to OrderedDict | |
| doc = xmltodict.parse(text) | |
| # item contains all the main temp info | |
| title = doc['rss']['channel']['title'] | |
| condition = doc['rss']['channel']['item']['yweather:condition'] |
| import re | |
| from django.db import models | |
| from django.conf import settings | |
| from django.utils.translation import ugettext, ugettext_lazy as _ | |
| from django.core.urlresolvers import reverse | |
| from django.core.exceptions import ObjectDoesNotExist | |
| from django.contrib.auth import get_user_model | |
| from django.contrib.auth.models import User | |
| from django.utils.text import slugify |
Docker Command Line Cheatsheet
# Build image
# -t : tag
# . : current dir
docker build -t username/image_name:tag_name .
# start image in bash| {% extends "biz/base.html" %} | |
| {% load staticfiles %} | |
| {% block content %} | |
| <!-- start: MAIN CONTAINER --> | |
| <div class="main-container"> | |
| <section class="page-top"> | |
| <div class="container"> | |
| <div class="col-md-4 col-sm-4"> |
| define([ | |
| './module' | |
| ], function(module) { | |
| 'use strict'; | |
| module.controller('NewsletterCtrl', ['$scope', function($scope) { | |
| $scope.dj_test = "`test`: angular is loaded"; | |
| }]); | |
| module.controller('PricingCtrl', ['$scope', 'Pricing', function($scope, Pricing) { |
| # coding: utf-8 | |
| ''' | |
| Scrape promotions page of Orleans Casino test | |
| ''' | |
| import re | |
| import requests | |
| from lxml import html | |
| class nFile(file): |
| ''' | |
| Silver Sevens Casino scraper | |
| lxml docs: | |
| http://lxml.de/api/lxml.etree._Element-class.html | |
| ''' | |
| import re | |
| import requests |
| ''' String Methods ''' | |
| s = 'Jack the Crazy Giant' | |
| # methods | |
| s.upper() | |
| s.lower() | |
| # will return false because Python is case sensitive | |
| s.startswith('j') | |
| # indexing | |
| s[0] | |
| s[2:] |
| ### shorten my bash settings ### | |
| # If id command returns zero, you’ve root access. | |
| if [ $(id -u) -eq 0 ]; | |
| then # you are root, set red colour prompt | |
| PS1="\\[$(tput setaf 1)\\]\\u@\\h:\\w #\\[$(tput sgr0)\\]" | |
| else # normal | |
| PS1="[\\w]$ " | |
| fi | |
| ### Dir Colors ### |