Skip to content

Instantly share code, notes, and snippets.

View ryanmcgrath's full-sized avatar
💭
==bG9s

Ryan McGrath ryanmcgrath

💭
==bG9s
View GitHub Profile
#!/usr/bin/ruby
# A build script for this Maven-bullshit, because there's certain people here who don't
# actually *care* about this junk and just wanna get their work done. This is also meant to
# bring some semblance of sanity to alpha, because even though certain people have indicated that
# they don't wanna support it as an environment, they're still letting people code, build, and push
# from said environment. ;P
#
# This is meant to be run from your root webs directory/git repo.
#
<?php
require_once "Mail.php";
/* This is a PHP script to handle form-mailing on Webfaction hosted accounts.
*
* Normal PHP mail scripts won't work due to the way Webfaction has their stuff set up,
* so this is a pretty decent workaround. It's a combination of various other efforts
* by different people who use Webfaction; if you feel you're not being credited for any
* of the effort/code below, feel free to email/message me on Github. I just want this to
/* cssWalker.js
*
* Traverse every stylesheet in the document and filter based on their selectors.
*
* @Requires: Nothing, completely standalone.
*
* @Returns: An array of style objects/rules. The order of the array is determined by the point
* of the stylesheet in the document - e.g, first stylesheet rules are top of the array.
*
* @Author: Ryan McGrath (ryan@webs.com)
/* The following chunk of code is just part of a generic page load-event handler.
* Notice that document.addEventListener is its own branch, the win32 portion
* shouldn't go in there...
*/
if(document.addEventListener) { document.addEventListener("DOMContentLoaded", init, false); }
/*@cc_on @*//*@if (@_win32) document.write("<script id=__ie_onload defer src=//0><\/scr"+"ipt>");script = document.getElementById("__ie_onload");script.onreadystatechange = function(){if(this.readyState == "complete") init();};/*@end @*/
if(/WebKit/i.test(navigator.userAgent)) { /* Old Webkit versions, don't ask */
<script type="text/javascript">
var vote = {
_cacheChecker: function(el) { this.el = el; },
cast: function(el) {
var query = new vote._cacheChecker(el);
query.check(function() {
/* Since image loading is an asynchronous operation,
we'd need some kind of callback junk here. The beauty is that,
if you put your code to record a vote in this block, it'll only ever
<script type="text/javascript">
$(document).ready(function(){
$('#slide_one').delay(2000).fadeOut(500, function() {
$('#slide_two').fadeIn(500).delay(2000).fadeOut(500, function() {
$('#slide_three').fadeIn(500).delay(2000).fadeOut(500, function() {
$('#slide_one').fadeIn(500);
});
});
});
});
/* A bastard child of a DOM wrapper. Includes a beautiful clone of jQuery's
$(document).ready(...); without the bloat of the entire library.
*/
Webs.DOM = {
/* An internal indicator as to whether or not we're still waiting on DOM ready. */
loaded: false,
/* An internal indicator as to whether or not we've already started watching the DOM. */
watchSet: false,
// Bad practice. Can you see why?
var foo = function() { alert("bar"); };
setTimeout("foo()", 2000);
var foo = function() { alert("bar"); };
// Better practice. Note how the function is passed this time.
setTimeout(foo, 2000);
// Bad practice. Why concoct such an ugly string?
var delayedLol = function(laugh) {
setTimeout("alert('Laughing: " + laugh + "')", 2000);
};
delayedLol("bwahahaha");
// Instead, pass around your argument (laugh) with anonymous functions.
var delayedLol = function(laugh) {
setTimeout(function() {