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 Subject(name, topics){ | |
this.name = name; | |
this.topics = topics; | |
} | |
var subjectMath = new Subject("Maths", ["sets", "trigonomitry", "algebra"]); | |
var subjectScience = new Subject("Science", ["Biology", "Astronomy", "Physics"]); | |
function Person(gender, age, currentSubject, currentTopicIndex){ | |
this.gender = gender; |
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 Subject(name, topics){ | |
this.name = name; | |
this.topics = topics; | |
} | |
var subjectMath = new Subject("Maths", ["sets", "Trigonometry", "algebra"]); | |
var subjectScience = new Subject("Science", ["Biology", "Astronomy", "Physics"]); | |
function Person(name, gender, age, currentSubject, currentTopicIndex){ | |
this.name = name; |
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 urllib2 # needed for functions,classed for opening urls. | |
url = raw_input( "enter the url needed for downloading file(pdf,mp3,zip...etc)\n"); | |
usock = urllib2.urlopen(url) #function for opening desired url | |
file_name = url.split('/')[-1] #Example : for given url "www.cs.berkeley.edu/~vazirani/algorithms/chap6.pdf" file_name will store "chap6.pdf" | |
f = open(file_name, 'wb') #opening file for write and that too in binary mode. | |
file_size = int(usock.info().getheaders("Content-Length")[0]) #getting size in bytes of file(pdf,mp3...) | |
print "Downloading: %s Bytes: %s" % (file_name, file_size) | |
downloaded = 0 |
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 Color(object): | |
'''An RGB color, with red, green and blue components.''' | |
def __init__(self, r, g, b): | |
'''A new color with red value r, green value g, and blue value b. All components are integers in the range 0-255.''' | |
self.red = r | |
self.green = g | |
self.blue = b |
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
from django.db import models | |
from django.utils.text import slugify | |
class Document(models.Model): | |
def get_upload_path(self, filename): | |
""" | |
Returns the upload path for docs | |
""" | |
filename = filename.split('.') | |
extension = filename.pop() |
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 urlparse | |
from django import template | |
register = template.Library() | |
def video_embed(context, url): | |
url_data = urlparse.urlparse(url) | |
query = urlparse.parse_qs(url_data.query) | |
try: | |
video_id = query["v"][0] |
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
# in templatetags/app_tags.py | |
import calendar | |
from django import template | |
register = template.Library() | |
@register.filter | |
def month_name(month_number): | |
return calendar.month_name[month_number] |
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
def change_keys(row_dict): | |
""" | |
It returns a dictionary with keys in English and all lowercase. | |
Create a dictionary to map keys to given dictionary keys. | |
Following is Dutch to English text mapping. | |
""" | |
dict_map = { | |
'Leerlingnummer': 'student_id', | |
'Voornamen': 'first_name', | |
'Achternaam': 'last_name', |
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 requests | |
import json | |
import random | |
AFTER = 1388952000 | |
TOKEN = 'Token' | |
def get_posts(): | |
""" | |
Returns dictionary of id, first names of people who posted on my wall |
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
from celery.task.schedules import crontab | |
from celery.decorators import periodic_task | |
from .models import send_all | |
# Every ten minutes | |
@periodic_task(run_every=crontab(hour="*", minute="*/10", day_of_week="*")) | |
def send_newsletter(): | |
print("Sending Newsletters") |
OlderNewer