Skip to content

Instantly share code, notes, and snippets.

@sbussard
sbussard / img2canvas.js
Created October 12, 2013 03:58
Converts all images on a page to canvas of images
// requires jQuery obviously
$(function(){
$('img').each(function(i, img){
var $img = $(img);
var url = $img.attr('src');
var w = $img.width();
var h = $img.height();
var canvas = $('<canvas data-image="'+i+'"></canvas>').attr({ width: w, height: h });
$(img).replaceWith(canvas);
@sbussard
sbussard / meta.json
Created June 13, 2013 19:22
if all meta information was stored in a meta file it would be one step closer toward a more semantic web. meta.json could replace all html meta tags, robots.txt, humans.txt, and add the ability to map pages to ontologies through the use of selectors.
// created for apple.com/contact
"{
'language': 'en-us',
'charset': 'utf-8',
'author': 'Apple Inc.',
'omni_page': 'How to Contact Us',
'publish-date': 'May 12, 2013',
'sitemap': 'http://www.apple.com/sitemap',
'shortcut-icon': 'http://www.apple.com/favicon.ico',
'viewport': 'width=1024',
# add this line at the end of the file
python ~/.psam.py
@sbussard
sbussard / gist:2777767
Created May 23, 2012 20:57
animated neon thingies
/*
Author: Stephen Bussard
Twitter: @sbussard
*/
var sin = Math.sin;
var cos = Math.cos;
var tan = Math.tan;
@sbussard
sbussard / minivalidator.js
Created December 8, 2011 05:15
quick email validation
function validate(name, email) {
var errors = [];
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(name === '') {
errors.push('You forgot to enter your name');
}
if(email === '' || !emailReg.test(email)) {
errors.push('Your e-mail address is invalid');
@sbussard
sbussard / setup
Created November 15, 2011 22:49
rackspace + wordpress
sudo su
apt-get update
apt-get install unzip apache2 php5-mysql libapache2-mod-php5 mysql-server phpmyadmin
# go through the wizards and set up the passwords, making sure to write them down / memorize!
a2enmod rewrite
nano /etc/apache2/sites-enabled/000-default
# change AllowOverride setting for /var/www from None to All, save then quit
@sbussard
sbussard / upsshipping.html
Created August 26, 2011 20:03
Get UPS Shipping Rates
<!DOCTYPE html>
<!-- converted from php http://www.geekpedia.com/tutorial213_Creating-a-UPS-Shipping-Calculator.html -->
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Unofficial UPS Shipping Calculator</title>
</head>
@sbussard
sbussard / price.js
Created August 19, 2011 18:06
Price validation using jQuery
// usage: $("#price").priceField();
$.fn.getCaret = function() { // adapted from http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea
var ctrl = this[0];
var CaretPos = 0; // IE Support
if (document.selection) {
ctrl.focus();
var Sel = document.selection.createRange();
Sel.moveStart('character', -ctrl.value.length);
@sbussard
sbussard / snippets.less
Last active September 26, 2015 13:37
css3 snippet
.no-select {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
.no-drag {
-webkit-touch-callout: none;
@sbussard
sbussard / calculator.js
Created February 27, 2011 17:16
graphing calculator using html5 canvas and web workers
var sin = Math.sin;
var cos = Math.cos;
var tan = Math.tan;
var ln = Math.log;
var log = Math.LOG10E;
var pi = Math.PI;
onmessage = function (event) {
var n = event.data;
var p = [];