Skip to content

Instantly share code, notes, and snippets.

View aaronlelevier's full-sized avatar

Aaron Lelevier aaronlelevier

View GitHub Profile
@aaronlelevier
aaronlelevier / charge.py
Last active January 16, 2016 14:19
This python function has a bug, can you find it?
def charge(self, account):
"""
Charge account for the monthly amount. This is triggered by
a monthly cron job.
"""
self.check_balance(account)
amount = settings.MONTHLY_CHARGE
return self.create(account=account, amount=amount)
@aaronlelevier
aaronlelevier / python_install.sls
Created December 3, 2015 14:34
Trying to install Python 2.7.10 in a Salt State
### previous SLS
install-python-2.7.10-from-tarball:
cmd.run:
- names:
- cd /usr/src
- wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
- tar xzf Python-2.7.10.tgz
- cd Python-2.7.10
- ./configure
- make altinstall
@aaronlelevier
aaronlelevier / postgres.sls
Last active November 5, 2015 23:07
salt postgres state
run-postgresql:
service.running:
- enable: true
- name: postgresql-93
- require:
- pkg: postgresql93
# I keep getting this error ->
@aaronlelevier
aaronlelevier / planned_django_screencast_tips.md
Last active September 12, 2015 12:52
Django tips I'd like to screencast

Django tips I'd like to screencast

  1. ipython / django-extensions
  2. model_mommy
  3. Learn a single text-editor well
  • learning a few extra commands in Sublime-text has made a huge difference
@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 ###
@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 / 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 / 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 / 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 / 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">