Skip to content

Instantly share code, notes, and snippets.

View makthrow's full-sized avatar

Alan Jaw makthrow

View GitHub Profile
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:
# 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)
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):
@makthrow
makthrow / gamescene.swift
Created October 14, 2015 21:58
HWS20 gamescene.swift
//
// GameScene.swift
// Project20
//
// Created by Alan Jaw on 10/14/15.
// Copyright (c) 2015 Alan Jaw. All rights reserved.
//
import GameplayKit
import SpriteKit
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)
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
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) {
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)
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()
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)