Skip to content

Instantly share code, notes, and snippets.

On vacation


On vacation
View GitHub Profile
View Mat1.m
% The ; means we are stoping and starting a new row
A = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12] % 4 X 3 matrix
% making a vector and stroing it in v
v = [1;2;3] % 3 X 1 matrix
[m,n] = size(A) % the size function returns the amoutn of rows and columns and puts them in m and n
% now you can access m and n as two different variables
% You could also store it this way
RedGhoul / Protocols.swift
Created Feb 5, 2018
WTF are Protocols ?
View Protocols.swift
protocol lifeOfABear {
var fishEatenToday: Int {get}
func eatFish()
func eatHoney()
func ClimbTree()
func sleep()
// now all you have to do is make sure you have variable and functions implemented
RedGhoul / Optionals.swift
Created Feb 1, 2018
WTF is an Optional ?
View Optionals.swift
var Cat:String? //<- the "?" is what just made Cat a optional
Cat = "Phil Knight"
let nowUnwrapped = Cat! //"!" <- How you can tell Swift to demand a real answer from the optional
// Swift -> what is your real name cat ?
// the technical term for this is called optional unwrapping
// Optional Binding - How you can check that your optional actually holds somthing before you start using it
from django.conf.urls import url
from first_app import views
# is key word needs to be right
urlpatterns = [
url(r'^$',views.index, name='index'),
from django.conf.urls import url
from django.contrib import admin
from django.conf.urls import include
from first_app import views
urlpatterns = [
from django.shortcuts import render
from django.http import HttpResponse
from first_app.models import Topic,Webpage,AccessRecord
# Create your views here.
def index(request):
webpages_list = AccessRecord.objects.order_by('date')
date_dict = {'access_records': webpages_list}
my_dict = {'insert_me':"This is coming from da Index.html!!!"}
return render(request,'first_app/index.html',context=date_dict)
View template_Django.html
<!DOCTYPE html>
{% load staticfiles %}
<meta charset="utf-8">
<title>Django Level Two</title>
<link rel="stylesheet" href="{% static "css/mystyle.css" %}"/>
<h1>YOLO LIFE</h1>
from django.db import models
class Topic(models.Model):
top_name = models.CharField(max_length=264,unique=True)
def __str__(self):
return self.top_name
class Webpage(models.Model):
topic = models.ForeignKey(Topic) # notice how easy it is to take care of foreign keys
#For Loops
seq = [1,2,3,4,5,6,3]
for item in seq:
dick = {"SAM":1,"FRANK":2,"Dan":3}
for it in dick:
print(it) #outputs the keys
print(dick[it]) #outputs the values
x = 1
y = 1
# basic ifs
if x == y:
if 2 > 1:
print("Hello as well")
# an else if is a "elif"
if 1 == 1: