Skip to content

Instantly share code, notes, and snippets.

View aaronlelevier's full-sized avatar

Aaron Lelevier aaronlelevier

View GitHub Profile
@aaronlelevier
aaronlelevier / Dockerfile-django-postgres
Created April 6, 2015 14:37
Dockerfile for django-postgres-nginx-uswgi
### 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
@aaronlelevier
aaronlelevier / yahoo_weather.py
Created April 6, 2015 20:17
Make Yahoo! Weather API call for the weather in Las Vegas
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']
@aaronlelevier
aaronlelevier / textress_example_models.py
Created April 6, 2015 20:24
Example of data models in one of Textress' Apps
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
@aaronlelevier
aaronlelevier / docker-cheatsheet.rst
Last active August 29, 2015 14:18
Docker Cheatsheet

Docker Command Line Cheatsheet

# Build image
# -t : tag
# . : current dir
docker build -t username/image_name:tag_name .

# start image in bash
@aaronlelevier
aaronlelevier / django_template_example.html
Created April 23, 2015 12:46
Django templating Example
{% 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">
@aaronlelevier
aaronlelevier / angularjs_ctrl_example.js
Created April 23, 2015 12:49
AngularJS Controller Example
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) {
@aaronlelevier
aaronlelevier / orleans.py
Created May 29, 2015 14:50
Orleans Casino promotions scraper
# coding: utf-8
'''
Scrape promotions page of Orleans Casino test
'''
import re
import requests
from lxml import html
class nFile(file):
@aaronlelevier
aaronlelevier / silver_sevens.py
Created May 29, 2015 14:51
Silver Sevens Casino promotions scraper
'''
Silver Sevens Casino scraper
lxml docs:
http://lxml.de/api/lxml.etree._Element-class.html
'''
import re
import requests
@aaronlelevier
aaronlelevier / misc_notes.py
Last active August 29, 2015 14:22
Notes for Saturday May 30th
''' 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:]
@aaronlelevier
aaronlelevier / bashrc_prompt
Created June 30, 2015 12:39
my favorite bash prompt with color dirs
### 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 ###