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 find_next_prime(n): | |
# A prime number is a natural number greater than 1 | |
# that has no positive divisors other than 1 and itself. | |
# find the next prime number greater than n by iterating +1 and checking | |
# if the number is prime | |
o = n+1 | |
while check_prime(o) is False: |
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
# realpython.com course 2 chapter 27.14.7 homework | |
# django redirect to url of newly added blogpost | |
def add_post(request): | |
context = RequestContext(request) | |
if request.method == 'POST': | |
form = PostForm(request.POST, request.FILES) | |
if form.is_valid(): | |
form.save(commit=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
class ContactForm(models.Model): | |
name=models.CharField(max_length=150) | |
email = models.EmailField(max_length=250) | |
topic = models.CharField(max_length=200) | |
message = models.CharField(max_length = 1000) | |
timestamp = models.DateTimeField( | |
auto_now_add=True, default =datetime.datetime.now | |
) | |
def __unicode__(self): |
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
// | |
// GameScene.swift | |
// Project20 | |
// | |
// Created by Alan Jaw on 10/14/15. | |
// Copyright (c) 2015 Alan Jaw. All rights reserved. | |
// | |
import GameplayKit | |
import SpriteKit |
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 ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate{ | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func viewDidAppear(animated: Bool) { | |
super.viewDidAppear(animated) |
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 LoginViewController : PFLogInViewController { | |
var backgroundImage : UIImageView!; | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// set our custom background image | |
backgroundImage = UIImageView(image: UIImage(named: "berry_welcome")) | |
backgroundImage.contentMode = UIViewContentMode.ScaleAspectFill |
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 ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate{ | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func viewDidAppear(animated: Bool) { |
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 ViewController: UIPageViewController, UIPageViewControllerDataSource, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func viewDidAppear(animated: Bool) { | |
super.viewDidAppear(animated) |
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 LoginViewController: PFLogInViewController { | |
var backgroundImage : UIImageView! | |
// let fbPermissions = ["fields": "public_profile, user_friends, user_education_history, user_birthday"] | |
// public_profile accesses id, name, first_name, last_name, age_range, link, gender, locale, timezone, updated_time, verified | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
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 Foundation | |
var s = "hello" | |
s.startIndex // starts at 0 | |
let index = s.startIndex.advancedBy(2) // index is a String.index to the 3rd glyph, "l" | |
print (index) | |
s.insertContentsOf("abc".characters, at: index) |
OlderNewer