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 math import pi | |
from cairo import SVGSurface, Context, Matrix | |
WIDTH = 6 * 72 | |
HEIGHT = 4 * 72 | |
s = SVGSurface('example1.svg', WIDTH, HEIGHT) | |
c = Context(s) | |
# Transform to normal cartesian coordinate system |
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
#!/usr/bin/env sh | |
# Filename: update-hosts.sh | |
# Author: George Lesica <george@lesica.com> | |
# Description: Replaces the HOSTS file with a customized version that blocks | |
# domains that serve ads and malicious software, creating a backup of the old | |
# file. | |
HOSTS_URL="http://someonewhocares.org/hosts/zero/hosts" | |
NEW_HOSTS="hosts" |
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
sentiment <- function(str, words, weights=NULL) { | |
if (is.null(weights)) { | |
weights <- rep(1, length(words)) | |
} | |
if (length(words) != length(weights)) { | |
stop('Length of words and weights not equal') | |
} | |
str.wts <- rep(0, length(str)) |
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
perceptron <- function(x, y, w, a, verbose=F) { | |
# Uses the Perceptron algorithm to find a weight vector that | |
# satisfies the given data. | |
# | |
# Args: | |
# x: an m by n matrix representing the data under study | |
# y: objective vector of m elements | |
# w: initial guess for the weight vector, n elements | |
# a: learning rate, should be in (0,1] | |
# verbose: echo information w at each iteration (default: 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
convolution <- function(A, B) { | |
# Computes the convolution of two vectors. | |
# | |
# Args: | |
# A, B: column vectors representing polynomial coefficients. | |
# | |
# Returns: | |
# The coefficient vector resulting from multiplying the polynomial | |
# represented by A by the polynomial represented by B. | |
Ap <- c(A, B*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
# particle.r | |
# George Lesica | |
# CSCI 555 - FA 2012 | |
# Homework 7.5 | |
# Solution to problem 2 | |
samp <- function(S) { | |
return(sample(S$X, length(S$X), replace=T, prob=S$W)) | |
} |
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
# value_iteration.r | |
# George Lesica | |
# CSCI 555 - FA 2012 | |
# Homework 5 | |
# Solution to problem 3 | |
INTENDED <- 0.8 | |
LEFT <- 0.1 | |
RIGHT <- 0.1 |
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
[xcb] Unknown sequence number while appending request | |
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called | |
[xcb] Aborting, sorry about that. | |
invader: ../../src/xcb_io.c:160: append_pending_request: Assertion `!xcb_xlib_unknown_seq_number' failed. | |
Program received signal SIGABRT, Aborted. | |
0x00007ffff75ab445 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 | |
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory. | |
(gdb) bt | |
#0 0x00007ffff75ab445 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 |
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
pburg <- function() { | |
p <- 1 | |
while (sample(1:2, 1)[1] == 1) { | |
p <- p * 2 | |
} | |
return(p) | |
} | |
ipburg <- function(n) { | |
r <- sapply(1:n, function(x) { return(pburg()) }) |
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 views.py | |
import flask | |
from flask import request, session, g | |
from datably import app, crypt, db | |
from datably import operations as ops | |
@app.route('/login', methods=('GET', 'POST')) | |
def login(): | |
context = {} |