Skip to content

Instantly share code, notes, and snippets.

@andrew8088
andrew8088 / prof.sql
Created July 5, 2012 18:51
This is the SQL code to set up a database for a problem I had on a database management exam. Here's the problem: write an SQL query that will return a table of the names and salaries of the professors who teach 20 or more students.
CREATE DATABASE profs;
USE profs;
CREATE TABLE professors (
name varchar(30) NOT NULL,
specialization varchar(20),
salary double(8,2),
CONSTRAINT prof_pk PRIMARY KEY (name));
CREATE TABLE students (
@andrew8088
andrew8088 / test.sh
Created January 11, 2012 02:53
This little script is an example script combining JSDev with running the script in the terminal via node.
#! /bin/sh
d=$(date)
jsdev <test.js >test.dev.js code equal:areEqual -comment "Development Version" -comment "Built: $d"
node test.dev.js
@andrew8088
andrew8088 / Move-to-Dropbox-public-folder.applescript
Created August 2, 2011 00:42
This AppleScript (for use in Keyboard Maestro) will copy the file selected in the Finder to your public dropbox folder and copy the public link to the file to your clipboard. Don't forget to change The XXXXXX to your public "ID".
-- Add file to Dropbox Script
-- Andrew Burgess, modified a bit from http://www.bencardy.co.uk/blog/dropbox-applescript/
-- You'll have to change the first part of your Dropbox URL, in the filePath variable
-- Also, make sure the myPath variable points in the right direction
on splitText(delimiter, someText)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set output to text items of someText
@andrew8088
andrew8088 / MyObject.js
Created July 29, 2011 20:35
This little JavaScript object is a quick example for a Nettuts+ tutorial.
var MyObject = function (state) {
this._state = state;
}
MyObject.prototype.setState = function (state) {
this._state = state;
};
MyObject.prototype.addState = function (state) {
if (typeof this._state === "string") {
this._state = [this._state, state];
} else {
<article class="post">
<header>
<h1>Google Plus: Success and Failure</h1>
</header>
<footer>
<h2>TL. DR.</h2>
<p>I won't use Google Plus (right now), because it doesn't fill a need
in my social web sharing.</p>
<h2>Meta</h2>
@andrew8088
andrew8088 / twitter-scrolling.js
Created February 16, 2011 14:07
This code is an alternate version of the code found in my tutorial on Nettuts+: http://net.tutsplus.com/tutorials/javascript-ajax/implement-twitter-scrolling-without-jquery-2
$(document).bind("scroll", function (e) {
scrolling = true;
});
setInterval(function () {
if (scrolling) {
//console.profile("scroll");
scrolling = false;
var temp_top = win.scrollTop(),
down = scroll_top - temp_top < 0 ? true : false,
@andrew8088
andrew8088 / yui_exercise_1.html
Created January 21, 2011 18:35
For some reason, the handler on "#groupA li" works for lis in groupB
<div id="exercise" class="yui3-g">
<div class="yui3-u-1-2">
<h3>Group A</h3>
<ul id="groupA">
<li>Steven Tyler</li>
<li>Joe Perry</li>
<li>Brad Whitford</li>
<li>Tom Hamilton</li>
</ul>
</div>
@andrew8088
andrew8088 / oop.js
Created December 12, 2010 02:15
OOP in JS
var tooltip_button = {
show : function () {
this.panel.show();
},
hide : function () {
this.panel.hide();
},
bind_events : function () {
var that = this;
this.button.bind("mouseover.Tooltip_Button", function () { that.show.call(that); });
@andrew8088
andrew8088 / tumblr2opml.js
Created November 25, 2010 21:27
You can run this script on tumblr.com/following and you'll get an OPML file for tumblogs on that page print out to the console, ready for you to copy+paste into a file and import into Google Reader.
clear();
var feeds = Array.prototype.slice.call(document.querySelectorAll("div.name a")),
i = 0, p, f, doc = "";
while (feeds[i]) {
f = feeds[i];
feeds[i++] = {
htmlUrl : f.href,
xmlUrl : f.href + 'rss',
title : f.innerHTML,
@andrew8088
andrew8088 / __noSuchMethod__.js
Created October 22, 2010 15:31
Playing around with FireFox's __noSuchMethod__ property; all browsers should have this!
var myObj = (function () {
var data = {
products : ["foobar", "bazquirk", "gizmo"],
services : ["widgets", "other", "last"]
};
return {
__noSuchMethod__ : function (id, args) {
if (id === 'all_products') return data.products;
if (id === 'all_services') return data.services;