This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>4. Django Basics — How to Tango with Django 1.7</title> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from random import randint, randrange | |
with open('stuff.txt', 'r') as f: | |
groups = {} | |
current = "" | |
for line in f.readlines(): | |
if line.endswith("[edit]\n"): | |
current = line.strip('[edit]\n ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AlchemyEncoder(json.JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj.__class__, DeclarativeMeta): | |
# a SQLAlchemy class | |
fields = {} | |
for field in [x for x in dir(obj) | |
if not x.startswith('_') and x != 'metadata']: | |
data = obj.__getattribute__(field) | |
if field == "discount": data = unicode(data) | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
from flask.ext.script import Manager | |
from null.app import create_app | |
app = create_app() | |
manager = Manager(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EMAIL_USE_TLS = True | |
EMAIL_HOST = 'smtp.gmail.com' | |
EMAIL_HOST_USER = 'YOUR GMAIL USERNAME' | |
EMAIL_HOST_PASSWORD = 'YOUR GMAIL PASSWORD' | |
EMAIL_PORT = 587 | |
DEFAULT_FROM_EMAIL = 'YOUR FROM EMAIL FOR SENDING EMAIL' | |
SERVER_EMAIL = 'SAME AS ABOVE' | |
""" | |
There is also a setting in gmail to have to do. "Allow less secure apps" has to be True. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be sure to chmod +x | |
#!/usr/bin/env python | |
import email | |
import json | |
import sys | |
import requests | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
from time import sleep | |
if __name__ == "__main__": | |
while True: | |
do_stuff() | |
sleep(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
$.fn.exchangePositionWith = function(selector) { | |
var other = $(selector); | |
this.after(other.clone()); | |
other.after(this).remove(); | |
}; | |
$(document).on('click', '.fa-chevron-down', function () { | |
var ul = $(this).parents('ul'), | |
li_index = $(this).parents('li').index(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import email | |
import sys | |
def walk(stdin_data): | |
"""Prepend alert to all parts of the message.""" | |
root_message = email.message_from_string(stdin_data) | |
f = open('/tmp/ids_logs.txt', 'a') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Edit this file to introduce tasks to be run by cron. | |
# | |
# Each task to run has to be defined through a single line | |
# indicating with different fields when the task will be run | |
# and what command to run for the task | |
# | |
# To define the time you can provide concrete values for | |
# minute (m), hour (h), day of month (dom), month (mon), | |
# and day of week (dow) or use '*' in these fields (for 'any').# | |
# Notice that tasks will be started based on the cron's system |