Skip to content

Instantly share code, notes, and snippets.

@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@abstrctn
abstrctn / nyu_scraper.py
Created April 26, 2011 04:06
nyu.OpenCourseSearch.org Scraper
import cookielib, urllib2, urllib, BeautifulSoup, re, time, pickle
#from courses.helpers import *
"""
This class scrapes NYU's course registration listings on Albert,
and writes the pickled data out to a specified file directory.
Shouldn't require a working NYU Net ID to work, but adding it is worth a shot
if something seems broken.