Skip to content

Instantly share code, notes, and snippets.

View lettergram's full-sized avatar
🕶️
Loading...

Austin Walters lettergram

🕶️
Loading...
View GitHub Profile
func main() {
http.HandleFunc("/login", loginHandler)
http.HandleFunc("/logout", logoutHandler)
http.HandleFunc("/register", registerHandler)
http.HandleFunc("/add-book", bookHandler)
http.HandleFunc("/", viewHandler)
http.ListenAndServe(":8080", nil)
}
// True if there was not an attack
clear := attackChecking(usr.Input)
if(!clear){
// remove or fix accordingly
}
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}
<head>
<br>
<div>{{.UserData}}</div>
<h1>{{.Title}}</h1>
</head>
<sidebar>
{{.Bar}}
</sidebar>
<br>
<body>
// Page struct, which will contain template
type Page struct {
Title string
Body template.HTML
UserData template.HTML
Bar template.HTML
}
// Loads a page for use
func loadPage(title string, r *http.Request) (*Page, error) {
// Shows a particular page
func viewHandler(w http.ResponseWriter, r *http.Request) {
// Parses URL to obtain title of file to add to .body
title := r.URL.Path[len("/"):]
// Load templatized page, given title
p, err := loadPage(title, r)
// If they do not have a cookie force them to login
def svd_LeastSquares(A, b):
U, s, V = np.linalg.svd(A)
r = [0.0, 0.0]
r += (1/s[0]) * (U[:,0].T*b) * (V[:,0].T)
r += (1/s[1]) * (U[:,1].T*b) * (V[:,1].T)
return r
fit = []
for i in range(len(A)):
fit.append([A[i, 0], A[i, 0] * M[0, 0] + M[0, 1]])
import numpy as np
from scipy.linalg import solve
def jacobi(A, b, x, n):
D = np.diag(A)
R = A - np.diagflat(D)
for i in range(n):
x = (b - np.dot(R,x))/ D
import numpy as np
from scipy.linalg import solve
def gauss(A, b, x, n):
L = np.tril(A)
U = A - L
for i in range(n):
x = np.dot(np.linalg.inv(L), b - np.dot(U, x))
print str(i).zfill(3),