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
# 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 = {} |
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
>>> a = re.compile(r'^[0-9_]+|\W|[_]+$') | |
>>> a.findall('__hello world') | |
['__', ' '] | |
>>> a.sub('', '__username@gmail.com_table name hello') | |
'usernamegmailcom_tablenamehello' | |
>>> a.sub('', 'a') | |
'a' | |
>>> a.sub('', '_') | |
'' | |
>>> a.sub('', '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
""" | |
Function to find the contiguous subsequence in a | |
list that has the greatest sum. | |
""" | |
def max_subsequence(L): | |
""" | |
Implements a linear time algorithm. | |
>>> max_subsequence([1,2,3,4,5]) |
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
/* | |
shotgun.c | |
Author: George Lesica <glesica@gmail.com> | |
Description: An ANSI C implementation of the shotgun sorting algorithm. | |
*/ | |
#include <stdlib.h> | |
/* Private utility functions. */ |
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
#!/bin/bash | |
# install.sh | |
# Author: George Lesica <glesica@gmail.com> | |
# Description: Deploy script for my dotfiles repo. | |
# License: Public Domain (where it exists), any OSI-approved | |
# license elsewhere. | |
# | |
# Configuration |